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

Remove snowball.Initialize and snowball.Factory #2104

Merged
merged 7 commits into from
Sep 27, 2023

Conversation

danlaine
Copy link

Why this should be merged

Down with Initialize methods.

How this works

Remove snowball.Initialize and snowball.Factory.

How this was tested

Existing UT.

@danlaine danlaine added consensus This involves consensus cleanup Code quality improvement labels Sep 27, 2023
@danlaine danlaine self-assigned this Sep 27, 2023
snow/consensus/snowball/network_test.go Outdated Show resolved Hide resolved
@StephenButtolph StephenButtolph added this to the v1.10.12 milestone Sep 27, 2023
f := &Flat{
params: params,
}
f.nnarySnowball.Initialize(params.BetaVirtuous, params.BetaRogue, choice)
Copy link
Contributor

Choose a reason for hiding this comment

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

q: why not dropping this Initialize as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

this is being done in a followup

@StephenButtolph StephenButtolph added this pull request to the merge queue Sep 27, 2023
Copy link
Contributor

@joshua-kim joshua-kim left a comment

Choose a reason for hiding this comment

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

Want to see if we can get rid of the function passing in the consensus test

@@ -16,16 +16,18 @@ var (
_ Consensus = (*Byzantine)(nil)
)

func NewByzantine(_ Parameters, choice ids.ID) Consensus {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get rid of the unused parameter here? Looks like we only had it previous for interface signature

@@ -26,34 +28,44 @@ func (n *Network) Initialize(params Parameters, numColors int) {
}
}

func (n *Network) AddNode(sb Consensus) {
func (n *Network) AddNode(newConsensusFunc newConsensusFunc) Consensus {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for the caller to just give us an initialized Consensus instance instead of this function result?

@@ -28,12 +28,12 @@ func TestSnowballOptimized(t *testing.T) {

sampler.Seed(seed)
for i := 0; i < numNodes; i++ {
nBitwise.AddNode(&Tree{})
nBitwise.AddNode(NewTree)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if it's possible for us to pass parameters into NewTree and NewFlat so we can avoid passing in this function directly

Merged via the queue into dev with commit 2be4e3e Sep 27, 2023
15 checks passed
@StephenButtolph StephenButtolph deleted the consensus-remove-initialize branch September 27, 2023 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement consensus This involves consensus
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants