File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -181,8 +181,10 @@ pub enum TimedMessage {
181181 CFilters ,
182182 /// Bitcoin blocks
183183 Block ,
184- /// Potential peers on the network
184+ /// Potential peers on the network, either `addr` or `addrv2`.
185185 Addr ,
186+ /// Transaction announcements by `Tx`, `WTx`, or `WitnessTransaction`.
187+ TransactionAnnouncement ,
186188}
187189
188190#[ derive( Debug , Clone ) ]
@@ -196,6 +198,7 @@ impl TimedMessages {
196198 TimedMessage :: CFilters ,
197199 TimedMessage :: Block ,
198200 TimedMessage :: Addr ,
201+ TimedMessage :: TransactionAnnouncement ,
199202 ] {
200203 map. insert ( key, MessageRate :: new ( ) ) ;
201204 }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ use bitcoin::{
1616} ;
1717use p2p:: {
1818 message:: { NetworkMessage , RawNetworkMessage , V1MessageHeader } ,
19+ message_blockdata:: Inventory ,
1920 Magic , NetworkExt ,
2021} ;
2122
@@ -336,6 +337,26 @@ impl ConnectionReader {
336337 }
337338 }
338339 }
340+ NetworkMessage :: Inv ( payload) => {
341+ let payload = & payload. 0 ;
342+ let now = Instant :: now ( ) ;
343+ if let Ok ( mut lock) = self . timed_messages . lock ( ) {
344+ for inv in payload {
345+ match inv {
346+ Inventory :: WTx ( _) => {
347+ lock. add_single ( TimedMessage :: TransactionAnnouncement , now) ;
348+ }
349+ Inventory :: Transaction ( _) => {
350+ lock. add_single ( TimedMessage :: TransactionAnnouncement , now) ;
351+ }
352+ Inventory :: WitnessTransaction ( _) => {
353+ lock. add_single ( TimedMessage :: TransactionAnnouncement , now) ;
354+ }
355+ _ => ( ) ,
356+ }
357+ }
358+ }
359+ }
339360 _ => ( ) ,
340361 }
341362 }
You can’t perform that action at this time.
0 commit comments