filecoin-project / go-amt-ipld

Implementation of an array mapped trie using go and ipld
Other
9 stars 15 forks source link

fix: reset leaf node bitmap on flush #24

Closed rvagg closed 4 years ago

rvagg commented 4 years ago

Flush() rebuilds the serializable form of the node and, setting the Values array for leaves and Links for non-leaves, in the process it sets up the bitmap again for each set element. On the non-leaf nodes we get a fresh bitmap to work with but the same is not done on leaf nodes.

I'm not convinced this is strictly necessary since setBit() and clearBit() are called on mutations elsewhere, but as long as we're doing a fresh rebuild and it's being done for non-leaf nodes, this should be done here to be absolutely sure, otherwise the n.setBit(i) isn't necessary either.