iotaledger / iota.py

PyOTA: The IOTA Python API Library
https://docs.iota.org/
MIT License
345 stars 124 forks source link

Add metadata field to iota.Transaction #94

Open mlouielu opened 6 years ago

mlouielu commented 6 years ago

Maybe we can add metadata field in iota.Transaction

Example of transaction metadata field name:

    return {
        'address': address,
        'bundle_hash': bundle,
        'trunk_transaction_hash': trunk,
        'branch_transaction_hash': branch,
        'legacy_tag': legacy_tag,
        'value': value,
        'current_index': current_index,
        'last_index': last_index,
        'timestamp': timestamp,
        'tag': tag,
        'attachment_timestamp': attachment_timestamp,
        'attachment_timestamp_lower_bound': attachment_timestamp_lower_bound,
        'attachment_timestamp_upper_bound': attachment_timestamp_upper_bound,
        'validity': validity,
        'type': type_,
        'arrival_time': arrival_time,
        'height': height,
        'solid': solid,
        'snapshot': snapshot,
        'sender': sender
    }
todofixthis commented 6 years ago

Hey @mlouielu interesting idea. Are these values included in the transaction data on the Tangle, or would they be loaded from another source?

mlouielu commented 6 years ago

The field is only found in IRI rocksdb transaction-metadata column. And used for milestone, node...etc to check the transaction validity and other information.

The default value can be found at: https://github.com/iotaledger/iri/blob/dev/src/main/java/com/iota/iri/model/Transaction.java#L32

Addidtional field is: validity, type, arrival_time, solid, height, sender, snapshot.

todofixthis commented 6 years ago

Hmmmmmmmm. Very interesting.

I think most PyOTA users will not interface directly with the IRI database, so I'm not sure if it's the right approach to integrate this into the PyOTA core.

However, I really like what you're doing with https://github.com/mlouielu/iota-python . What do you think about subclassing Transaction in your library to add the extra fields?

This will give advanced users a way to interface directly with rocksdb, without confusing users who don't need to know about that implementation detail.

bhargavrpatel commented 6 years ago

I agree with @todofixthis's proposal.