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

Cleanup Duplicate Transitive Constructor #2812

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,8 @@ func (m *manager) createAvalancheChain(
Params: consensusParams,
Consensus: snowmanConsensus,
}
snowmanEngine, err := smeng.New(snowmanEngineConfig)
var snowmanEngine common.Engine
snowmanEngine, err = smeng.New(snowmanEngineConfig)
if err != nil {
return nil, fmt.Errorf("error initializing snowman engine: %w", err)
}
Expand Down Expand Up @@ -1188,7 +1189,8 @@ func (m *manager) createSnowmanChain(
Consensus: consensus,
PartialSync: m.PartialSyncPrimaryNetwork && ctx.ChainID == constants.PlatformChainID,
}
engine, err := smeng.New(engineConfig)
var engine common.Engine
engine, err = smeng.New(engineConfig)
if err != nil {
return nil, fmt.Errorf("error initializing snowman engine: %w", err)
}
Expand Down
6 changes: 1 addition & 5 deletions snow/engine/snowman/transitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ const (

var _ common.Engine = (*Transitive)(nil)

func New(config Config) (common.Engine, error) {
return newTransitive(config)
}

func cachedBlockSize(_ ids.ID, blk snowman.Block) int {
return ids.IDLen + len(blk.Bytes()) + constants.PointerOverhead
}
Expand Down Expand Up @@ -106,7 +102,7 @@ type Transitive struct {
errs wrappers.Errs
}

func newTransitive(config Config) (*Transitive, error) {
func New(config Config) (*Transitive, error) {
config.Ctx.Log.Info("initializing consensus engine")

nonVerifiedCache, err := metercacher.New[ids.ID, snowman.Block](
Expand Down
20 changes: 10 additions & 10 deletions snow/engine/snowman/transitive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func setup(t *testing.T, engCfg Config) (ids.NodeID, validators.Manager, *common
}
}

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)

require.NoError(te.Start(context.Background(), 0))
Expand Down Expand Up @@ -377,7 +377,7 @@ func TestEngineMultipleQuery(t *testing.T) {
return gBlk, nil
}

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)

require.NoError(te.Start(context.Background(), 0))
Expand Down Expand Up @@ -796,7 +796,7 @@ func TestVoteCanceling(t *testing.T) {
return gBlk, nil
}

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)

require.NoError(te.Start(context.Background(), 0))
Expand Down Expand Up @@ -877,7 +877,7 @@ func TestEngineNoQuery(t *testing.T) {

engCfg.VM = vm

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)

require.NoError(te.Start(context.Background(), 0))
Expand Down Expand Up @@ -930,7 +930,7 @@ func TestEngineNoRepollQuery(t *testing.T) {

engCfg.VM = vm

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)

require.NoError(te.Start(context.Background(), 0))
Expand Down Expand Up @@ -1630,7 +1630,7 @@ func TestEngineAggressivePolling(t *testing.T) {
return gBlk, nil
}

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)

require.NoError(te.Start(context.Background(), 0))
Expand Down Expand Up @@ -1732,7 +1732,7 @@ func TestEngineDoubleChit(t *testing.T) {
return gBlk, nil
}

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)

require.NoError(te.Start(context.Background(), 0))
Expand Down Expand Up @@ -1831,7 +1831,7 @@ func TestEngineBuildBlockLimit(t *testing.T) {
return gBlk, nil
}

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)

require.NoError(te.Start(context.Background(), 0))
Expand Down Expand Up @@ -2861,7 +2861,7 @@ func TestEngineApplyAcceptedFrontierInQueryFailed(t *testing.T) {
return gBlk, nil
}

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)
require.NoError(te.Start(context.Background(), 0))

Expand Down Expand Up @@ -2969,7 +2969,7 @@ func TestEngineRepollsMisconfiguredSubnet(t *testing.T) {
return gBlk, nil
}

te, err := newTransitive(engCfg)
te, err := New(engCfg)
require.NoError(err)
require.NoError(te.Start(context.Background(), 0))

Expand Down
Loading