blob: 8b94cfab2e44e832fd8cde2ddc1b28ad7f571b1c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package state
import (
"github.com/dexon-foundation/dexon/common"
"github.com/dexon-foundation/dexon/core/types"
"github.com/dexon-foundation/dexon/trie"
)
func GetGovState(statedb *StateDB, header *types.Header,
addr common.Address) (*types.GovState, error) {
proof, err := statedb.GetProof(addr)
if err != nil {
return nil, err
}
govState := &types.GovState{
BlockHash: header.Hash(),
Number: header.Number,
Root: header.Root,
Proof: proof,
}
if t := statedb.StorageTrie(addr); t != nil {
it := trie.NewIterator(t.NodeIterator(nil))
for it.Next() {
govState.Storage = append(govState.Storage,
[2][]byte{it.Key, it.Value})
}
}
return govState, nil
}
|