Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions node/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,3 +925,28 @@ func (c *Consensus) verifyAndClassifyRequest(request *protos.Request) (*protos.R

return configRequest, nil
}

// PruneRequestsFromMemPool removes from the mempool the requests included in the given block.
// It is called by the BFT synchronizer.
func (c *Consensus) PruneRequestsFromMemPool(consenterBlock *common.Block) {
if consenterBlock.GetHeader().GetNumber() == 0 {
return // genesis block doesn't include any request
}

// TODO it make sense to have ConsenterBlockToDecision return the error
decision := ConsenterBlockToDecision(consenterBlock)
if decision == nil {
c.Logger.Panicf("Failed parsing block we pulled with BFT Synchronizer")
}

// Every request, including config requests, is included in the proposal's payload as a batch of requests,
// so we can just deserialize the payload to get all the included requests and remove them from the mempool.
var batch arma_types.BatchedRequests
if err := batch.Deserialize(decision.Proposal.Payload); err != nil {
c.Logger.Panicf("Failed deserializing proposal payload: %v", err)
}

for _, req := range batch {
c.BFT.Pool.RemoveRequest(c.RequestID(req))
}
}
10 changes: 5 additions & 5 deletions node/consensus/consensus_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ func CreateConsensus(conf *node_config.ConsenterNodeConfig, net NetStopper, last
ClientPrivateKey: conf.TLSPrivateKeyFile,
ReplicationPolicy: "",
},
c, // implements synchronizer.BFTConfigGetter,
ConsenterBlockToDecision, // func(block *cb.Block) *types.Decision // TODO look at the assembler
nil, // pruneCommittedRequests func(block *cb.Block),
nil, // updateRuntimeConfig func(block *cb.Block) types.Reconfig,
nil, // support ConsenterSupport,
c, // implements synchronizer.BFTConfigGetter,
ConsenterBlockToDecision, // func(block *cb.Block) *types.Decision // TODO look at the assembler
c.PruneRequestsFromMemPool, // pruneCommittedRequests func(block *cb.Block),
nil, // updateRuntimeConfig func(block *cb.Block) types.Reconfig,
nil, // support ConsenterSupport,
factory.GetDefault(),
nil, // c.ClusterService.Dialer)
)
Expand Down
Loading