|
|
@ -47,7 +47,7 @@ type mempoolIDs struct { |
|
|
|
activeIDs map[uint16]struct{} // used to check if a given peerID key is used, the value doesn't matter
|
|
|
|
} |
|
|
|
|
|
|
|
// Reserve searches for the next unused ID and assignes it to the
|
|
|
|
// Reserve searches for the next unused ID and assigns it to the
|
|
|
|
// peer.
|
|
|
|
func (ids *mempoolIDs) ReserveForPeer(peer p2p.Peer) { |
|
|
|
ids.mtx.Lock() |
|
|
@ -114,6 +114,12 @@ func NewReactor(config *cfg.MempoolConfig, mempool *CListMempool) *Reactor { |
|
|
|
return memR |
|
|
|
} |
|
|
|
|
|
|
|
// InitPeer implements Reactor by creating a state for the peer.
|
|
|
|
func (memR *Reactor) InitPeer(peer p2p.Peer) p2p.Peer { |
|
|
|
memR.ids.ReserveForPeer(peer) |
|
|
|
return peer |
|
|
|
} |
|
|
|
|
|
|
|
// SetLogger sets the Logger on the reactor and the underlying mempool.
|
|
|
|
func (memR *Reactor) SetLogger(l log.Logger) { |
|
|
|
memR.Logger = l |
|
|
@ -142,7 +148,6 @@ func (memR *Reactor) GetChannels() []*p2p.ChannelDescriptor { |
|
|
|
// AddPeer implements Reactor.
|
|
|
|
// It starts a broadcast routine ensuring all txs are forwarded to the given peer.
|
|
|
|
func (memR *Reactor) AddPeer(peer p2p.Peer) { |
|
|
|
memR.ids.ReserveForPeer(peer) |
|
|
|
go memR.broadcastTxRoutine(peer) |
|
|
|
} |
|
|
|
|
|
|
|