mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
lock in receive block
This commit is contained in:
@@ -39,6 +39,8 @@ type BlockProcessor interface {
|
||||
// 4. Process and cleanup any block operations, such as attestations and deposits, which would need to be
|
||||
// either included or flushed from the beacon node's runtime.
|
||||
func (c *ChainService) ReceiveBlock(ctx context.Context, block *pb.BeaconBlock) (*pb.BeaconState, error) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
ctx, span := trace.StartSpan(ctx, "beacon-chain.blockchain.ReceiveBlock")
|
||||
defer span.End()
|
||||
beaconState, err := c.beaconDB.HistoricalStateFromSlot(ctx, block.Slot-1)
|
||||
|
||||
@@ -122,6 +122,8 @@ func (c *ChainService) ApplyForkChoiceRule(
|
||||
block *pb.BeaconBlock,
|
||||
postState *pb.BeaconState,
|
||||
) error {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
ctx, span := trace.StartSpan(ctx, "beacon-chain.blockchain.ApplyForkChoiceRule")
|
||||
defer span.End()
|
||||
log.Info("Applying LMD-GHOST Fork Choice Rule")
|
||||
|
||||
@@ -6,6 +6,7 @@ package blockchain
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/attestation"
|
||||
@@ -44,6 +45,7 @@ type ChainService struct {
|
||||
finalizedEpoch uint64
|
||||
stateInitializedFeed *event.Feed
|
||||
p2p p2p.Broadcaster
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
// Config options for the service.
|
||||
|
||||
Reference in New Issue
Block a user