Clean up state types (#11916)

* Clean up state types

* rename package
This commit is contained in:
Radosław Kapka
2023-01-26 15:40:12 +01:00
committed by GitHub
parent a296a0c783
commit 77d3ccb9ad
555 changed files with 4696 additions and 4958 deletions

View File

@@ -14,7 +14,7 @@ import (
"github.com/prysmaticlabs/prysm/v3/config/params"
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v3/crypto/rand"
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v3/encoding/ssz/equality"
@@ -210,7 +210,7 @@ func (s *Service) processPendingBlocks(ctx context.Context) error {
func (s *Service) checkIfBlockIsBad(
ctx context.Context,
span *trace.Span,
slot types.Slot,
slot primitives.Slot,
b interfaces.SignedBeaconBlock,
blkRoot [32]byte,
) (keepProcessing bool, err error) {
@@ -280,13 +280,13 @@ func (s *Service) sendBatchRootRequest(ctx context.Context, roots [][32]byte, ra
return nil
}
func (s *Service) sortedPendingSlots() []types.Slot {
func (s *Service) sortedPendingSlots() []primitives.Slot {
s.pendingQueueLock.RLock()
defer s.pendingQueueLock.RUnlock()
items := s.slotToPendingBlocks.Items()
ss := make([]types.Slot, 0, len(items))
ss := make([]primitives.Slot, 0, len(items))
for k := range items {
slot := cacheKeyToSlot(k)
ss = append(ss, slot)
@@ -353,7 +353,7 @@ func (s *Service) clearPendingSlots() {
// Delete block from the list from the pending queue using the slot as key.
// Note: this helper is not thread safe.
func (s *Service) deleteBlockFromPendingQueue(slot types.Slot, b interfaces.SignedBeaconBlock, r [32]byte) error {
func (s *Service) deleteBlockFromPendingQueue(slot primitives.Slot, b interfaces.SignedBeaconBlock, r [32]byte) error {
mutexasserts.AssertRWMutexLocked(&s.pendingQueueLock)
blks := s.pendingBlocksInCache(slot)
@@ -398,7 +398,7 @@ func (s *Service) deleteBlockFromPendingQueue(slot types.Slot, b interfaces.Sign
// Insert block to the list in the pending queue using the slot as key.
// Note: this helper is not thread safe.
func (s *Service) insertBlockToPendingQueue(_ types.Slot, b interfaces.SignedBeaconBlock, r [32]byte) error {
func (s *Service) insertBlockToPendingQueue(_ primitives.Slot, b interfaces.SignedBeaconBlock, r [32]byte) error {
mutexasserts.AssertRWMutexLocked(&s.pendingQueueLock)
if s.seenPendingBlocks[r] {
@@ -414,7 +414,7 @@ func (s *Service) insertBlockToPendingQueue(_ types.Slot, b interfaces.SignedBea
}
// This returns signed beacon blocks given input key from slotToPendingBlocks.
func (s *Service) pendingBlocksInCache(slot types.Slot) []interfaces.SignedBeaconBlock {
func (s *Service) pendingBlocksInCache(slot primitives.Slot) []interfaces.SignedBeaconBlock {
k := slotToCacheKey(slot)
value, ok := s.slotToPendingBlocks.Get(k)
if !ok {
@@ -452,13 +452,13 @@ func (s *Service) isGenesisTimeSet() bool {
}
// This converts input string to slot.
func cacheKeyToSlot(s string) types.Slot {
func cacheKeyToSlot(s string) primitives.Slot {
b := []byte(s)
return bytesutil.BytesToSlotBigEndian(b)
}
// This converts input slot to a key to be used for slotToPendingBlocks cache.
func slotToCacheKey(s types.Slot) string {
func slotToCacheKey(s primitives.Slot) string {
b := bytesutil.SlotToBytesBigEndian(s)
return string(b)
}