[trie] add MerkleProofPast to query a state at a given past block
@@ -9,7 +9,7 @@ import (
"bytes"
)
-// MerkleProof generates a Merke proof of inclusion for a given trie root
+// MerkleProof generates a Merke proof of inclusion for the current trie root
// The proof of non inclusion is not explicit : it is a proof that
// a leaf node is on the path of the non included key.
// returns the audit path, true (key included), key, value (unless key is not included
@@ -21,6 +21,18 @@ func (s *Trie) MerkleProof(key []byte) ([][]byte, bool, []byte, []byte, error) {
return s.merkleProof(s.Root, key, nil, s.TrieHeight, 0)
}
+// MerkleProofPast generates a Merke proof of inclusion for a given past trie root
+// The proof of non inclusion is not explicit : it is a proof that
+// a leaf node is on the path of the non included key.
+// returns the audit path, true (key included), key, value (unless key is not included
+// and there is no shortcut on the path), error
+func (s *Trie) MerkleProofPast(key []byte, root []byte) ([][]byte, bool, []byte, []byte, error) {
+ s.lock.RLock()
+ defer s.lock.RUnlock()
+ s.atomicUpdate = false // so loadChildren doesnt return a copy
+ return s.merkleProof(root, key, nil, s.TrieHeight, 0)
+}
+
// MerkleProofCompressed returns a compressed merkle proof
func (s *Trie) MerkleProofCompressed(key []byte) ([]byte, [][]byte, uint64, bool, []byte, []byte, error) {
s.lock.RLock()
