Skip to content

Commit 46a8274

Browse files
committed
docs: accurate comments
1 parent bae5586 commit 46a8274

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

libevm/stateconf/conf.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323

2424
// A StateDBCommitOption configures the behaviour of all update calls within the
2525
// state.StateDB.Commit() implementations.
26+
// This is provided in two distinct types to allow customizability to both
27+
// snapshot and trie database updates, but are ignored in libevm implementations.
2628
type StateDBCommitOption = options.Option[stateDBCommitConfig]
2729

2830
type stateDBCommitConfig struct {
@@ -31,24 +33,33 @@ type stateDBCommitConfig struct {
3133
}
3234

3335
// WithSnapshotUpdateOpts returns a StateDBCommitOption carrying a list of
36+
// SnapshotUpdateOptions.
37+
// If the list is not of length 1, the last option in the list is used.
3438
func WithSnapshotUpdateOpts(opts ...SnapshotUpdateOption) StateDBCommitOption {
3539
return options.Func[stateDBCommitConfig](func(c *stateDBCommitConfig) {
3640
// I don't like append() because there's no way to remove options, but that's a weakly held opinion
3741
c.snapshotOpts = opts
3842
})
3943
}
4044

45+
// ExtractSnapshotUpdateOpts returns the list of SnapshotUpdateOptions carried
46+
// by the provided slice of StateDBCommitOption.
4147
func ExtractSnapshotUpdateOpts(opts ...StateDBCommitOption) []SnapshotUpdateOption {
4248
return options.As(opts...).snapshotOpts
4349
}
4450

51+
// WithTrieDBUpdateOpts returns a StateDBCommitOption carrying a list of
52+
// TrieDBUpdateOptions. If the list is not of length 1, the last option in the
53+
// list is used.
4554
func WithTrieDBUpdateOpts(opts ...TrieDBUpdateOption) StateDBCommitOption {
4655
return options.Func[stateDBCommitConfig](func(c *stateDBCommitConfig) {
4756
// I don't like append() because there's no way to remove options, but that's a weakly held opinion
4857
c.triedbOpts = opts
4958
})
5059
}
5160

61+
// ExtractTrieDBUpdateOpts returns the list of TrieDBUpdateOptions carried by
62+
// the provided slice of StateDBCommitOption.
5263
func ExtractTrieDBUpdateOpts(opts ...StateDBCommitOption) []TrieDBUpdateOption {
5364
return options.As(opts...).triedbOpts
5465
}
@@ -78,12 +89,16 @@ func ExtractSnapshotUpdatePayload(opts ...SnapshotUpdateOption) any {
7889
return options.As(opts...).payload
7990
}
8091

92+
// A TrieDBUpdateOption configures the behaviour of triedb.Database.Update() implementations.
8193
type TrieDBUpdateOption = options.Option[triedbUpdateConfig]
8294

8395
type triedbUpdateConfig struct {
8496
payload any
8597
}
8698

99+
// WithTrieDBUpdatePayload returns a TrieDBUpdateOption carrying an arbitrary
100+
// payload. It acts only as a carrier to exploit existing function plumbing and
101+
// the effect on behaviour is left to the implementation receiving it.
87102
func WithTrieDBUpdatePayload(p any) TrieDBUpdateOption {
88103
return options.Func[triedbUpdateConfig](func(c *triedbUpdateConfig) {
89104
c.payload = p

0 commit comments

Comments
 (0)