Skip to content

Commit

Permalink
nit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaidashenko committed Feb 28, 2024
1 parent 83ea5d1 commit 2d5ae65
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion common/headtracker/head_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (ht *HeadTracker[HTH, S, ID, BLOCK_HASH]) handleInitialHead(ctx context.Con
return fmt.Errorf("failed to calculate latest finalized head: %w", err)
}

latestChain, err := ht.headSaver.Load(ctx, latestFinalized)
latestChain, err := ht.headSaver.Load(ctx, latestFinalized.BlockNumber())
if err != nil {
return fmt.Errorf("failed to initialzed headSaver: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion common/types/head_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type HeadSaver[H Head[BLOCK_HASH], BLOCK_HASH Hashable] interface {
// this number in case of reboot.
Save(ctx context.Context, head H) error
// Load loads latest heads up to latestFinalized - historyDepth, returns the latest chain.
Load(ctx context.Context, latestFinalized H) (H, error)
Load(ctx context.Context, latestFinalized int64) (H, error)
// LatestChain returns the block header with the highest number that has been seen, or nil.
LatestChain() H
// Chain returns a head for the specified hash, or nil.
Expand Down
6 changes: 3 additions & 3 deletions core/chains/evm/headtracker/head_saver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func (hs *headSaver) Save(ctx context.Context, head *evmtypes.Head) error {
return nil
}

func (hs *headSaver) Load(ctx context.Context, latestFinalized *evmtypes.Head) (chain *evmtypes.Head, err error) {
minBlockNumber := hs.calculateMinBlockToKeep(latestFinalized.BlockNumber())
func (hs *headSaver) Load(ctx context.Context, latestFinalized int64) (chain *evmtypes.Head, err error) {
minBlockNumber := hs.calculateMinBlockToKeep(latestFinalized)
heads, err := hs.orm.LatestHeads(ctx, minBlockNumber)
if err != nil {
return nil, err
Expand Down Expand Up @@ -91,7 +91,7 @@ var NullSaver httypes.HeadSaver = &nullSaver{}
type nullSaver struct{}

func (*nullSaver) Save(ctx context.Context, head *evmtypes.Head) error { return nil }
func (*nullSaver) Load(ctx context.Context, latestFinalized *evmtypes.Head) (*evmtypes.Head, error) {
func (*nullSaver) Load(ctx context.Context, latestFinalized int64) (*evmtypes.Head, error) {
return nil, nil
}
func (*nullSaver) LatestHeadFromDB(ctx context.Context) (*evmtypes.Head, error) { return nil, nil }
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/headtracker/head_saver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestHeadSaver_Load(t *testing.T) {
}

// load all from [h5-historyDepth, h5]
latestHead, err := saver.Load(testutils.Context(t), h5)
latestHead, err := saver.Load(testutils.Context(t), h5.BlockNumber())
require.NoError(t, err)
// verify latest head loaded from db
verifyLatestHead(latestHead)
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/headtracker/head_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestHeadTracker_MarkFinalized_MarksAndTrimsTable(t *testing.T) {
assert.Nil(t, orm.IdempotentInsertHead(testutils.Context(t), latest))

ht := createHeadTracker(t, ethClient, config.EVM(), config.EVM().HeadTracker(), orm)
_, err := ht.headSaver.Load(testutils.Context(t), latest)
_, err := ht.headSaver.Load(testutils.Context(t), latest.Number)
require.NoError(t, err)
require.NoError(t, ht.headSaver.MarkFinalized(testutils.Context(t), latest))
assert.Equal(t, big.NewInt(201), ht.headSaver.LatestChain().ToInt())
Expand Down Expand Up @@ -831,7 +831,7 @@ func TestHeadTracker_Backfill(t *testing.T) {
ethClient := evmtest.NewEthClientMock(t)
ethClient.On("ConfiguredChainID", mock.Anything).Return(evmtest.MustGetDefaultChainID(t, cfg.EVMConfigs()), nil)
ht := createHeadTracker(t, ethClient, evmcfg.EVM(), evmcfg.EVM().HeadTracker(), orm)
_, err := ht.headSaver.Load(testutils.Context(t), cltest.Head(0))
_, err := ht.headSaver.Load(testutils.Context(t), 0)
require.NoError(t, err)
return ht
}
Expand Down

0 comments on commit 2d5ae65

Please sign in to comment.