RainBlock/merkle-patricia-tree

getFromCache needs to return which nodes were used

Closed this issue · 0 comments

We need to return which nodes were actually used from the cache, so we can save space by not re-transmitting nodes which were not used.

I suggest actually changing the signature of getFromCache to this:

interface CachedTraversal<V> {
   value : V;
   nodesUsed: bigint[];
}

getFromCache(key: K, nodesBags... : Map<bigint, MerklePatriciaTreeNode<V>) : CachedTraversal<V>

nodeBags should be variable arguments, so we can support a simple cache in the future of frequently used accounts. Example:

getFromCache("buffer", nodeBag, cache);