@@ -476,7 +476,7 @@ type Peer struct {
476
476
outputQueue chan outMsg
477
477
sendQueue chan outMsg
478
478
sendDoneQueue chan struct {}
479
- outputInvChan chan * wire.InvVect
479
+ outputInvChan chan [] * wire.InvVect
480
480
inQuit chan struct {}
481
481
queueQuit chan struct {}
482
482
outQuit chan struct {}
@@ -1609,23 +1609,27 @@ out:
1609
1609
val := pendingMsgs .Remove (next )
1610
1610
p .sendQueue <- val .(outMsg )
1611
1611
1612
- case iv := <- p .outputInvChan :
1613
- // No handshake? They'll find out soon enough.
1614
- if p .VersionKnown () {
1615
- // If this is a new block, then we'll blast it
1616
- // out immediately, sipping the inv trickle
1617
- // queue.
1618
- if iv .Type == wire .InvTypeBlock ||
1619
- iv .Type == wire .InvTypeUtreexoBlock ||
1620
- iv .Type == wire .InvTypeWitnessBlock ||
1621
- iv .Type == wire .InvTypeWitnessUtreexoBlock {
1622
-
1623
- invMsg := wire .NewMsgInvSizeHint (1 )
1624
- invMsg .AddInvVect (iv )
1625
- waiting = queuePacket (outMsg {msg : invMsg },
1626
- pendingMsgs , waiting )
1627
- } else {
1628
- invSendQueue .PushBack (iv )
1612
+ case ivs := <- p .outputInvChan :
1613
+ for i := range ivs {
1614
+ iv := ivs [i ]
1615
+
1616
+ // No handshake? They'll find out soon enough.
1617
+ if p .VersionKnown () {
1618
+ // If this is a new block, then we'll blast it
1619
+ // out immediately, sipping the inv trickle
1620
+ // queue.
1621
+ if iv .Type == wire .InvTypeBlock ||
1622
+ iv .Type == wire .InvTypeUtreexoBlock ||
1623
+ iv .Type == wire .InvTypeWitnessBlock ||
1624
+ iv .Type == wire .InvTypeWitnessUtreexoBlock {
1625
+
1626
+ invMsg := wire .NewMsgInvSizeHint (1 )
1627
+ invMsg .AddInvVect (iv )
1628
+ waiting = queuePacket (outMsg {msg : invMsg },
1629
+ pendingMsgs , waiting )
1630
+ } else {
1631
+ invSendQueue .PushBack (iv )
1632
+ }
1629
1633
}
1630
1634
}
1631
1635
@@ -1849,11 +1853,13 @@ func (p *Peer) QueueMessageWithEncoding(msg wire.Message, doneChan chan<- struct
1849
1853
// Inventory that the peer is already known to have is ignored.
1850
1854
//
1851
1855
// This function is safe for concurrent access.
1852
- func (p * Peer ) QueueInventory (invVect * wire.InvVect ) {
1853
- // Don't add the inventory to the send queue if the peer is already
1854
- // known to have it.
1855
- if p .knownInventory .Contains (invVect ) {
1856
- return
1856
+ func (p * Peer ) QueueInventory (invVects []* wire.InvVect ) {
1857
+ for i := 0 ; i < len (invVects ); i ++ {
1858
+ // Don't add the inventory to the send queue if the peer is already
1859
+ // known to have it.
1860
+ if p .knownInventory .Contains (invVects [i ]) {
1861
+ invVects = append (invVects [:i ], invVects [i + 1 :]... )
1862
+ }
1857
1863
}
1858
1864
1859
1865
// Avoid risk of deadlock if goroutine already exited. The goroutine
@@ -1863,7 +1869,7 @@ func (p *Peer) QueueInventory(invVect *wire.InvVect) {
1863
1869
return
1864
1870
}
1865
1871
1866
- p .outputInvChan <- invVect
1872
+ p .outputInvChan <- invVects
1867
1873
}
1868
1874
1869
1875
// Connected returns whether or not the peer is currently connected.
@@ -2261,7 +2267,7 @@ func newPeerBase(origCfg *Config, inbound bool) *Peer {
2261
2267
outputQueue : make (chan outMsg , outputBufferSize ),
2262
2268
sendQueue : make (chan outMsg , 1 ), // nonblocking sync
2263
2269
sendDoneQueue : make (chan struct {}, 1 ), // nonblocking sync
2264
- outputInvChan : make (chan * wire.InvVect , outputBufferSize ),
2270
+ outputInvChan : make (chan [] * wire.InvVect , outputBufferSize ),
2265
2271
inQuit : make (chan struct {}),
2266
2272
queueQuit : make (chan struct {}),
2267
2273
outQuit : make (chan struct {}),
0 commit comments