Update statedb docs and constructor

This commit is contained in:
Aleksandr Bezobchuk 2018-10-04 12:09:59 -04:00
parent 2feb5bbb5b
commit 3c47af91ab

View File

@ -49,6 +49,8 @@ type CommitStateDB struct {
logs map[ethcmn.Hash][]*ethtypes.Log logs map[ethcmn.Hash][]*ethtypes.Log
logSize uint logSize uint
// TODO: Determine if we actually need this as we do not need preimages in
// the SDK, but it seems to be used elsewhere in Geth.
preimages map[ethcmn.Hash][]byte preimages map[ethcmn.Hash][]byte
// DB error. // DB error.
@ -68,13 +70,16 @@ type CommitStateDB struct {
lock sync.Mutex lock sync.Mutex
} }
// TODO: Make sure storage is prefixed with address!!! // NewCommitStateDB returns a reference to a newly initialized CommitStateDB
// which implements Geth's state.StateDB interface.
func NewCommitStateDB(ctx sdk.Context) (*CommitStateDB, error) { func NewCommitStateDB(ctx sdk.Context, am auth.AccountMapper) (*CommitStateDB, error) {
return &CommitStateDB{ return &CommitStateDB{
ctx: ctx,
am: am,
stateObjects: make(map[ethcmn.Address]*stateObject), stateObjects: make(map[ethcmn.Address]*stateObject),
stateObjectsDirty: make(map[ethcmn.Address]struct{}), stateObjectsDirty: make(map[ethcmn.Address]struct{}),
logs: make(map[ethcmn.Hash][]*ethtypes.Log), logs: make(map[ethcmn.Hash][]*ethtypes.Log),
preimages: make(map[ethcmn.Hash][]byte),
journal: newJournal(), journal: newJournal(),
}, nil }, nil
} }