Skip to content

Commit 3547120

Browse files
committed
go/worker/common/committee: Simplify cross node lock
1 parent f42d9bd commit 3547120

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

go/worker/common/committee/node.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,11 @@ type Node struct {
183183

184184
// Mutable and shared between nodes' workers.
185185
// Guarded by .CrossNode.
186-
CrossNode sync.Mutex
187-
CurrentBlock *block.Block
188-
CurrentBlockHeight int64
189-
CurrentConsensusBlock *consensus.LightBlock
190-
CurrentDescriptor *registry.Runtime
191-
CurrentEpoch beacon.EpochTime
186+
CrossNode sync.Mutex
187+
CurrentBlock *block.Block
188+
CurrentBlockHeight int64
189+
CurrentDescriptor *registry.Runtime
190+
CurrentEpoch beacon.EpochTime
192191

193192
logger *logging.Logger
194193
}
@@ -470,8 +469,6 @@ func (n *Node) handleNewBlock(blk *block.Block, height int64) {
470469

471470
processedBlockCount.With(n.getMetricLabels()).Inc()
472471

473-
header := blk.Header
474-
475472
// The first received block will be treated an epoch transition (if valid).
476473
// This will refresh the committee on the first block,
477474
// instead of waiting for the next epoch transition to occur.
@@ -492,10 +489,9 @@ func (n *Node) handleNewBlock(blk *block.Block, height int64) {
492489
// Update the current block.
493490
n.CurrentBlock = blk
494491
n.CurrentBlockHeight = height
495-
n.CurrentConsensusBlock = consensusBlk
496492

497493
// Update active descriptor on epoch transitions.
498-
if firstBlockReceived || header.HeaderType == block.EpochTransition || header.HeaderType == block.Suspended {
494+
if firstBlockReceived || blk.Header.HeaderType == block.EpochTransition || blk.Header.HeaderType == block.Suspended {
499495
var rs *roothash.RuntimeState
500496
rs, err = n.Consensus.RootHash().GetRuntimeState(n.ctx, &roothash.RuntimeRequest{
501497
RuntimeID: n.Runtime.ID(),
@@ -530,7 +526,7 @@ func (n *Node) handleNewBlock(blk *block.Block, height int64) {
530526
}
531527

532528
// Perform actions based on block type.
533-
switch header.HeaderType {
529+
switch blk.Header.HeaderType {
534530
case block.Normal:
535531
if firstBlockReceived {
536532
n.logger.Warn("forcing an epoch transition on first received block")
@@ -560,7 +556,7 @@ func (n *Node) handleNewBlock(blk *block.Block, height int64) {
560556

561557
bi := &runtime.BlockInfo{
562558
RuntimeBlock: n.CurrentBlock,
563-
ConsensusBlock: n.CurrentConsensusBlock,
559+
ConsensusBlock: consensusBlk,
564560
Epoch: n.CurrentEpoch,
565561
ActiveDescriptor: n.CurrentDescriptor,
566562
}

0 commit comments

Comments
 (0)