@@ -75,25 +75,25 @@ func NewStateTrie(id *ID, db *Database) (*StateTrie, error) {
75
75
// Get returns the value for key stored in the trie.
76
76
// The value bytes must not be modified by the caller.
77
77
func (t * StateTrie ) Get (key []byte ) []byte {
78
- res , err := t .TryGetStorage (common.Address {}, key )
78
+ res , err := t .GetStorage (common.Address {}, key )
79
79
if err != nil {
80
80
log .Error ("Unhandled trie error in StateTrie.Get" , "err" , err )
81
81
}
82
82
return res
83
83
}
84
84
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.
88
88
// 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 ) {
90
90
return t .trie .TryGet (t .hashKey (key ))
91
91
}
92
92
93
- // TryGetAccount attempts to retrieve an account with provided account address.
93
+ // GetAccount attempts to retrieve an account with provided account address.
94
94
// If the specified account is not in the trie, nil will be returned.
95
95
// 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 ) {
97
97
res , err := t .trie .TryGet (t .hashKey (address .Bytes ()))
98
98
if res == nil || err != nil {
99
99
return nil , err
@@ -103,10 +103,10 @@ func (t *StateTrie) TryGetAccount(address common.Address) (*types.StateAccount,
103
103
return ret , err
104
104
}
105
105
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 ) {
110
110
res , err := t .trie .TryGet (addrHash .Bytes ())
111
111
if res == nil || err != nil {
112
112
return nil , err
@@ -116,11 +116,11 @@ func (t *StateTrie) TryGetAccountByHash(addrHash common.Hash) (*types.StateAccou
116
116
return ret , err
117
117
}
118
118
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
120
120
// possible to use keybyte-encoding as the path might contain odd nibbles.
121
121
// If the specified trie node is not in the trie, nil will be returned.
122
122
// 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 ) {
124
124
return t .trie .TryGetNode (path )
125
125
}
126
126
@@ -131,20 +131,20 @@ func (t *StateTrie) TryGetNode(path []byte) ([]byte, int, error) {
131
131
// The value bytes must not be modified by the caller while they are
132
132
// stored in the trie.
133
133
func (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 {
135
135
log .Error ("Unhandled trie error in StateTrie.Update" , "err" , err )
136
136
}
137
137
}
138
138
139
- // TryUpdate associates key with value in the trie. Subsequent calls to
139
+ // UpdateStorage associates key with value in the trie. Subsequent calls to
140
140
// Get will return value. If value has length zero, any existing value
141
141
// is deleted from the trie and calls to Get will return nil.
142
142
//
143
143
// The value bytes must not be modified by the caller while they are
144
144
// stored in the trie.
145
145
//
146
146
// 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 {
148
148
hk := t .hashKey (key )
149
149
err := t .trie .TryUpdate (hk , value )
150
150
if err != nil {
@@ -154,9 +154,8 @@ func (t *StateTrie) TryUpdateStorage(_ common.Address, key, value []byte) error
154
154
return nil
155
155
}
156
156
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 {
160
159
hk := t .hashKey (address .Bytes ())
161
160
data , err := rlp .EncodeToBytes (acc )
162
161
if err != nil {
@@ -171,22 +170,22 @@ func (t *StateTrie) TryUpdateAccount(address common.Address, acc *types.StateAcc
171
170
172
171
// Delete removes any existing value for key from the trie.
173
172
func (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 {
175
174
log .Error ("Unhandled trie error in StateTrie.Delete" , "err" , err )
176
175
}
177
176
}
178
177
179
- // TryDelete removes any existing value for key from the trie.
178
+ // DeleteStorage removes any existing storage slot from the trie.
180
179
// If the specified trie node is not in the trie, nothing will be changed.
181
180
// 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 {
183
182
hk := t .hashKey (key )
184
183
delete (t .getSecKeyCache (), string (hk ))
185
184
return t .trie .TryDelete (hk )
186
185
}
187
186
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 {
190
189
hk := t .hashKey (address .Bytes ())
191
190
delete (t .getSecKeyCache (), string (hk ))
192
191
return t .trie .TryDelete (hk )
0 commit comments