mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-31 16:21:21 +00:00
21 lines
918 B
Go
21 lines
918 B
Go
package trie
|
|
|
|
func (t *Trie) ExtractWitness(blockNr uint64, trace bool, rs *ResolveSet, codeMap CodeMap) (*Witness, error) {
|
|
return extractWitnessFromRootNode(t.root, blockNr, trace, rs, codeMap)
|
|
}
|
|
|
|
// extractWitnessFromRootNode extracts a witness for a subtrie starting from the specified root
|
|
// if hashOnly param is nil it will make a witness for the full subtrie,
|
|
// if hashOnly param is set to a ResolveSet instance, it will make a witness for only the accounts/storages that were actually touched; other paths will be hashed.
|
|
func extractWitnessFromRootNode(root node, blockNr uint64, trace bool, hashOnly HashOnly, codeMap CodeMap) (*Witness, error) {
|
|
builder := NewWitnessBuilder(root, blockNr, trace, codeMap)
|
|
var limiter *MerklePathLimiter
|
|
if hashOnly != nil {
|
|
hr := newHasher(false)
|
|
defer returnHasherToPool(hr)
|
|
limiter = &MerklePathLimiter{hashOnly, hr.hash}
|
|
}
|
|
|
|
return builder.Build(limiter)
|
|
}
|