From 28c5ce8e5c9449a66a9b169c618399ca3a4b33fd Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 18 Oct 2016 16:23:46 -0700 Subject: [PATCH] BIP0144+wire: introduce new segregated witness inventory types This commit adds the new inventory types for segwit which are used by the responder to explicitly request that transactions/blocks sent for a particular inv hash should include all witness data. --- wire/invvect.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/wire/invvect.go b/wire/invvect.go index 3feddcb1..1e706642 100644 --- a/wire/invvect.go +++ b/wire/invvect.go @@ -18,6 +18,10 @@ const ( // Maximum payload size for an inventory vector. maxInvVectPayload = 4 + chainhash.HashSize + + // InvWitnessFlag denotes that the inventory vector type is requesting, + // or sending a version which includes witness data. + InvWitnessFlag = 1 << 30 ) // InvType represents the allowed types of inventory vectors. See InvVect. @@ -25,18 +29,24 @@ type InvType uint32 // These constants define the various supported inventory vector types. const ( - InvTypeError InvType = 0 - InvTypeTx InvType = 1 - InvTypeBlock InvType = 2 - InvTypeFilteredBlock InvType = 3 + InvTypeError InvType = 0 + InvTypeTx InvType = 1 + InvTypeBlock InvType = 2 + InvTypeFilteredBlock InvType = 3 + InvTypeWitnessBlock InvType = InvTypeBlock | InvWitnessFlag + InvTypeWitnessTx InvType = InvTypeTx | InvWitnessFlag + InvTypeFilteredWitnessBlock InvType = InvTypeFilteredBlock | InvWitnessFlag ) // Map of service flags back to their constant names for pretty printing. var ivStrings = map[InvType]string{ - InvTypeError: "ERROR", - InvTypeTx: "MSG_TX", - InvTypeBlock: "MSG_BLOCK", - InvTypeFilteredBlock: "MSG_FILTERED_BLOCK", + InvTypeError: "ERROR", + InvTypeTx: "MSG_TX", + InvTypeBlock: "MSG_BLOCK", + InvTypeFilteredBlock: "MSG_FILTERED_BLOCK", + InvTypeWitnessBlock: "MSG_WITNESS_BLOCK", + InvTypeWitnessTx: "MSG_WITNESS_TX", + InvTypeFilteredWitnessBlock: "MSG_FILTERED_WITNESS_BLOCK", } // String returns the InvType in human-readable form.