Skip to content

Commit

Permalink
Block proposing moved from Node to Consensus. (#4698)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frozen authored Jun 25, 2024
1 parent d748647 commit d6da9ff
Show file tree
Hide file tree
Showing 12 changed files with 561 additions and 518 deletions.
20 changes: 9 additions & 11 deletions api/service/blockproposal/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ import (

// Service is a block proposal service.
type Service struct {
stopChan chan struct{}
stoppedChan chan struct{}
c *consensus.Consensus
messageChan chan *msg_pb.Message
waitForConsensusReady func(c *consensus.Consensus, stopChan chan struct{}, stoppedChan chan struct{})
stopChan chan struct{}
stoppedChan chan struct{}
c *consensus.Consensus
messageChan chan *msg_pb.Message
}

// New returns a block proposal service.
func New(c *consensus.Consensus, waitForConsensusReady func(c *consensus.Consensus, stopChan chan struct{}, stoppedChan chan struct{})) *Service {
func New(c *consensus.Consensus) *Service {
return &Service{
c: c,
waitForConsensusReady: waitForConsensusReady,
stopChan: make(chan struct{}),
stoppedChan: make(chan struct{}),
c: c,
stopChan: make(chan struct{}),
stoppedChan: make(chan struct{}),
}
}

Expand All @@ -32,7 +30,7 @@ func (s *Service) Start() error {
}

func (s *Service) run() {
s.waitForConsensusReady(s.c, s.stopChan, s.stoppedChan)
s.c.WaitForConsensusReadyV2(s.stopChan, s.stoppedChan)
}

// Stop stops block proposal service.
Expand Down
6 changes: 4 additions & 2 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type Consensus struct {

multiSigBitmap *bls_cosi.Mask // Bitmap for parsing multisig bitmap from validators

pendingCXReceipts map[utils.CXKey]*types.CXReceiptsProof // All the receipts received but not yet processed for Consensus
// Registry for services.
registry *registry.Registry
// Minimal number of peers in the shard
Expand Down Expand Up @@ -296,8 +297,9 @@ func New(
host: host,
msgSender: NewMessageSender(host),
// FBFT timeout
consensusTimeout: createTimeout(),
dHelper: downloadAsync{},
consensusTimeout: createTimeout(),
dHelper: downloadAsync{},
pendingCXReceipts: make(map[utils.CXKey]*types.CXReceiptsProof), // All the receipts received but not yet processed for Consensus
}

if multiBLSPriKey != nil {
Expand Down
Loading

0 comments on commit d6da9ff

Please sign in to comment.