EYBlockchain / timber

Construct a Merkle Tree database from Ethereum logs.
Other
67 stars 19 forks source link

emit leaf count fix? #11

Closed tkstanczak closed 3 years ago

tkstanczak commented 4 years ago

correct if I am wrong but we probably want to emit the leaf count after incrementing it? (specifically when inserting many leaves the new leaf count value does not have to be equal to previous + number of leaves added?)

tkstanczak commented 4 years ago

also fixed the comments about the tree rows

iAmMichaelConnor commented 4 years ago

@tkstanczak thanks for the PR, and for taking a look at the project! Apologies that I've only just seen this now.

Thanks for spotting the errors in the comments about tree rows.

correct if I am wrong but we probably want to emit the leaf count after incrementing it?

The event parameter's name actually relates to the leafIndex of the leaf that was just inserted (rather than leafCount).

event NewLeaf(uint leafIndex, bytes32 leafValue, bytes32 root);
event NewLeaves(uint minLeafIndex, bytes32[] leafValues, bytes32 root);

So if the 0th leaf was just inserted, then the leafIndex to emit is 0. The leafCount then gets updated to 1, but it's not emitted by any events.