StateDBs within the ethereum protocol are used to store anything within the merkle trie. StateDBs take care of caching and storing nested states. It's the general query interface to retrieve: * Contracts * Accounts
| 50 | // * Contracts |
| 51 | // * Accounts |
| 52 | type StateDB struct { |
| 53 | db Database |
| 54 | trie Trie |
| 55 | |
| 56 | // This map holds 'live' objects, which will get modified while processing a state transition. |
| 57 | stateObjects map[common.Address]*stateObject |
| 58 | stateObjectsDirty map[common.Address]struct{} |
| 59 | |
| 60 | // DB error. |
| 61 | // State objects are used by the consensus core and VM which are |
| 62 | // unable to deal with database-level errors. Any error that occurs |
| 63 | // during a database read is memoized here and will eventually be returned |
| 64 | // by StateDB.Commit. |
| 65 | dbErr error |
| 66 | |
| 67 | // The refund counter, also used by state transitioning. |
| 68 | refund uint64 |
| 69 | |
| 70 | thash, bhash common.Hash |
| 71 | txIndex int |
| 72 | logs map[common.Hash][]*types.Log |
| 73 | logSize uint |
| 74 | |
| 75 | preimages map[common.Hash][]byte |
| 76 | |
| 77 | // Journal of state modifications. This is the backbone of |
| 78 | // Snapshot and RevertToSnapshot. |
| 79 | journal *journal |
| 80 | validRevisions []revision |
| 81 | nextRevisionId int |
| 82 | |
| 83 | lock sync.Mutex |
| 84 | } |
| 85 | |
| 86 | // Create a new state from a given trie. |
| 87 | func New(root common.Hash, db Database) (*StateDB, error) { |
nothing calls this directly
no outgoing calls
no test coverage detected