Skip to content

Commit 5e0fbdc

Browse files
committed
fix: other changes
1 parent 661488a commit 5e0fbdc

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

core/extstate/firewood_database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (*firewoodAccessorDb) OpenStorageTrie(_ common.Hash, _ common.Address, acco
3434
if !ok {
3535
return nil, fmt.Errorf("Invalid account trie type: %T", self)
3636
}
37-
return firewood.NewStorageTrie(accountTrie, accountRoot)
37+
return firewood.NewStorageTrie(accountTrie)
3838
}
3939

4040
// CopyTrie returns a deep copy of the given trie.

triedb/firewood/account_trie.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ func (a *AccountTrie) GetAccount(addr common.Address) (*types.StateAccount, erro
8989
}
9090

9191
// GetStorage returns the value associated with a storage key for a given account address.
92-
// If the storage slot has been updated, the new value is returned.
93-
// If the storage slot has been deleted, (nil, nil) is returned.
94-
// If the storage slot does not exist, (nil, nil) is returned.
92+
// - If the storage slot has been updated, the new value is returned.
93+
// - If the storage slot has been deleted, (nil, nil) is returned.
94+
// - If the storage slot does not exist, (nil, nil) is returned.
9595
func (a *AccountTrie) GetStorage(addr common.Address, key []byte) ([]byte, error) {
9696
// If the account has been deleted, we should return nil
9797
accountKey := crypto.Keccak256Hash(addr.Bytes()).Bytes()

triedb/firewood/database.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ var Defaults = Config{
7777
}
7878

7979
func (c Config) BackendConstructor(ethdb.Database) triedb.DBOverride {
80-
return New(&c)
80+
db, err := New(c)
81+
if err != nil {
82+
log.Crit("firewood: error creating database", "error", err)
83+
}
84+
return db
8185
}
8286

8387
type Database struct {
@@ -94,14 +98,9 @@ type Database struct {
9498

9599
// New creates a new Firewood database with the given disk database and configuration.
96100
// Any error during creation will cause the program to exit.
97-
func New(config *Config) *Database {
98-
if config == nil {
99-
log.Crit("firewood: config must be provided")
100-
}
101-
102-
err := validatePath(config.FilePath)
103-
if err != nil {
104-
log.Crit("firewood: error validating config", "error", err)
101+
func New(config Config) (*Database, error) {
102+
if err := validatePath(config.FilePath); err != nil {
103+
return nil, err
105104
}
106105

107106
fw, err := ffi.New(config.FilePath, &ffi.Config{
@@ -111,12 +110,12 @@ func New(config *Config) *Database {
111110
ReadCacheStrategy: config.ReadCacheStrategy,
112111
})
113112
if err != nil {
114-
log.Crit("firewood: error creating firewood database", "error", err)
113+
return nil, err
115114
}
116115

117116
currentRoot, err := fw.Root()
118117
if err != nil {
119-
log.Crit("firewood: error getting current root", "error", err)
118+
return nil, err
120119
}
121120

122121
return &Database{
@@ -125,7 +124,7 @@ func New(config *Config) *Database {
125124
proposalTree: &ProposalContext{
126125
Root: common.Hash(currentRoot),
127126
},
128-
}
127+
}, nil
129128
}
130129

131130
func validatePath(path string) error {

triedb/firewood/storage_trie.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type StorageTrie struct {
1414

1515
// `NewStorageTrie` returns a wrapper around an `AccountTrie` since Firewood
1616
// does not require a separate storage trie. All changes are managed by the account trie.
17-
func NewStorageTrie(accountTrie *AccountTrie, _ common.Hash) (*StorageTrie, error) {
17+
func NewStorageTrie(accountTrie *AccountTrie) (*StorageTrie, error) {
1818
return &StorageTrie{
1919
AccountTrie: accountTrie,
2020
}, nil

0 commit comments

Comments
 (0)