diff --git a/beacon-chain/stategen/replay.go b/beacon-chain/stategen/replay.go index c0fc83af916..b9fb8c3f1e0 100644 --- a/beacon-chain/stategen/replay.go +++ b/beacon-chain/stategen/replay.go @@ -11,8 +11,8 @@ import ( "github.com/prysmaticlabs/prysm/shared/bytesutil" ) -// This replays the input blocks on the input state until the target slot is reached. -func (s *State) replayBlocks(ctx context.Context, state *state.BeaconState, signed []*ethpb.SignedBeaconBlock, targetSlot uint64) (*state.BeaconState, error) { +// ReplayBlocks replays the input blocks on the input state until the target slot is reached. +func (s *State) ReplayBlocks(ctx context.Context, state *state.BeaconState, signed []*ethpb.SignedBeaconBlock, targetSlot uint64) (*state.BeaconState, error) { var err error // The input block list is sorted in decreasing slots order. if len(signed) > 0 { @@ -33,9 +33,9 @@ func (s *State) replayBlocks(ctx context.Context, state *state.BeaconState, sign return state, nil } -// This loads the blocks between start slot and end slot by recursively fetching from end block root. +// LoadBlocks loads the blocks between start slot and end slot by recursively fetching from end block root. // The Blocks are returned in slot-descending order. -func (s *State) loadBlocks(ctx context.Context, startSlot uint64, endSlot uint64, endBlockRoot [32]byte) ([]*ethpb.SignedBeaconBlock, error) { +func (s *State) LoadBlocks(ctx context.Context, startSlot uint64, endSlot uint64, endBlockRoot [32]byte) ([]*ethpb.SignedBeaconBlock, error) { filter := filters.NewFilter().SetStartSlot(startSlot).SetEndSlot(endSlot) blocks, err := s.beaconDB.Blocks(ctx, filter) if err != nil { diff --git a/beacon-chain/stategen/replay_test.go b/beacon-chain/stategen/replay_test.go index 692d807b461..449adfcc00f 100644 --- a/beacon-chain/stategen/replay_test.go +++ b/beacon-chain/stategen/replay_test.go @@ -43,7 +43,7 @@ func TestReplayBlocks_AllSkipSlots(t *testing.T) { service := New(db) targetSlot := params.BeaconConfig().SlotsPerEpoch - 1 - newState, err := service.replayBlocks(context.Background(), beaconState, []*ethpb.SignedBeaconBlock{}, targetSlot) + newState, err := service.ReplayBlocks(context.Background(), beaconState, []*ethpb.SignedBeaconBlock{}, targetSlot) if err != nil { t.Fatal(err) } @@ -79,7 +79,7 @@ func TestReplayBlocks_SameSlot(t *testing.T) { service := New(db) targetSlot := beaconState.Slot() - newState, err := service.replayBlocks(context.Background(), beaconState, []*ethpb.SignedBeaconBlock{}, targetSlot) + newState, err := service.ReplayBlocks(context.Background(), beaconState, []*ethpb.SignedBeaconBlock{}, targetSlot) if err != nil { t.Fatal(err) } @@ -102,7 +102,7 @@ func TestLoadBlocks_FirstBranch(t *testing.T) { t.Fatal(err) } - filteredBlocks, err := s.loadBlocks(ctx, 0, 8, roots[len(roots)-1]) + filteredBlocks, err := s.LoadBlocks(ctx, 0, 8, roots[len(roots)-1]) if err != nil { t.Fatal(err) } @@ -133,7 +133,7 @@ func TestLoadBlocks_SecondBranch(t *testing.T) { t.Fatal(err) } - filteredBlocks, err := s.loadBlocks(ctx, 0, 5, roots[5]) + filteredBlocks, err := s.LoadBlocks(ctx, 0, 5, roots[5]) if err != nil { t.Fatal(err) } @@ -162,7 +162,7 @@ func TestLoadBlocks_ThirdBranch(t *testing.T) { t.Fatal(err) } - filteredBlocks, err := s.loadBlocks(ctx, 0, 7, roots[7]) + filteredBlocks, err := s.LoadBlocks(ctx, 0, 7, roots[7]) if err != nil { t.Fatal(err) } @@ -193,7 +193,7 @@ func TestLoadBlocks_SameSlots(t *testing.T) { t.Fatal(err) } - filteredBlocks, err := s.loadBlocks(ctx, 0, 3, roots[6]) + filteredBlocks, err := s.LoadBlocks(ctx, 0, 3, roots[6]) if err != nil { t.Fatal(err) } @@ -222,7 +222,7 @@ func TestLoadBlocks_SameEndSlots(t *testing.T) { t.Fatal(err) } - filteredBlocks, err := s.loadBlocks(ctx, 0, 2, roots[2]) + filteredBlocks, err := s.LoadBlocks(ctx, 0, 2, roots[2]) if err != nil { t.Fatal(err) } @@ -250,7 +250,7 @@ func TestLoadBlocks_SameEndSlotsWith2blocks(t *testing.T) { t.Fatal(err) } - filteredBlocks, err := s.loadBlocks(ctx, 0, 2, roots[1]) + filteredBlocks, err := s.LoadBlocks(ctx, 0, 2, roots[1]) if err != nil { t.Fatal(err) } @@ -276,7 +276,7 @@ func TestLoadBlocks_BadStart(t *testing.T) { if err != nil { t.Fatal(err) } - _, err = s.loadBlocks(ctx, 0, 5, roots[8]) + _, err = s.LoadBlocks(ctx, 0, 5, roots[8]) if err.Error() != "end block roots don't match" { t.Error("Did not get wanted error") }