github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/forkchoice/interfaces.go (about) 1 package forkchoice 2 3 import ( 4 "context" 5 6 types "github.com/prysmaticlabs/eth2-types" 7 "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray" 8 ) 9 10 // ForkChoicer represents the full fork choice interface composed of all of the sub-interfaces. 11 type ForkChoicer interface { 12 HeadRetriever // to compute head. 13 BlockProcessor // to track new block for fork choice. 14 AttestationProcessor // to track new attestation for fork choice. 15 Pruner // to clean old data for fork choice. 16 Getter // to retrieve fork choice information. 17 } 18 19 // HeadRetriever retrieves head root of the current chain. 20 type HeadRetriever interface { 21 Head(context.Context, types.Epoch, [32]byte, []uint64, types.Epoch) ([32]byte, error) 22 } 23 24 // BlockProcessor processes the block that's used for accounting fork choice. 25 type BlockProcessor interface { 26 ProcessBlock(context.Context, types.Slot, [32]byte, [32]byte, [32]byte, types.Epoch, types.Epoch) error 27 } 28 29 // AttestationProcessor processes the attestation that's used for accounting fork choice. 30 type AttestationProcessor interface { 31 ProcessAttestation(context.Context, []uint64, [32]byte, types.Epoch) 32 } 33 34 // Pruner prunes the fork choice upon new finalization. This is used to keep fork choice sane. 35 type Pruner interface { 36 Prune(context.Context, [32]byte) error 37 } 38 39 // Getter returns fork choice related information. 40 type Getter interface { 41 Nodes() []*protoarray.Node 42 Node([32]byte) *protoarray.Node 43 HasNode([32]byte) bool 44 Store() *protoarray.Store 45 HasParent(root [32]byte) bool 46 AncestorRoot(ctx context.Context, root [32]byte, slot types.Slot) ([]byte, error) 47 IsCanonical(root [32]byte) bool 48 }