From 946c370480b23d481268de183ce052c18a8055b8 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sun, 31 Mar 2019 10:05:37 -0400 Subject: [PATCH 1/8] added a new protobuf for paginating txo results --- v2/proto/page.proto | 72 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 v2/proto/page.proto diff --git a/v2/proto/page.proto b/v2/proto/page.proto new file mode 100644 index 0000000..cb12e8d --- /dev/null +++ b/v2/proto/page.proto @@ -0,0 +1,72 @@ +// Page message can represent the results of +// paginated queries to a server which return +// transactions and outputs. This should be +// enough to cover just about every blockchain +// type in LBRY: claims, supports, payments, etc. +// +// Assembling Result Page +// +// To prevent unnecessarily duplicating the same +// raw TX many times if the result is TXOs in +// the same transaction, the Page is split between +// a list of `txos` (pointers) and a list of `txs` +// (actual raw transactions). To assemble the page, +// +// 1) Loop over all `txs`, parsing them into a TX +// object as desired and adding them into a +// mapping keyed by "tx hash -> TX object". +// +// 2) Create a new list to hold the page results. +// +// 3) Loop over all `txos` adding it along with the +// TX retrieved from previously created TX mapping. +// Optionally, lookup and include the channel `txo` +// using the same process. +// +// 4) You should now have a list of TXOs with their +// associated TX and for claims in a channel also +// associated channel TXO and TX. +// +// If the Page object is used strictly to return a list +// of TXs then the `txos` attribute will be empty. The +// semantics of which field is being paginated (`txos` vs +// `txs`) is determined in context of the RPC API. An +// RPC method such as `get_transactions` is likely to +// be paginating the `txs` list. +// +syntax = "proto3"; + +package pb; + +message Page { + repeated Output txos = 1; + repeated Transaction txs = 2; + uint32 total = 3; + uint32 offset = 4; +} + +message Output { + // pointer to an output in one of the Page.txs + bytes tx_hash = 1; + uint32 nout = 2; + + // if this output is a stream claim in a + // channel, this is a pointer to an output + // representing that channel (should be + // available in Page.txs) + Output channel = 3; +} + +message Transaction { + // entire raw transaction + bytes tx = 1; + + // height progression + // -1: in mempool but has unconfirmed inputs + // 0: in mempool and all inputs confirmed + // +num: confirmed in a specific block (height) + int32 height = 2; + + // position in block from top, only if height > 0 + uint32 position = 3; +} -- 2.45.2 From 7722e2c509651555ad5c0ad7a81b7d3ed7932223 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Wed, 10 Apr 2019 09:05:58 -0400 Subject: [PATCH 2/8] claim meta --- v2/proto/page.proto | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/v2/proto/page.proto b/v2/proto/page.proto index cb12e8d..d1b3f81 100644 --- a/v2/proto/page.proto +++ b/v2/proto/page.proto @@ -49,12 +49,16 @@ message Output { // pointer to an output in one of the Page.txs bytes tx_hash = 1; uint32 nout = 2; + oneof meta { + ClaimMeta claim = 3; + } +} - // if this output is a stream claim in a - // channel, this is a pointer to an output - // representing that channel (should be - // available in Page.txs) - Output channel = 3; +message ClaimMeta { + Output channel = 1; + bool is_winning = 2; + uint64 effective_amount = 3; + uint64 trending_amount = 4; } message Transaction { -- 2.45.2 From 33bba63786be82e1b91a27218bb970e55cac97ab Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Thu, 25 Apr 2019 19:46:48 -0400 Subject: [PATCH 3/8] updates --- v2/proto/page.proto | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/v2/proto/page.proto b/v2/proto/page.proto index d1b3f81..aaf6c8e 100644 --- a/v2/proto/page.proto +++ b/v2/proto/page.proto @@ -57,13 +57,14 @@ message Output { message ClaimMeta { Output channel = 1; bool is_winning = 2; - uint64 effective_amount = 3; - uint64 trending_amount = 4; + uint64 activation_height = 3; + uint64 effective_amount = 4; + uint64 trending_amount = 5; } message Transaction { // entire raw transaction - bytes tx = 1; + bytes raw = 1; // height progression // -1: in mempool but has unconfirmed inputs -- 2.45.2 From e7685d58ac0ea32712654d954d5cd0ab0eaf9482 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sat, 27 Apr 2019 19:00:30 -0400 Subject: [PATCH 4/8] renamed: page.proto -> result.proto --- v2/proto/{page.proto => result.proto} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename v2/proto/{page.proto => result.proto} (100%) diff --git a/v2/proto/page.proto b/v2/proto/result.proto similarity index 100% rename from v2/proto/page.proto rename to v2/proto/result.proto -- 2.45.2 From aedeae5c528d0929f97aeb0d3a465508b13ef3bb Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sat, 27 Apr 2019 19:01:44 -0400 Subject: [PATCH 5/8] split Page into separate objects Outputs and Transactions --- v2/proto/result.proto | 50 ++++++++----------------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/v2/proto/result.proto b/v2/proto/result.proto index aaf6c8e..fc33466 100644 --- a/v2/proto/result.proto +++ b/v2/proto/result.proto @@ -1,52 +1,14 @@ -// Page message can represent the results of -// paginated queries to a server which return -// transactions and outputs. This should be -// enough to cover just about every blockchain -// type in LBRY: claims, supports, payments, etc. -// -// Assembling Result Page -// -// To prevent unnecessarily duplicating the same -// raw TX many times if the result is TXOs in -// the same transaction, the Page is split between -// a list of `txos` (pointers) and a list of `txs` -// (actual raw transactions). To assemble the page, -// -// 1) Loop over all `txs`, parsing them into a TX -// object as desired and adding them into a -// mapping keyed by "tx hash -> TX object". -// -// 2) Create a new list to hold the page results. -// -// 3) Loop over all `txos` adding it along with the -// TX retrieved from previously created TX mapping. -// Optionally, lookup and include the channel `txo` -// using the same process. -// -// 4) You should now have a list of TXOs with their -// associated TX and for claims in a channel also -// associated channel TXO and TX. -// -// If the Page object is used strictly to return a list -// of TXs then the `txos` attribute will be empty. The -// semantics of which field is being paginated (`txos` vs -// `txs`) is determined in context of the RPC API. An -// RPC method such as `get_transactions` is likely to -// be paginating the `txs` list. -// syntax = "proto3"; package pb; -message Page { +message Outputs { repeated Output txos = 1; - repeated Transaction txs = 2; - uint32 total = 3; - uint32 offset = 4; + uint32 total = 2; + uint32 offset = 3; } message Output { - // pointer to an output in one of the Page.txs bytes tx_hash = 1; uint32 nout = 2; oneof meta { @@ -62,6 +24,12 @@ message ClaimMeta { uint64 trending_amount = 5; } +message Transactions { + repeated Transaction txs = 1; + uint32 total = 2; + uint32 offset = 3; +} + message Transaction { // entire raw transaction bytes raw = 1; -- 2.45.2 From be1cc9bbd41ea1507835492b78206bfb35718c80 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 29 Apr 2019 13:39:55 -0400 Subject: [PATCH 6/8] added claims_in_channel and removed Transaction message type --- v2/proto/result.proto | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/v2/proto/result.proto b/v2/proto/result.proto index fc33466..fca6d69 100644 --- a/v2/proto/result.proto +++ b/v2/proto/result.proto @@ -11,35 +11,28 @@ message Outputs { message Output { bytes tx_hash = 1; uint32 nout = 2; + uint32 height = 3; oneof meta { - ClaimMeta claim = 3; + ClaimMeta claim = 7; + Error error = 15; } } message ClaimMeta { Output channel = 1; - bool is_winning = 2; - uint64 activation_height = 3; + bool is_controlling = 2; + uint32 activation_height = 3; uint64 effective_amount = 4; uint64 trending_amount = 5; + uint32 claims_in_channel = 6; } -message Transactions { - repeated Transaction txs = 1; - uint32 total = 2; - uint32 offset = 3; -} - -message Transaction { - // entire raw transaction - bytes raw = 1; - - // height progression - // -1: in mempool but has unconfirmed inputs - // 0: in mempool and all inputs confirmed - // +num: confirmed in a specific block (height) - int32 height = 2; - - // position in block from top, only if height > 0 - uint32 position = 3; +message Error { + enum Code { + UNKNOWN_CODE = 0; + NOT_FOUND = 1; + INVALID = 2; + } + Code code = 1; + string text = 2; } -- 2.45.2 From f9d9ecd6f343f16fb008a3f452da5ded9a407850 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 20 May 2019 14:43:36 -0400 Subject: [PATCH 7/8] trending data in result.proto --- v2/proto/result.proto | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/v2/proto/result.proto b/v2/proto/result.proto index fca6d69..602c5c7 100644 --- a/v2/proto/result.proto +++ b/v2/proto/result.proto @@ -23,8 +23,12 @@ message ClaimMeta { bool is_controlling = 2; uint32 activation_height = 3; uint64 effective_amount = 4; - uint64 trending_amount = 5; + uint64 support_amount = 5; uint32 claims_in_channel = 6; + uint32 trending_group = 7; + sint64 trending_mixed = 8; + sint64 trending_local = 9; + sint64 trending_global = 10; } message Error { -- 2.45.2 From 86b26e43db6525ae669beea4b80ed223fe0b2f77 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 20 May 2019 14:54:51 -0400 Subject: [PATCH 8/8] use float for trending_* result --- v2/proto/result.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/v2/proto/result.proto b/v2/proto/result.proto index 602c5c7..09f4690 100644 --- a/v2/proto/result.proto +++ b/v2/proto/result.proto @@ -26,9 +26,9 @@ message ClaimMeta { uint64 support_amount = 5; uint32 claims_in_channel = 6; uint32 trending_group = 7; - sint64 trending_mixed = 8; - sint64 trending_local = 9; - sint64 trending_global = 10; + float trending_mixed = 8; + float trending_local = 9; + float trending_global = 10; } message Error { -- 2.45.2