mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-18 23:51:21 +00:00
rewrite broadcastTxRoutine to use channels
https://play.golang.org/p/gN21yO9IRs3 ``` func waitWithCancel(f func() *clist.CElement, ctx context.Context) *clist.CElement { el := make(chan *clist.CElement, 1) select { case el <- f(): ``` will just run f() blockingly, so this doesn't change much in terms of behavior.
This commit is contained in:
@ -18,6 +18,7 @@ import (
|
||||
// Peer is an interface representing a peer connected on a reactor.
|
||||
type Peer interface {
|
||||
cmn.Service
|
||||
QuitChan() <-chan struct{}
|
||||
|
||||
ID() ID // peer's cryptographic ID
|
||||
IsOutbound() bool // did we dial the peer
|
||||
@ -331,6 +332,11 @@ func (p *peer) String() string {
|
||||
return fmt.Sprintf("Peer{%v %v in}", p.mconn, p.ID())
|
||||
}
|
||||
|
||||
// QuitChan returns a channel, which will be closed once peer is stopped.
|
||||
func (p *peer) QuitChan() <-chan struct{} {
|
||||
return p.Quit
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// helper funcs
|
||||
|
||||
|
Reference in New Issue
Block a user