X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=netsync%2Fchainmgr%2Ftx_keeper.go;h=6c6f5f9e3861519c084d8f411198a629a36635e5;hp=50714031dbf04e7929256541b640b98d189b9c1d;hb=93dd7ceb9c426fa99362a81bf7e137d410d4ef92;hpb=e0bb6e8ab045e0449a652a9b924b815f59c34e63 diff --git a/netsync/chainmgr/tx_keeper.go b/netsync/chainmgr/tx_keeper.go index 50714031..6c6f5f9e 100644 --- a/netsync/chainmgr/tx_keeper.go +++ b/netsync/chainmgr/tx_keeper.go @@ -21,8 +21,8 @@ type txSyncMsg struct { txs []*types.Tx } -func (m *Manager) syncTransactions(peerID string) { - pending := m.txPool.GetTransactions() +func (m *Manager) syncMempool(peerID string) { + pending := m.mempool.GetTransactions() if len(pending) == 0 { return } @@ -34,7 +34,7 @@ func (m *Manager) syncTransactions(peerID string) { m.txSyncCh <- &txSyncMsg{peerID, txs} } -func (m *Manager) txBroadcastLoop() { +func (m *Manager) broadcastTxsLoop() { for { select { case obj, ok := <-m.txMsgSub.Chan(): @@ -55,17 +55,17 @@ func (m *Manager) txBroadcastLoop() { continue } } - case <-m.quitSync: + case <-m.quit: return } } } -// txSyncLoop takes care of the initial transaction sync for each new +// syncMempoolLoop takes care of the initial transaction sync for each new // connection. When a new peer appears, we relay all currently pending // transactions. In order to minimise egress bandwidth usage, we send // the transactions in small packs to one peer at a time. -func (m *Manager) txSyncLoop() { +func (m *Manager) syncMempoolLoop() { pending := make(map[string]*txSyncMsg) sending := false // whether a send is active done := make(chan error, 1) // result of the send @@ -130,7 +130,6 @@ func (m *Manager) txSyncLoop() { if !sending { send(msg) } - case err := <-done: sending = false if err != nil { @@ -140,6 +139,8 @@ func (m *Manager) txSyncLoop() { if s := pick(); s != nil { send(s) } + case <-m.quit: + return } } }