From d63faf6da27fb71bb4422a92d5bfe1a85a984fec Mon Sep 17 00:00:00 2001 From: lostystyg Date: Fri, 14 Oct 2022 11:17:27 +0400 Subject: [PATCH 01/21] Actialized events: referals --- .../repositories/web/WebRpcRepository.cpp | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 30c1a4ddf..789879dc4 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6407,9 +6407,16 @@ namespace PocketDb t.BlockNum as BlockNum, null, null, + null, + null, + null, + null, + null, + null, + null, + p.String1, p.String2, p.String3, - p.String4, ifnull(r.Value,0), null, null, @@ -6421,16 +6428,30 @@ namespace PocketDb null, null, null, + null, + null, + null, + null, + null, + null, + null, + null, + null, null from Transactions t indexed by Transactions_Type_Last_String2_Height + left join Transactions tLast indexed by Transactions_Type_Last_String1_Height_Id + on tLast.Type = 100 + and tLast.Last = 1 + and tLast.String1 = t.String1 + left join Payload p - on p.TxHash = t.Hash + on p.TxHash = tLast.Hash left join Ratings r indexed by Ratings_Type_Id_Last_Height on r.Type = 0 - and r.Id = t.Id + and r.Id = tLast.Id and r.Last = 1 where t.Type = 100 From a1e1fba39588879030a1812c6831cf90819ade1c Mon Sep 17 00:00:00 2001 From: lostystyg Date: Fri, 14 Oct 2022 11:20:04 +0400 Subject: [PATCH 02/21] Actualized events: answers --- .../repositories/web/WebRpcRepository.cpp | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 789879dc4..683688c0c 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6478,45 +6478,65 @@ namespace PocketDb a.Hash, a.Type, a.String1, - orig.Height as Height, + a.Height as Height, a.BlockNum as BlockNum, null, + a.String2, + a.String3, + null, + null, + null, pa.String1, + a.String4, + a.String5, paa.String2, paa.String3, paa.String4, ifnull(ra.Value,0), + null, c.Hash, c.Type, null, c.Height, c.BlockNum, null, + c.String2, + null, + null, + null, + null, pc.String1, null, null, null, + null, + null, + null, null - from Transactions c indexed by Transactions_Type_Last_String1_String2_Height -- My comments + from Transactions c indexed by Transactions_Type_Last_String1_Height_Id -- My comments left join Payload pc on pc.TxHash = c.Hash join Transactions a indexed by Transactions_Type_Last_String5_Height -- Other answers - on a.Type in (204, 205) and a.Last = 1 + on a.Type in (204, 205) and a.Last in (0,1) and a.Height > ? and (a.Height < ? or (a.Height = ? and a.BlockNum < ?)) and a.String5 = c.String2 and a.String1 != c.String1 + and a.Hash = a.String2 - join Transactions orig indexed by Transactions_Hash_Height - on orig.Hash = a.String2 + left join Transactions aLast indexed by Transactions_Type_Last_String2_Height + on aLast.Type in (204,205) + and aLast.Last = 1 + and aLast.String2 = a.Hash + and aLast.Height > 0 left join Payload pa - on pa.TxHash = a.Hash + on pa.TxHash = aLast.Hash - left join Transactions aa + left join Transactions aa indexed by Transactions_Type_Last_String1_Height_Id on aa.Type = 100 and aa.Last = 1 and aa.String1 = a.String1 @@ -6531,9 +6551,9 @@ namespace PocketDb and ra.Last = 1 where c.Type in (204, 205) - and c.Last = 1 - and c.String1 = ? - and c.Height > 0 + and c.Last = 1 + and c.String1 = ? + and c.Height > 0 )sql", [this](std::shared_ptr& stmt, int& i, QueryParams const& queryParams){ TryBindStatementInt64(stmt, i++, queryParams.heightMin); From d3c18ffdefe67d7a365177d321477c93eaa8303d Mon Sep 17 00:00:00 2001 From: lostystyg Date: Fri, 14 Oct 2022 11:53:54 +0400 Subject: [PATCH 03/21] Actualized events: comments --- .../repositories/web/WebRpcRepository.cpp | 60 +++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 683688c0c..6e3d4f585 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6574,44 +6574,81 @@ namespace PocketDb c.String1, c.Height as Height, c.BlockNum as BlockNum, - oc.Value, + null, + c.String2, + c.String3, + null, + ( + select json_group_array(json_object( + 'Value', Value, + 'Number', Number, + 'AddressHash', AddressHash, + 'ScriptPubKey', ScriptPubKey + )) + from TxOutputs i + where i.SpentTxHash = c.Hash + ), + ( + select json_group_array(json_object( + 'Value', Value, + 'AddressHash', AddressHash, + 'ScriptPubKey', ScriptPubKey + )) + from TxOutputs o + where o.TxHash = c.Hash + and o.TxHeight = c.Height + order by o.Number + ), pc.String1, + null, + null, + pac.String1, pac.String2, pac.String3, - pac.String4, ifnull(rac.Value,0), + null, p.Hash, p.Type, null, p.Height, p.BlockNum, null, + p.String2, + null, + null, + null, + null, + pp.String2, + null, + null, null, null, null, null, null - from Transactions p indexed by Transactions_String1_Last_Height + from Transactions p indexed by Transactions_Type_Last_String1_Height_Id join Transactions c indexed by Transactions_Type_Last_String3_Height - on c.Type in (204,205) - and c.Last = 1 + on c.Type = 204 + and c.Last in (0,1) and c.String3 = p.String2 and c.String1 != p.String1 - and c.Hash = c.String2 and c.String4 is null and c.String5 is null and c.Height > ? and (c.Height < ? or (c.Height = ? and c.BlockNum < ?)) - left join TxOutputs oc indexed by TxOutputs_TxHash_AddressHash_Value - on oc.TxHash = c.Hash and oc.AddressHash = p.String1 and oc.AddressHash != c.String1 + left join Transactions cLast indexed by Transactions_Type_Last_String2_Height + on cLast.Type in (204,205) + and cLast.Last = 1 + and cLast.String2 = c.Hash + and cLast.Height > 0 left join Payload pc - on pC.TxHash = c.Hash + on pC.TxHash = cLast.Hash - join Transactions ac -- accounts of commentators + join Transactions ac indexed by Transactions_Type_Last_String1_Height_Id on ac.String1 = c.String1 and ac.Last = 1 and ac.Type = 100 @@ -6625,6 +6662,9 @@ namespace PocketDb and rac.Id = ac.Id and rac.Last = 1 + left join Payload pp + on pp.TxHash = p.Hash + where p.Type in (200,201,202) and p.Last = 1 and p.Height > 0 From 80de8b538d49fca13a87c5baf4a839f312e422f2 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Tue, 18 Oct 2022 13:58:55 +0400 Subject: [PATCH 04/21] Actualized events: subscribers --- .../repositories/web/WebRpcRepository.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 6e3d4f585..9c751e7cc 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6691,9 +6691,16 @@ namespace PocketDb subs.BlockNum as BlockNum, null, null, + null, + null, + null, + null, + null, + null, + null, + pu.String1, pu.String2, pu.String3, - pu.String4, ifnull(ru.Value,0), null, null, @@ -6705,6 +6712,15 @@ namespace PocketDb null, null, null, + null, + null, + null, + null, + null, + null, + null, + null, + null, null from Transactions subs --indexed by Transactions_Type_Last_String2_Height From 803a20a475f0ec61e71ba5e7fc02b0412a94d266 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Tue, 18 Oct 2022 15:38:59 +0400 Subject: [PATCH 05/21] Actualized events: commentscores --- .../repositories/web/WebRpcRepository.cpp | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 9c751e7cc..7abc5711c 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6764,19 +6764,35 @@ namespace PocketDb s.String1, s.Height as Height, s.BlockNum as BlockNum, + null, + null, + null, s.Int1, null, + null, + null, + null, + null, + pacs.String1, pacs.String2, pacs.String3, - pacs.String4, ifnull(racs.Value,0), + null, c.Hash, c.Type, null, - c.Height, -- TODO (losty): original? + c.Height, c.BlockNum, null, + c.String2, + c.String3, + null, + null, + null, ps.String1, + c.String4, + c.String5, + null, null, null, null, @@ -6791,8 +6807,13 @@ namespace PocketDb and s.Height > ? and (s.Height < ? or (s.Height = ? and s.BlockNum < ?)) + left join Transactions cLast indexed by Transactions_Type_Last_String2_Height + on cLast.Type in (204,205) + and cLast.Last = 1 + and cLast.String2 = c.String2 + left join Payload ps - on ps.TxHash = c.Hash + on ps.TxHash = cLast.Hash join Transactions acs on acs.Type = 100 @@ -6808,8 +6829,8 @@ namespace PocketDb and racs.Id = acs.Id and racs.Last = 1 - where c.Type in (204,205) - and c.Last = 1 + where c.Type in (204) + and c.Last in (0,1) and c.Height > 0 and c.String1 = ? )sql", From 638a524a5d26f322b3971c6b8070508875c87e4e Mon Sep 17 00:00:00 2001 From: lostystyg Date: Tue, 18 Oct 2022 15:45:23 +0400 Subject: [PATCH 06/21] Actualized events: contentscores --- .../repositories/web/WebRpcRepository.cpp | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 7abc5711c..4fd3db79b 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6853,22 +6853,38 @@ namespace PocketDb s.String1, s.Height as Height, s.BlockNum as BlockNum, + null, + null, + null, s.Int1, null, + null, + null, + null, + null, + pacs.String1, pacs.String2, pacs.String3, - pacs.String4, ifnull(racs.Value,0), + null, c.Hash, c.Type, null, - c.Height, -- TODO (losty): original? + c.Height, c.BlockNum, null, + c.String2, + null, + null, + null, + null, pc.String2, null, null, null, + null, + null, + null, null from Transactions c indexed by Transactions_Type_Last_String1_Height_Id @@ -6880,8 +6896,13 @@ namespace PocketDb and s.Height > ? and (s.Height < ? or (s.Height = ? and s.BlockNum < ?)) + left join Transactions cLast indexed by Transactions_Type_Last_String2_Height + on cLast.Type = c.Type + and cLast.Last = 1 + and cLast.String2 = c.String2 + left join Payload pc - on pc.TxHash = c.Hash + on pc.TxHash = cLast.Hash join Transactions acs on acs.Type = 100 @@ -6898,7 +6919,7 @@ namespace PocketDb and racs.Last = 1 where c.Type in (200, 201, 202) - and c.Last = 1 + and c.Hash = c.String2 -- orig and c.Height > 0 and c.String1 = ? )sql", From 6a1932f592b03668b6ac448892dbbdef7baaf13b Mon Sep 17 00:00:00 2001 From: lostystyg Date: Tue, 18 Oct 2022 17:34:29 +0400 Subject: [PATCH 07/21] Actualized events: privatecontent --- .../repositories/web/WebRpcRepository.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 4fd3db79b..17e74e805 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6964,16 +6964,21 @@ namespace PocketDb join Transactions c indexed by Transactions_Type_Last_String1_Height_Id -- content for private subscribers on c.Type in (200,201,202) - and c.Last = 1 -- TODO (losty): last = 1 and c.Hash = c.String2 ????? + and c.Last in (0,1) and c.String1 = subs.String2 - -- and c.Hash = c.String2 -- TODO (losty): Only first content record + and c.Hash = c.String2 -- orig and c.Height > ? and (c.Height < ? or (c.Height = ? and c.BlockNum < ?)) + left join Transactions cLast indexed by Transactions_Type_Last_String2_Height + on cLast.Type = c.Type + and cLast.Last = 1 + and cLast.String2 = c.String2 + left join Payload p - on p.TxHash = c.Hash - - join Transactions ac + on p.TxHash = cLast.Hash + + left join Transactions ac indexed by Transactions_Type_Last_String1_Height_Id on ac.Type = 100 and ac.Last = 1 and ac.String1 = c.String1 @@ -6986,7 +6991,7 @@ namespace PocketDb on rac.Type = 0 and rac.Id = ac.Id and rac.Last = 1 - + where subs.Type = 303 and subs.Last = 1 and subs.Height > 0 From 6e0d9df0cdf9af409410284017c94ed088c70420 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Tue, 18 Oct 2022 17:34:57 +0400 Subject: [PATCH 08/21] Actualized events: boosts --- .../repositories/web/WebRpcRepository.cpp | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 17e74e805..72f642e35 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -7016,39 +7016,56 @@ namespace PocketDb tBoost.String1, tBoost.Height as Height, tBoost.BlockNum as BlockNum, + null, + null, + null, tBoost.Int1, null, + null, + null, + null, + null, + pac.String1, pac.String2, pac.String3, - pac.String4, ifnull(rac.Value,0), + null, tContent.Hash, tContent.Type, null, tContent.Height, tContent.BlockNum, null, + tContent.String2, + null, + null, + null, + null, pContent.String2, null, null, null, + null, + null, + null, null from Transactions tBoost indexed by Transactions_Type_Last_Height_Id join Transactions tContent indexed by Transactions_Type_Last_String1_String2_Height on tContent.Type in (200,201,202) - and tContent.Last in (0,1) - and tContent.Height > 0 + and tContent.Last = 1 and tContent.String1 = ? and tContent.String2 = tBoost.String2 + and tContent.Height > 0 + left join Payload pContent on pContent.TxHash = tContent.Hash - - join Transactions ac - on ac.String1 = tBoost.String1 - and ac.Type = 100 + + left join Transactions ac indexed by Transactions_Type_Last_String1_Height_Id + on ac.Type = 100 and ac.Last = 1 + and ac.String1 = tBoost.String1 and ac.Height > 0 left join Payload pac From 93e34cb73c48144d4d914a030770bd418c26c977 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Tue, 18 Oct 2022 17:58:14 +0400 Subject: [PATCH 09/21] Actualized events: reposts --- .../repositories/web/WebRpcRepository.cpp | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 72f642e35..2dc0b4af7 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -7098,42 +7098,64 @@ namespace PocketDb r.Hash, r.Type, r.String1, - r.Height as Height, -- TODO (losty): orig height maybe??? + r.Height as Height, r.BlockNum as BlockNum, null, + r.String2, + null, + null, + null, + null, pr.String2, + null, + null, + par.String1, par.String2, par.String3, - par.String4, ifnull(rar.Value,0), + null, p.Hash, p.Type, null, p.Height, p.BlockNum, null, + p.String2, + null, + null, + null, + null, pp.String2, null, null, null, + null, + null, + null, null from Transactions p indexed by Transactions_Type_Last_String1_Height_Id - join Payload pp - on pp.TxHash = p.Hash + left join Payload pp + on pp.TxHash = p.Hash join Transactions r indexed by Transactions_Type_Last_String3_Height on r.Type in (200,201,202) - and r.Last = 1 + and r.Last in (0,1) + and r.Hash = r.String2 and r.String3 = p.String2 and r.Height > ? and (r.Height < ? or (r.Height = ? and r.BlockNum < ?)) + left join Transactions rLast indexed by Transactions_Type_Last_String2_Height + on rLast.Type = r.Type + and rLast.Last = 1 + and rLast.String2 = r.String2 + left join Payload pr - on pr.TxHash = r.Hash + on pr.TxHash = rLast.Hash - join Transactions ar + left join Transactions ar indexed by Transactions_Type_Last_String1_Height_Id on ar.Type = 100 and ar.Last = 1 and ar.String1 = r.String1 From 4f21e1e97f67fa5a0d43886bc473c911571ba55d Mon Sep 17 00:00:00 2001 From: lostystyg Date: Tue, 18 Oct 2022 20:47:58 +0400 Subject: [PATCH 10/21] Enable getevents rpc --- src/pocketdb/web/PocketRpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketdb/web/PocketRpc.cpp b/src/pocketdb/web/PocketRpc.cpp index 951afc170..d2fcab1f5 100644 --- a/src/pocketdb/web/PocketRpc.cpp +++ b/src/pocketdb/web/PocketRpc.cpp @@ -69,7 +69,7 @@ static const CRPCCommand commands[] = {"contents", "getcontents", &GetContents, {"address"}}, {"contents", "getrandomcontents", &GetRandomContents, {}}, {"contents", "getcontentactions", &GetContentActions, {"contentHash"}}, - // {"contents", "getevents", &GetEvents, {"address", "height", "blockNum", "filters"}}, + {"contents", "getevents", &GetEvents, {"address", "height", "blockNum", "filters"}}, {"contents", "getactivities", &GetActivities, {"address", "height", "blockNum", "filters"}}, {"contents", "getnotifications", &GetNotifications, {"height", "filters"}}, {"contents", "getnotificationssummary", &GetNotificationsSummary, {"addresses", "height", "filters"}}, From 23b12a148aaf7a2b76b7ca73ab551ddbe7a58449 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 19 Oct 2022 22:01:32 +0400 Subject: [PATCH 11/21] Actualized events: money --- .../repositories/web/WebRpcRepository.cpp | 62 ++++++++++++++++--- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 2dc0b4af7..9c5bc221f 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6346,10 +6346,61 @@ namespace PocketDb (')sql" + ShortTxTypeConvertor::toString(ShortTxType::Money) + R"sql(')TP, t.Hash, t.Type, - i.AddressHash, + null, t.Height as Height, t.BlockNum as BlockNum, - o.Value, + null, + null, + null, + null, + ( + select json_group_array(json_object( + 'Value', Value, + 'Number', Number, + 'AddressHash', AddressHash, + 'ScriptPubKey', ScriptPubKey + )) + from TxOutputs i + where i.SpentTxHash = t.Hash + ), + ( + select json_group_array(json_object( + 'Value', o.Value, + 'AddressHash', o.AddressHash, + 'ScriptPubKey', o.ScriptPubKey, + 'Account', json_object( + 'Lang', pna.String1, + 'Name', pna.String2, + 'Avatar', pna.String3, + 'Rep', ifnull(rna.Value,0) + ) + )) + from TxOutputs o + left join Transactions na indexed by Transactions_Type_Last_String1_String2_Height + on na.Type = 100 + and na.Last = 1 + and na.String1 = o.AddressHash + left join Payload pna + on pna.TxHash = na.Hash + left join Ratings rna indexed by Ratings_Type_Id_Last_Height + on rna.Type = 0 + and rna.Id = na.Id + and rna.Last = 1 + where o.TxHash = t.Hash + and o.TxHeight = t.Height + order by o.Number + ), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, null, null, null, @@ -6371,15 +6422,10 @@ namespace PocketDb join Transactions t indexed by Transactions_Hash_Type_Height on t.Hash = o.TxHash - and t.Type in (1,2,3) -- 1 default money transfer, 2 coinbase, 3 coinstake + and t.Type in (1,2,3) and t.Height > ? and (t.Height < ? or (t.Height = ? and t.BlockNum < ?)) - join TxOutputs i indexed by TxOutputs_SpentTxHash - on i.SpentTxHash = o.TxHash - and i.Number = (select min(ii.Number) from TxOutputs ii where ii.SpentTxHash = o.TxHash) - and i.AddressHash != o.AddressHash -- TODO (brangr, lostystyg): exclude coinstake first transaction - where o.AddressHash = ? and o.TxHeight > ? and o.TxHeight < ? From c72ee1967d5ff9d30cd680a6a35dc581d7456501 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 19 Oct 2022 22:02:05 +0400 Subject: [PATCH 12/21] Fix privatecontent for events --- .../repositories/web/WebRpcRepository.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 9c5bc221f..457087f67 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6989,12 +6989,28 @@ namespace PocketDb c.Height as Height, c.BlockNum as BlockNum, null, + null, + null, + null, + null, + null, p.String2, + null, + null, + pac.String1, pac.String2, pac.String3, - pac.String4, ifnull(rac.Value,0), - null, -- TODO (losty): probably reposts here? + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, null, null, null, From 17ec285f7edc86a65a3b1e2e4c7bf7ee6442b8c9 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 19 Oct 2022 22:02:56 +0400 Subject: [PATCH 13/21] Indicies for subscribers query in events --- src/pocketdb/repositories/web/WebRpcRepository.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 457087f67..7d54bb59b 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6769,9 +6769,9 @@ namespace PocketDb null, null - from Transactions subs --indexed by Transactions_Type_Last_String2_Height + from Transactions subs indexed by Transactions_Type_Last_String2_Height - join Transactions u --indexed by Transactions_Type_Last_String1_Height_Id + join Transactions u indexed by Transactions_Type_Last_String1_Height_Id on u.Type in (100) and u.Last = 1 and u.String1 = subs.String1 From bcef6a02bbcb059c8314fb45e13ca0abedcfa207 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 19 Oct 2022 22:05:50 +0400 Subject: [PATCH 14/21] Fixed index for contentscore in events --- src/pocketdb/repositories/web/WebRpcRepository.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 7d54bb59b..8a8434206 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6933,7 +6933,7 @@ namespace PocketDb null, null - from Transactions c indexed by Transactions_Type_Last_String1_Height_Id + from Transactions c indexed by Transactions_Type_String1_Height_Time_Int1 join Transactions s indexed by Transactions_Type_Last_String2_Height on s.Type = 300 From 8d24eb5a1b315920cfcb982bbd36766024ebbec2 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 26 Oct 2022 18:46:19 +0200 Subject: [PATCH 15/21] Events: added rootTxHash for privatecontent --- src/pocketdb/repositories/web/WebRpcRepository.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 8a8434206..6e048ddd9 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6989,7 +6989,7 @@ namespace PocketDb c.Height as Height, c.BlockNum as BlockNum, null, - null, + c.String2, null, null, null, From fd826690691ac947b2b56f9c0c2cb96c02e5976f Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 26 Oct 2022 18:46:52 +0200 Subject: [PATCH 16/21] Events: fixed profile for answer --- src/pocketdb/repositories/web/WebRpcRepository.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 6e048ddd9..8640661fa 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6535,9 +6535,9 @@ namespace PocketDb pa.String1, a.String4, a.String5, + paa.String1, paa.String2, paa.String3, - paa.String4, ifnull(ra.Value,0), null, c.Hash, From 6c084a4a32578019d018a93e306e269148954fca Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 26 Oct 2022 18:51:20 +0200 Subject: [PATCH 17/21] Events: removed postHash from comments to because it is available in relatedContent --- src/pocketdb/repositories/web/WebRpcRepository.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 8640661fa..1ccf4ff7b 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6622,7 +6622,7 @@ namespace PocketDb c.BlockNum as BlockNum, null, c.String2, - c.String3, + null, null, ( select json_group_array(json_object( From 0af7cf6e57f54722a248dc100c18cbff99af0b90 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 26 Oct 2022 19:19:45 +0200 Subject: [PATCH 18/21] Events: inputs/outputs instead of value for boost --- .../repositories/web/WebRpcRepository.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 1ccf4ff7b..0d59fd1ea 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -7081,9 +7081,28 @@ namespace PocketDb null, null, null, - tBoost.Int1, - null, null, + ( + select json_group_array(json_object( + 'Value', Value, + 'Number', Number, + 'AddressHash', AddressHash, + 'ScriptPubKey', ScriptPubKey + )) + from TxOutputs i + where i.SpentTxHash = tBoost.Hash + ), + ( + select json_group_array(json_object( + 'Value', Value, + 'AddressHash', AddressHash, + 'ScriptPubKey', ScriptPubKey + )) + from TxOutputs o + where o.TxHash = tBoost.Hash + and o.TxHeight = tBoost.Height + order by o.Number + ), null, null, null, From 1ce0fe5daabb528f932b3a424410fd7e0311217d Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 26 Oct 2022 19:42:41 +0200 Subject: [PATCH 19/21] Events: fixed money query --- .../repositories/web/WebRpcRepository.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 0d59fd1ea..073846aed 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6342,12 +6342,12 @@ namespace PocketDb { ShortTxType::Money, { R"sql( -- Incoming money - select + select distinct (')sql" + ShortTxTypeConvertor::toString(ShortTxType::Money) + R"sql(')TP, t.Hash, t.Type, null, - t.Height as Height, + o.TxHeight as Height, t.BlockNum as BlockNum, null, null, @@ -6360,14 +6360,14 @@ namespace PocketDb 'AddressHash', AddressHash, 'ScriptPubKey', ScriptPubKey )) - from TxOutputs i + from TxOutputs i indexed by TxOutputs_SpentTxHash where i.SpentTxHash = t.Hash ), ( select json_group_array(json_object( - 'Value', o.Value, - 'AddressHash', o.AddressHash, - 'ScriptPubKey', o.ScriptPubKey, + 'Value', oo.Value, + 'AddressHash', oo.AddressHash, + 'ScriptPubKey', oo.ScriptPubKey, 'Account', json_object( 'Lang', pna.String1, 'Name', pna.String2, @@ -6375,20 +6375,20 @@ namespace PocketDb 'Rep', ifnull(rna.Value,0) ) )) - from TxOutputs o + from TxOutputs oo indexed by TxOutputs_TxHash_AddressHash_Value left join Transactions na indexed by Transactions_Type_Last_String1_String2_Height on na.Type = 100 and na.Last = 1 - and na.String1 = o.AddressHash + and na.String1 = oo.AddressHash left join Payload pna on pna.TxHash = na.Hash left join Ratings rna indexed by Ratings_Type_Id_Last_Height on rna.Type = 0 and rna.Id = na.Id and rna.Last = 1 - where o.TxHash = t.Hash - and o.TxHeight = t.Height - order by o.Number + where oo.TxHash = t.Hash + and oo.TxHeight = t.Height + order by oo.Number ), null, null, @@ -6428,7 +6428,7 @@ namespace PocketDb where o.AddressHash = ? and o.TxHeight > ? - and o.TxHeight < ? + and o.TxHeight <= ? )sql", [this](std::shared_ptr& stmt, int& i, QueryParams const& queryParams){ TryBindStatementInt64(stmt, i++, queryParams.heightMin); From 2c80bab415b390320b54b285e3b5e21adf3f3383 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 26 Oct 2022 19:54:34 +0200 Subject: [PATCH 20/21] Search only 200 txtype for reposts in activities, events, notifications --- src/pocketdb/repositories/web/WebRpcRepository.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index 073846aed..f4caa9c5e 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6256,7 +6256,7 @@ namespace PocketDb from Transactions r join Transactions p indexed by Transactions_Type_Last_String2_Height - on p.Type in (200,201,202) + on p.Type in = 200 and p.Last = 1 and p.String2 = r.String3 and p.Height > 0 @@ -6294,7 +6294,7 @@ namespace PocketDb and rna.Id = na.Id and rna.Last = 1 - where r.Type in (200,201,202) + where r.Type in = 200 and r.Hash = r.String2 -- Only orig and r.Height = ? and r.String3 is not null @@ -7221,7 +7221,7 @@ namespace PocketDb on pp.TxHash = p.Hash join Transactions r indexed by Transactions_Type_Last_String3_Height - on r.Type in (200,201,202) + on r.Type = 200 and r.Last in (0,1) and r.Hash = r.String2 and r.String3 = p.String2 @@ -7250,7 +7250,7 @@ namespace PocketDb and rar.Id = ar.Id and rar.Last = 1 - where p.Type in (200,201,202) + where p.Type = 200 and p.Last = 1 and p.Height > 0 and p.String1 = ? @@ -7459,10 +7459,10 @@ namespace PocketDb join Transactions p indexed by Transactions_Type_Last_String1_String2_Height on p.String2 = r.String3 and p.Last = 1 - and p.Type in (200,201,202) + and p.Type = 200 and p.String1 in ( )sql" + join(vector(addresses.size(), "?"), ",") + R"sql( ) - where r.Type in (200,201,202) + where r.Type = 200 and r.Last in (0,1) and r.Hash = r.String2 -- Only orig and r.Height between ? and ? From 153cbe3a9fa3bfaf7d004f140ac622bcb0fdc110 Mon Sep 17 00:00:00 2001 From: lostystyg Date: Wed, 26 Oct 2022 20:23:19 +0200 Subject: [PATCH 21/21] Events: full history for subscriber --- src/pocketdb/repositories/web/WebRpcRepository.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketdb/repositories/web/WebRpcRepository.cpp b/src/pocketdb/repositories/web/WebRpcRepository.cpp index f4caa9c5e..20005697e 100644 --- a/src/pocketdb/repositories/web/WebRpcRepository.cpp +++ b/src/pocketdb/repositories/web/WebRpcRepository.cpp @@ -6785,8 +6785,8 @@ namespace PocketDb and ru.Id = u.Id and ru.Last = 1 - where subs.Type in (302, 303) -- Ignoring unsubscribers? - and subs.Last = 1 + where subs.Type in (302, 303, 304) -- Ignoring unsubscribers? + and subs.Last in (0,1) and subs.String2 = ? and subs.Height > ? and (subs.Height < ? or (subs.Height = ? and subs.BlockNum < ?))