Skip to content

Commit

Permalink
Fix for Raft stability (#886)
Browse files Browse the repository at this point in the history
* increased the size of blockProposal and chainHeadEvent channels. Changed the call to mintNewBlock from a go routine to a function call. Changes done to improve performance of Raft in high load envs
  • Loading branch information
vsmk98 authored and jpmsam committed Nov 21, 2019
1 parent f809144 commit 5cb92ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,3 +1323,8 @@ func checkAccount(fromAcct common.Address, toAcct *common.Address) error {
}
return nil
}

// helper function to return chainHeadChannel size
func GetChainHeadChannleSize() int {
return chainHeadChanSize
}
2 changes: 1 addition & 1 deletion raft/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func NewProtocolManager(raftId uint16, raftPort uint16, blockchain *core.BlockCh
joinExisting: joinExisting,
blockchain: blockchain,
eventMux: mux,
blockProposalC: make(chan *types.Block),
blockProposalC: make(chan *types.Block, 10),
confChangeProposalC: make(chan raftpb.ConfChange),
httpstopc: make(chan struct{}),
httpdonec: make(chan struct{}),
Expand Down
4 changes: 2 additions & 2 deletions raft/minter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func newMinter(config *params.ChainConfig, eth *RaftService, blockTime time.Dura
speculativeChain: newSpeculativeChain(),

invalidRaftOrderingChan: make(chan InvalidRaftOrdering, 1),
chainHeadChan: make(chan core.ChainHeadEvent, 1),
chainHeadChan: make(chan core.ChainHeadEvent, core.GetChainHeadChannleSize()),
txPreChan: make(chan core.NewTxsEvent, 4096),
}

Expand Down Expand Up @@ -213,7 +213,7 @@ func throttle(rate time.Duration, f func()) func() {

for range ticker.C {
<-request.Out()
go f()
f()
}
}()

Expand Down

0 comments on commit 5cb92ce

Please sign in to comment.