@@ -262,16 +262,14 @@ func (handler *TxHandler) Start() {
262262
263263 // libp2p pubsub validator and handler abstracted as TaggedMessageProcessor
264264 // TODO: rename to validators
265- handler .net .RegisterProcessors ([]network.TaggedMessageProcessor {
265+ handler .net .RegisterValidatorHandlers ([]network.TaggedMessageValidatorHandler {
266266 {
267267 Tag : protocol .TxnTag ,
268268 // create anonymous struct to hold the two functions and satisfy the network.MessageProcessor interface
269269 MessageHandler : struct {
270- network.ProcessorValidateFunc
271- network.ProcessorHandleFunc
270+ network.ValidateHandleFunc
272271 }{
273- network .ProcessorValidateFunc (handler .validateIncomingTxMessage ),
274- network .ProcessorHandleFunc (handler .processIncomingTxMessage ),
272+ network .ValidateHandleFunc (handler .validateIncomingTxMessage ),
275273 },
276274 },
277275 })
@@ -788,31 +786,24 @@ func (handler *TxHandler) processIncomingTxn(rawmsg network.IncomingMessage) net
788786 return network.OutgoingMessage {Action : network .Ignore }
789787}
790788
791- type validatedIncomingTxMessage struct {
792- rawmsg network.IncomingMessage
793- unverifiedTxGroup []transactions.SignedTxn
794- msgKey * crypto.Digest
795- canonicalKey * crypto.Digest
796- }
797-
798789// validateIncomingTxMessage is the validator for the MessageProcessor implementation used by P2PNetwork.
799- func (handler * TxHandler ) validateIncomingTxMessage (rawmsg network.IncomingMessage ) network.ValidatedMessage {
790+ func (handler * TxHandler ) validateIncomingTxMessage (rawmsg network.IncomingMessage ) network.OutgoingMessage {
800791 msgKey , isDup := handler .incomingMsgDupCheck (rawmsg .Data )
801792 if isDup {
802- return network.ValidatedMessage {Action : network .Ignore , ValidatedMessage : nil }
793+ return network.OutgoingMessage {Action : network .Ignore }
803794 }
804795
805796 unverifiedTxGroup , consumed , invalid := decodeMsg (rawmsg .Data )
806797 if invalid {
807798 // invalid encoding or exceeding txgroup, disconnect from this peer
808- return network.ValidatedMessage {Action : network .Disconnect , ValidatedMessage : nil }
799+ return network.OutgoingMessage {Action : network .Disconnect }
809800 }
810801
811802 canonicalKey , drop := handler .incomingTxGroupDupRateLimit (unverifiedTxGroup , consumed , rawmsg .Sender )
812803 if drop {
813804 // this re-serialized txgroup was detected as a duplicate by the canonical message cache,
814805 // or it was rate-limited by the per-app rate limiter
815- return network.ValidatedMessage {Action : network .Ignore , ValidatedMessage : nil }
806+ return network.OutgoingMessage {Action : network .Ignore }
816807 }
817808
818809 // apply backlog worker logic
@@ -827,9 +818,8 @@ func (handler *TxHandler) validateIncomingTxMessage(rawmsg network.IncomingMessa
827818
828819 if handler .checkAlreadyCommitted (wi ) {
829820 transactionMessagesAlreadyCommitted .Inc (nil )
830- return network.ValidatedMessage {
831- Action : network .Ignore ,
832- ValidatedMessage : nil ,
821+ return network.OutgoingMessage {
822+ Action : network .Ignore ,
833823 }
834824 }
835825
@@ -842,9 +832,8 @@ func (handler *TxHandler) validateIncomingTxMessage(rawmsg network.IncomingMessa
842832 if wi .Err != nil {
843833 handler .postProcessReportErrors (wi .Err )
844834 logging .Base ().Warnf ("Received a malformed tx group %v: %v" , m .unverifiedTxGroup , wi .Err )
845- return network.ValidatedMessage {
846- Action : network .Disconnect ,
847- ValidatedMessage : nil ,
835+ return network.OutgoingMessage {
836+ Action : network .Disconnect ,
848837 }
849838 }
850839 // at this point, we've verified the transaction, so we can safely treat the transaction as a verified transaction.
@@ -855,9 +844,8 @@ func (handler *TxHandler) validateIncomingTxMessage(rawmsg network.IncomingMessa
855844 if err != nil {
856845 handler .rememberReportErrors (err )
857846 logging .Base ().Debugf ("could not remember tx: %v" , err )
858- return network.ValidatedMessage {
859- Action : network .Ignore ,
860- ValidatedMessage : nil ,
847+ return network.OutgoingMessage {
848+ Action : network .Ignore ,
861849 }
862850 }
863851
@@ -868,32 +856,23 @@ func (handler *TxHandler) validateIncomingTxMessage(rawmsg network.IncomingMessa
868856 if err != nil {
869857 logging .Base ().Infof ("unable to pin transaction: %v" , err )
870858 }
871- return network.ValidatedMessage {
872- Action : network .Accept ,
873- ValidatedMessage : nil ,
859+ return network.OutgoingMessage {
860+ Action : network .Accept ,
874861 }
875862
876863 case <- handler .streamVerifierDropped2 :
877864 transactionMessagesDroppedFromBacklog .Inc (nil )
878- return network.ValidatedMessage {
879- Action : network .Ignore ,
880- ValidatedMessage : nil ,
865+ return network.OutgoingMessage {
866+ Action : network .Ignore ,
881867 }
882868 case <- handler .ctx .Done ():
883869 transactionMessagesDroppedFromBacklog .Inc (nil )
884- return network.ValidatedMessage {
885- Action : network .Ignore ,
886- ValidatedMessage : nil ,
870+ return network.OutgoingMessage {
871+ Action : network .Ignore ,
887872 }
888873 }
889874}
890875
891- // processIncomingTxMessage is the handler for the MessageProcessor implementation used by P2PNetwork.
892- func (handler * TxHandler ) processIncomingTxMessage (validatedMessage network.ValidatedMessage ) network.OutgoingMessage {
893- // process is noop, all work is done in validateIncomingTxMessage above
894- return network.OutgoingMessage {Action : network .Ignore }
895- }
896-
897876var errBackLogFullLocal = errors .New ("backlog full" )
898877
899878// LocalTransaction is a special shortcut handler for local transactions and intended to be used
0 commit comments