@@ -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. 
2628type  StateDBCommitOption  =  options.Option [stateDBCommitConfig ]
2729
2830type  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. 
3438func  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. 
4147func  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. 
4554func  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. 
5263func  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. 
8193type  TrieDBUpdateOption  =  options.Option [triedbUpdateConfig ]
8294
8395type  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. 
87102func  WithTrieDBUpdatePayload (p  any ) TrieDBUpdateOption  {
88103	return  options.Func [triedbUpdateConfig ](func (c  * triedbUpdateConfig ) {
89104		c .payload  =  p 
0 commit comments