From 02ef50ab46ed5c5eb47d5d8cd20fc4680ed957aa Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Thu, 8 Apr 2021 09:22:41 +0200 Subject: [PATCH] Move pricing and payments into bitswap protobuf message Only a single message type is forwarded to the rpc handler, so we add pricing and payment info to that message type. --- dagger/bitswap/protobuf/bitswap.nim | 1 + dagger/bitswap/protobuf/message.proto | 12 ++++++++++++ dagger/bitswap/protobuf/payments.nim | 3 +-- dagger/bitswap/protobuf/payments.proto | 13 ------------- 4 files changed, 14 insertions(+), 15 deletions(-) delete mode 100644 dagger/bitswap/protobuf/payments.proto diff --git a/dagger/bitswap/protobuf/bitswap.nim b/dagger/bitswap/protobuf/bitswap.nim index e4498cef..e436bd0b 100644 --- a/dagger/bitswap/protobuf/bitswap.nim +++ b/dagger/bitswap/protobuf/bitswap.nim @@ -17,6 +17,7 @@ import_proto3 "message.proto" export Message export Wantlist, WantType, Entry export Block, BlockPresenceType, BlockPresence +export PricingMessage, StateChannelUpdate proc hash*(e: Entry): Hash = hash(e.`block`) diff --git a/dagger/bitswap/protobuf/message.proto b/dagger/bitswap/protobuf/message.proto index fc81228e..4abb2e1b 100644 --- a/dagger/bitswap/protobuf/message.proto +++ b/dagger/bitswap/protobuf/message.proto @@ -37,9 +37,21 @@ message Message { BlockPresenceType type = 2; } + message PricingMessage { + bytes address = 1; // Ethereum address to which payments should be made + bytes asset = 2; // Asset (coin) with which to pay + bytes price = 3; // Amount of assets to pay per byte (UInt256) + } + + message StateChannelUpdate { + bytes update = 1; // Signed Nitro state, serialized as JSON + } + Wantlist wantlist = 1; repeated bytes blocks = 2; // used to send Blocks in bitswap 1.0.0 repeated Block payload = 3; // used to send Blocks in bitswap 1.1.0 repeated BlockPresence blockPresences = 4; int32 pendingBytes = 5; + PricingMessage pricing = 6; + StateChannelUpdate payment = 7; } diff --git a/dagger/bitswap/protobuf/payments.nim b/dagger/bitswap/protobuf/payments.nim index 2a8f8f08..e300af9e 100644 --- a/dagger/bitswap/protobuf/payments.nim +++ b/dagger/bitswap/protobuf/payments.nim @@ -2,8 +2,7 @@ import pkg/protobuf_serialization import pkg/nitro import pkg/questionable import pkg/upraises - -import_proto3 "payments.proto" +import ./bitswap export PricingMessage export StateChannelUpdate diff --git a/dagger/bitswap/protobuf/payments.proto b/dagger/bitswap/protobuf/payments.proto deleted file mode 100644 index 1ef06ee6..00000000 --- a/dagger/bitswap/protobuf/payments.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -package bitswap.payments.pb; - -message PricingMessage { - bytes address = 1; // Ethereum address to which payments should be made - bytes asset = 2; // Asset (coin) with which to pay - bytes price = 3; // Amount of assets to pay per byte (UInt256) -} - -message StateChannelUpdate { - bytes update = 1; // Signed Nitro state, serialized as JSON -}