MCPcopy Create free account
hub / github.com/CPChain/chain / GetPrivateStateRoot

Function GetPrivateStateRoot

core/private_database.go:38–45  ·  view source on GitHub ↗

GetPrivateStateRoot gets the root(hash) for private state associated with the root of Merkle tree in public chain.

(db database.Database, blockRoot common.Hash)

Source from the content-addressed store, hash-verified

36
37// GetPrivateStateRoot gets the root(hash) for private state associated with the root of Merkle tree in public chain.
38func GetPrivateStateRoot(db database.Database, blockRoot common.Hash) common.Hash {
39 exist, _ := db.Has(append(privateRootPrefix, blockRoot[:]...))
40 if exist {
41 root, _ := db.Get(append(privateRootPrefix, blockRoot[:]...))
42 return common.BytesToHash(root)
43 }
44 return common.Hash{}
45}
46
47// WritePrivateStateRoot writes the root(hash) for private state associated with the root of Merkle tree in public chain.
48func WritePrivateStateRoot(db database.Database, blockRoot, root common.Hash) error {

Callers 10

GenerateChainFunction · 0.85
TestGetPrivateStateRootFunction · 0.85
loadLastStateMethod · 0.85
SetHeadMethod · 0.85
StatePrivAtMethod · 0.85
repairMethod · 0.85
CommitStateDBMethod · 0.85
ValidateBlockBodyMethod · 0.85
insertChainMethod · 0.85
testBlockChainImportFunction · 0.85

Calls 2

HasMethod · 0.65
GetMethod · 0.65

Tested by 2

TestGetPrivateStateRootFunction · 0.68
testBlockChainImportFunction · 0.68