yillkid / iota-swarm-node

IOTA Swarm node Reference Implementation
Other
12 stars 9 forks source link

Attachment timestamp required on Mainnet #15

Closed wusyong closed 6 years ago

wusyong commented 6 years ago

Unlike devnet, transaction without attachment_timestamp won't be confirm on mainnet even with recent hercules tip-sel algo. I can provide more results if needed. As for now, here's side by side comparison:

jserv commented 6 years ago

@wusyong, can you propose the expected modifications against existing codebase?

wusyong commented 6 years ago

Here is the modification. time_start_pow is moved inside the loop since every transactions in same bundle are expected to have different attachment timestamp. timestamp_lower_bound and timestamp_upper_bound are optional, even api call attachToTangle from IRI assign 0 and max value separately. So they are assigned same values here. Should I create a pull request?

Proposed method:

        # attachment_timestamp = time_start_pow
        time_start_pow = time.time()
        timestamp = TryteString.from_trits(
            trits_from_int(int(round(time_start_pow * 1000)), pad=27))
        tx_tryte = insert_to_trytes(2619, 2528, str(timestamp), tx_tryte)

        # timestamp_lower_bound = 0
        # timestamp_upper_bound = MAX_VALUE - 1
        timestamp_upper_bound = TryteString("MMMMMMMMM")
        tx_tryte = insert_to_trytes(2637, 2646, str(timestamp_upper_bound), tx_tryte)

https://github.com/wusyong/iota-swarm-node/blob/2f2f30e3ecadbebbacb3dfe1eeef7da21ce2effb/swarm_node.py#L129-L138

Edit: Don't know why code snippet doesn't work properly. So just put the code here directly.