OSDN Git Service

Fix txSyncLoop null pointer error (#1150)
authoryahtoo <yahtoo.ma@gmail.com>
Fri, 20 Jul 2018 05:27:04 +0000 (13:27 +0800)
committerPaladz <yzhu101@uottawa.ca>
Fri, 20 Jul 2018 05:27:04 +0000 (13:27 +0800)
netsync/tx_keeper.go

index 1a8cc67..eefe2b8 100644 (file)
@@ -60,6 +60,7 @@ func (sm *SyncManager) txSyncLoop() {
                peer := sm.peers.getPeer(msg.peerID)
                if peer == nil {
                        delete(pending, msg.peerID)
+                       return
                }
 
                totalSize := uint64(0)
@@ -69,9 +70,10 @@ func (sm *SyncManager) txSyncLoop() {
                        totalSize += msg.txs[i].SerializedSize
                }
 
-               copy(msg.txs, msg.txs[len(sendTxs):])
-               if len(msg.txs) == 0 {
+               if len(msg.txs) == len(sendTxs) {
                        delete(pending, msg.peerID)
+               } else {
+                       msg.txs = msg.txs[len(sendTxs):]
                }
 
                // Send the pack in the background.