MCPcopy Create free account
hub / github.com/CPChain/chain / syncTransactions

Method syncTransactions

protocols/cpc/sync.go:52–66  ·  view source on GitHub ↗

syncTransactions starts sending all currently pending transactions to the given peer.

(p *peer)

Source from the content-addressed store, hash-verified

50
51// syncTransactions starts sending all currently pending transactions to the given peer.
52func (pm *ProtocolManager) syncTransactions(p *peer) {
53 var txs types.Transactions
54 pending, _ := pm.txpool.Pending()
55 log.Debug("syncTransactions pending", "len", len(pending), "peer", p.RemoteAddr().String())
56 for _, batch := range pending {
57 txs = append(txs, batch...)
58 }
59 if len(txs) == 0 {
60 return
61 }
62 select {
63 case pm.txsyncCh <- &txsync{p, txs}:
64 case <-pm.quitSync:
65 }
66}
67
68// txsyncLoop takes care of the initial transaction sync for each new
69// connection. When a new peer appears, we relay all currently pending

Callers 1

handlePeerMethod · 0.95

Calls 4

DebugMethod · 0.80
PendingMethod · 0.65
StringMethod · 0.45
RemoteAddrMethod · 0.45

Tested by

no test coverage detected