Closed tac0turtle closed 11 months ago
The issue I have with simply adding an option and still taking the whole struct, is that you may overwrite a good default option that you haven't provided.
Example here: https://github.com/cosmos/cosmos-sdk/blob/66d9be0e1080ab6c7e013fc83bfed18ddd1b3c14/store/iavl/store.go#L54
We could simplify the api by adding a variadic way to update the options. Bonus is that NewMutableTreeWithOpts can still be used to provide all options, so there is no API break (or we clean it up and remove it).
type Option func(*Options)
NewMutableTree(db dbm.DB, cacheSize int, skipFastStorageUpgrade bool, lg log.Logger, options ...Option) *MutableTree {
opts := DefaultOptions()
for _, opt := range options {
opt(&opts)
}
return NewMutableTreeWithOpts(...)
}
Unless we are ok with that risk, and then it lgtm!
I like @julienrbrt 's idea, we should make sure to set the default options even if users miss the config
testing failed ?
@Mergifyio backport release/v1.x.x
backport release/v1.x.x
follow up to https://github.com/cosmos/iavl/pull/807