Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make batcher configurable #815

Merged
merged 5 commits into from
Aug 11, 2023

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Aug 11, 2023

follow up to #807

@tac0turtle tac0turtle marked this pull request as ready for review August 11, 2023 13:30
@tac0turtle tac0turtle requested a review from a team as a code owner August 11, 2023 13:30
@tac0turtle tac0turtle changed the title make batcher configurable refactor: make batcher configurable Aug 11, 2023
@julienrbrt
Copy link
Member

julienrbrt commented Aug 11, 2023

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!

@cool-develope
Copy link
Collaborator

I like @julienrbrt 's idea, we should make sure to set the default options even if users miss the config

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

CHANGELOG.md Show resolved Hide resolved
@cool-develope
Copy link
Collaborator

testing failed ?

@julienrbrt julienrbrt enabled auto-merge (squash) August 11, 2023 16:04
@julienrbrt julienrbrt merged commit 0420895 into master Aug 11, 2023
7 checks passed
@julienrbrt julienrbrt deleted the marko/make_batcher_configurable branch August 11, 2023 16:10
@julienrbrt
Copy link
Member

@Mergifyio backport release/v1.x.x

@mergify
Copy link
Contributor

mergify bot commented Aug 11, 2023

backport release/v1.x.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Aug 11, 2023
Co-authored-by: Marko Baricevic <marbar3778@yahoo.com>
Co-authored-by: Cool Developer <cool199966@outlook.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
(cherry picked from commit 0420895)

# Conflicts:
#	CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants