github.com/annchain/OG@v0.0.9/arefactor_core/core/state/statedb_interface.go (about) 1 package state 2 3 import ( 4 ogTypes "github.com/annchain/OG/arefactor/og_interface" 5 "github.com/annchain/OG/common/math" 6 ) 7 8 // StateDB is an OVM database for full state querying. 9 type StateDBInterface interface { 10 CreateAccount(ogTypes.Address) 11 12 SubBalance(ogTypes.Address, *math.BigInt) 13 SubTokenBalance(ogTypes.Address, int32, *math.BigInt) 14 AddBalance(ogTypes.Address, *math.BigInt) 15 AddTokenBalance(ogTypes.Address, int32, *math.BigInt) 16 SetTokenBalance(ogTypes.Address, int32, *math.BigInt) 17 // Retrieve the balance from the given address or 0 if object not found 18 GetBalance(ogTypes.Address) *math.BigInt 19 GetTokenBalance(ogTypes.Address, int32) *math.BigInt 20 21 GetNonce(ogTypes.Address) uint64 22 SetNonce(ogTypes.Address, uint64) 23 24 GetCodeHash(ogTypes.Address) ogTypes.Hash 25 GetCode(ogTypes.Address) []byte 26 SetCode(ogTypes.Address, []byte) 27 GetCodeSize(ogTypes.Address) int 28 29 // AddRefund adds gas to the refund counter 30 AddRefund(uint64) 31 // SubRefund removes gas from the refund counter. 32 // This method will panic if the refund counter goes below zero 33 SubRefund(uint64) 34 // GetRefund returns the current value of the refund counter. 35 GetRefund() uint64 36 37 GetCommittedState(ogTypes.Address, ogTypes.Hash) ogTypes.Hash 38 // GetState retrieves a value from the given account's storage trie. 39 GetState(ogTypes.Address, ogTypes.Hash) ogTypes.Hash 40 SetState(ogTypes.Address, ogTypes.Hash, ogTypes.Hash) 41 42 AppendJournal(JournalEntry) 43 44 // Suicide marks the given account as suicided. 45 // This clears the account balance. 46 // 47 // The account's state object is still available until the state is committed, 48 // getStateObject will return a non-nil account after Suicide. 49 Suicide(ogTypes.Address) bool 50 HasSuicided(ogTypes.Address) bool 51 52 // Exist reports whether the given account exists in state. 53 // Notably this should also return true for suicided accounts. 54 Exist(ogTypes.Address) bool 55 // Empty returns whether the given account is empty. Empty 56 // is defined according to EIP161 (balance = nonce = code = 0). 57 Empty(ogTypes.Address) bool 58 59 // RevertToSnapshot reverts all state changes made since the given revision. 60 RevertToSnapshot(int) 61 // Snapshot creates a new revision 62 Snapshot() int 63 64 //AddLog(*Log) 65 AddPreimage(ogTypes.Hash, []byte) 66 67 ForEachStorage(ogTypes.Address, func(ogTypes.Hash, ogTypes.Hash) bool) 68 // for debug. 69 String() string 70 }