@@ -75,25 +75,25 @@ func NewStateTrie(id *ID, db *Database) (*StateTrie, error) {
7575// Get returns the value for key stored in the trie.
7676// The value bytes must not be modified by the caller.
7777func (t * StateTrie ) Get (key []byte ) []byte {
78- res , err := t .TryGetStorage (common.Address {}, key )
78+ res , err := t .GetStorage (common.Address {}, key )
7979 if err != nil {
8080 log .Error ("Unhandled trie error in StateTrie.Get" , "err" , err )
8181 }
8282 return res
8383}
8484
85- // TryGet returns the value for key stored in the trie.
86- // The value bytes must not be modified by the caller.
87- // If the specified node is not in the trie, nil will be returned.
85+ // GetStorage attempts to retrieve a storage slot with provided account address
86+ // and slot key. The value bytes must not be modified by the caller.
87+ // If the specified storage slot is not in the trie, nil will be returned.
8888// If a trie node is not found in the database, a MissingNodeError is returned.
89- func (t * StateTrie ) TryGetStorage (_ common.Address , key []byte ) ([]byte , error ) {
89+ func (t * StateTrie ) GetStorage (_ common.Address , key []byte ) ([]byte , error ) {
9090 return t .trie .TryGet (t .hashKey (key ))
9191}
9292
93- // TryGetAccount attempts to retrieve an account with provided account address.
93+ // GetAccount attempts to retrieve an account with provided account address.
9494// If the specified account is not in the trie, nil will be returned.
9595// If a trie node is not found in the database, a MissingNodeError is returned.
96- func (t * StateTrie ) TryGetAccount (address common.Address ) (* types.StateAccount , error ) {
96+ func (t * StateTrie ) GetAccount (address common.Address ) (* types.StateAccount , error ) {
9797 res , err := t .trie .TryGet (t .hashKey (address .Bytes ()))
9898 if res == nil || err != nil {
9999 return nil , err
@@ -103,10 +103,10 @@ func (t *StateTrie) TryGetAccount(address common.Address) (*types.StateAccount,
103103 return ret , err
104104}
105105
106- // TryGetAccountByHash does the same thing as TryGetAccount , however
107- // it expects an account hash that is the hash of address. This constitutes an
108- // abstraction leak, since the client code needs to know the key format.
109- func (t * StateTrie ) TryGetAccountByHash (addrHash common.Hash ) (* types.StateAccount , error ) {
106+ // GetAccountByHash does the same thing as GetAccount , however it expects an
107+ // account hash that is the hash of address. This constitutes an abstraction
108+ // leak, since the client code needs to know the key format.
109+ func (t * StateTrie ) GetAccountByHash (addrHash common.Hash ) (* types.StateAccount , error ) {
110110 res , err := t .trie .TryGet (addrHash .Bytes ())
111111 if res == nil || err != nil {
112112 return nil , err
@@ -116,11 +116,11 @@ func (t *StateTrie) TryGetAccountByHash(addrHash common.Hash) (*types.StateAccou
116116 return ret , err
117117}
118118
119- // TryGetNode attempts to retrieve a trie node by compact-encoded path. It is not
119+ // GetNode attempts to retrieve a trie node by compact-encoded path. It is not
120120// possible to use keybyte-encoding as the path might contain odd nibbles.
121121// If the specified trie node is not in the trie, nil will be returned.
122122// If a trie node is not found in the database, a MissingNodeError is returned.
123- func (t * StateTrie ) TryGetNode (path []byte ) ([]byte , int , error ) {
123+ func (t * StateTrie ) GetNode (path []byte ) ([]byte , int , error ) {
124124 return t .trie .TryGetNode (path )
125125}
126126
@@ -131,20 +131,20 @@ func (t *StateTrie) TryGetNode(path []byte) ([]byte, int, error) {
131131// The value bytes must not be modified by the caller while they are
132132// stored in the trie.
133133func (t * StateTrie ) Update (key , value []byte ) {
134- if err := t .TryUpdateStorage (common.Address {}, key , value ); err != nil {
134+ if err := t .UpdateStorage (common.Address {}, key , value ); err != nil {
135135 log .Error ("Unhandled trie error in StateTrie.Update" , "err" , err )
136136 }
137137}
138138
139- // TryUpdate associates key with value in the trie. Subsequent calls to
139+ // UpdateStorage associates key with value in the trie. Subsequent calls to
140140// Get will return value. If value has length zero, any existing value
141141// is deleted from the trie and calls to Get will return nil.
142142//
143143// The value bytes must not be modified by the caller while they are
144144// stored in the trie.
145145//
146146// If a node is not found in the database, a MissingNodeError is returned.
147- func (t * StateTrie ) TryUpdateStorage (_ common.Address , key , value []byte ) error {
147+ func (t * StateTrie ) UpdateStorage (_ common.Address , key , value []byte ) error {
148148 hk := t .hashKey (key )
149149 err := t .trie .TryUpdate (hk , value )
150150 if err != nil {
@@ -154,9 +154,8 @@ func (t *StateTrie) TryUpdateStorage(_ common.Address, key, value []byte) error
154154 return nil
155155}
156156
157- // TryUpdateAccount account will abstract the write of an account to the
158- // secure trie.
159- func (t * StateTrie ) TryUpdateAccount (address common.Address , acc * types.StateAccount ) error {
157+ // UpdateAccount will abstract the write of an account to the secure trie.
158+ func (t * StateTrie ) UpdateAccount (address common.Address , acc * types.StateAccount ) error {
160159 hk := t .hashKey (address .Bytes ())
161160 data , err := rlp .EncodeToBytes (acc )
162161 if err != nil {
@@ -171,22 +170,22 @@ func (t *StateTrie) TryUpdateAccount(address common.Address, acc *types.StateAcc
171170
172171// Delete removes any existing value for key from the trie.
173172func (t * StateTrie ) Delete (key []byte ) {
174- if err := t .TryDeleteStorage (common.Address {}, key ); err != nil {
173+ if err := t .DeleteStorage (common.Address {}, key ); err != nil {
175174 log .Error ("Unhandled trie error in StateTrie.Delete" , "err" , err )
176175 }
177176}
178177
179- // TryDelete removes any existing value for key from the trie.
178+ // DeleteStorage removes any existing storage slot from the trie.
180179// If the specified trie node is not in the trie, nothing will be changed.
181180// If a node is not found in the database, a MissingNodeError is returned.
182- func (t * StateTrie ) TryDeleteStorage (_ common.Address , key []byte ) error {
181+ func (t * StateTrie ) DeleteStorage (_ common.Address , key []byte ) error {
183182 hk := t .hashKey (key )
184183 delete (t .getSecKeyCache (), string (hk ))
185184 return t .trie .TryDelete (hk )
186185}
187186
188- // TryDeleteAccount abstracts an account deletion from the trie.
189- func (t * StateTrie ) TryDeleteAccount (address common.Address ) error {
187+ // DeleteAccount abstracts an account deletion from the trie.
188+ func (t * StateTrie ) DeleteAccount (address common.Address ) error {
190189 hk := t .hashKey (address .Bytes ())
191190 delete (t .getSecKeyCache (), string (hk ))
192191 return t .trie .TryDelete (hk )
0 commit comments