@@ -601,6 +601,33 @@ func (sp *serverPeer) OnTx(_ *peer.Peer, msg *wire.MsgTx) {
601
601
<- sp .txProcessed
602
602
}
603
603
604
+ // OnUtreexoTx is invoked when a peer receives a utreexo tx bitcoin message.
605
+ // It blocks until the bitcoin transaction has been fully processed. Unlock the block
606
+ // handler this does not serialize all transactions through a single thread
607
+ // transactions don't rely on the previous one in a linear fashion like blocks.
608
+ func (sp * serverPeer ) OnUtreexoTx (_ * peer.Peer , msg * wire.MsgUtreexoTx ) {
609
+ if cfg .BlocksOnly {
610
+ peerLog .Tracef ("Ignoring utreexo tx %v from %v - blocksonly enabled" ,
611
+ msg .TxHash (), sp )
612
+ return
613
+ }
614
+
615
+ // Add the transaction to the known inventory for the peer.
616
+ // Convert the raw MsgUtreexoTx to a btcutil.UtreexoTx which provides some convenience
617
+ // methods and things such as hash caching.
618
+ tx := btcutil .NewUtreexoTx (msg )
619
+ iv := wire .NewInvVect (wire .InvTypeTx , tx .Hash ())
620
+ sp .AddKnownInventory (iv )
621
+
622
+ // Queue the transaction up to be handled by the sync manager and
623
+ // intentionally block further receives until the transaction is fully
624
+ // processed and known good or bad. This helps prevent a malicious peer
625
+ // from queuing up a bunch of bad transactions before disconnecting (or
626
+ // being disconnected) and wasting memory.
627
+ sp .server .syncManager .QueueUtreexoTx (tx , sp .Peer , sp .txProcessed )
628
+ <- sp .txProcessed
629
+ }
630
+
604
631
// OnBlock is invoked when a peer receives a block bitcoin message. It
605
632
// blocks until the bitcoin block has been fully processed.
606
633
func (sp * serverPeer ) OnBlock (_ * peer.Peer , msg * wire.MsgBlock , buf []byte ) {
@@ -2408,6 +2435,7 @@ func newPeerConfig(sp *serverPeer) *peer.Config {
2408
2435
OnVerAck : sp .OnVerAck ,
2409
2436
OnMemPool : sp .OnMemPool ,
2410
2437
OnTx : sp .OnTx ,
2438
+ OnUtreexoTx : sp .OnUtreexoTx ,
2411
2439
OnBlock : sp .OnBlock ,
2412
2440
OnInv : sp .OnInv ,
2413
2441
OnHeaders : sp .OnHeaders ,
0 commit comments