Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/0.20' into 0.21.todo
Browse files Browse the repository at this point in the history
  • Loading branch information
lostystyg committed Apr 21, 2022
2 parents 7775531 + 1e8acf7 commit b049782
Show file tree
Hide file tree
Showing 13 changed files with 441 additions and 1,026 deletions.
2 changes: 1 addition & 1 deletion src/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ void SetupServerArgs(NodeContext& node)
argsman.AddArg("-sqltimeout", strprintf("Timeout for ReadOnly sql querys (default: %ds)", 10), ArgsManager::ALLOW_ANY, OptionsCategory::SQLITE);
argsman.AddArg("-sqlsharedcache", strprintf("Experimental: enable shared cache for sqlite connections (default: disabled)"), ArgsManager::ALLOW_ANY, OptionsCategory::SQLITE);
argsman.AddArg("-sqlcachesize", strprintf("Experimental: Cache size for SQLite connection in megabytes (default: %d mb)", 5), ArgsManager::ALLOW_ANY, OptionsCategory::SQLITE);
argsman.AddArg("-withoutweb", strprintf("Disable WEB part of database (default: %u)", false), ArgsManager::ALLOW_ANY, OptionsCategory::SQLITE);


#if HAVE_DECL_DAEMON
Expand Down Expand Up @@ -1641,7 +1642,8 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA

PocketWeb::PocketFrontendInst.Init();

if (args.GetBoolArg("-api", DEFAULT_API_ENABLE))
// Always start WEB DB building thread
if (!args.GetBoolArg("-withoutweb", false))
PocketServices::WebPostProcessorInst.Start(threadGroup);

// ********************************************************* Step 4b: Additional settings
Expand Down
4 changes: 2 additions & 2 deletions src/pocketdb/consensus/Reputation.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ namespace PocketConsensus
{ 1180000, 0, [](int height) { return make_shared<ReputationConsensus_checkpoint_1180000>(height); }},
{ 1324655, 65000, [](int height) { return make_shared<ReputationConsensus_checkpoint_1324655>(height); }},
{ 1324655, 75000, [](int height) { return make_shared<ReputationConsensus_checkpoint_1324655_2>(height); }},
{ 1680000, 761000, [](int height) { return make_shared<ReputationConsensus_checkpoint_scores_content_author_reducing_impact>(height); }},
{ 1680000, 772000, [](int height) { return make_shared<ReputationConsensus_checkpoint_scores_comment_author_disable_impact>(height); }},
{ 1700000, 761000, [](int height) { return make_shared<ReputationConsensus_checkpoint_scores_content_author_reducing_impact>(height); }},
{ 1700000, 772000, [](int height) { return make_shared<ReputationConsensus_checkpoint_scores_comment_author_disable_impact>(height); }},
};
public:
shared_ptr<ReputationConsensus> Instance(int height)
Expand Down
2 changes: 1 addition & 1 deletion src/pocketdb/consensus/moderation/Flag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace PocketConsensus
private:
const vector<ConsensusCheckpoint<ModerationFlagConsensus>> m_rules = {
{ 0, -1, [](int height) { return make_shared<ModerationFlagConsensus>(height); }},
{ 1680000, 761000, [](int height) { return make_shared<ModerationFlagConsensus_checkpoint_enable>(height); }},
{ 1700000, 761000, [](int height) { return make_shared<ModerationFlagConsensus_checkpoint_enable>(height); }},
};
public:
shared_ptr<ModerationFlagConsensus> Instance(int height)
Expand Down
746 changes: 265 additions & 481 deletions src/pocketdb/repositories/web/SearchRepository.cpp

Large diffs are not rendered by default.

15 changes: 6 additions & 9 deletions src/pocketdb/repositories/web/SearchRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,12 @@ namespace PocketDb
vector<int64_t> SearchUsersOld(const SearchRequest& request);
vector<int64_t> SearchUsers(const string& keyword);

UniValue GetRecomendedAccountsBySubscriptions(const string& address, int cntOut = 10);
UniValue GetRecomendedAccountsByScoresOnSimilarAccounts(const string& address, const vector<int>& contentTypes, int nHeight, int depth = 1000, int cntOut = 10);
UniValue GetRecomendedAccountsByScoresFromAddress(const string& address, const vector<int>& contentTypes, int nHeight, int depth = 1000, int cntOut = 10);
UniValue GetRecomendedAccountsByTags(const vector<string>& tags, int nHeight, int depth = 1000, int cntOut = 10);
UniValue GetRecomendedContentsByScoresOnSimilarContents(const string& contentid, const vector<int>& contentTypes, int depth = 1000, int cntOut = 10);
UniValue GetRecomendedContentsByScoresFromAddress(const string& address, const vector<int>& contentTypes, int nHeight, int depth = 1000, int cntOut = 10);

vector<string> GetRecommendedAccountByAddressSubscriptions(const string& address, string& addressExclude, const vector<int>& contentTypes, const string& lang, int cntOut, int nHeight, int depth = 129600 /* about 3 month */, int cntSubscriptions = 100);
vector<int64_t> GetRecommendedContentByAddressSubscriptions(const string& contentAddress, string& address, const vector<int>& contentTypes, const string& lang, int cntOut, int nHeight, int depth = 129600 /* about 3 month */, int cntSubscriptions = 100);
//TODO (o1q): remove it
vector<string> GetRecommendedAccountByAddressSubscriptionsOld(const string& address, string& addressExclude, const vector<int>& contentTypes, const string& lang, int cntOut, int nHeight, int depth = 129600 /* about 3 month */, int cntSubscriptions = 100);
vector<int64_t> GetRecommendedContentByAddressSubscriptionsOld(const string& contentAddress, string& address, const vector<int>& contentTypes, const string& lang, int cntOut, int nHeight, int depth = 129600 /* about 3 month */, int cntSubscriptions = 100);

vector<string> GetRecommendedAccountByAddressSubscriptions(const string& address, string& addressExclude, const vector<int>& contentTypes, const string& lang, int cntOut, int nHeight, int depth = 129600 /* about 3 month */);
vector<int64_t> GetRecommendedContentByAddressSubscriptions(const string& contentAddress, string& address, const vector<int>& contentTypes, const string& lang, int cntOut, int nHeight, int depth = 129600 /* about 3 month */);
vector<int64_t> GetRandomContentByAddress(const string& contentAddress, const vector<int>& contentTypes, const string& lang, int cntOut);
};

Expand Down
12 changes: 6 additions & 6 deletions src/pocketdb/repositories/web/WebRpcRepository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2826,27 +2826,27 @@ namespace PocketDb

string langFilter;
if (!lang.empty())
langFilter += " join Payload p indexed by Payload_String1_TxHash on p.TxHash = t.Hash and p.String1 = ? ";
langFilter += " cross join Payload p indexed by Payload_String1_TxHash on p.TxHash = t.Hash and p.String1 = ? ";

string sql = R"sql(
select t.Id
from Transactions t indexed by Transactions_Last_Id_Height
from Transactions t indexed by Transactions_Type_Last_Height_Id
join Ratings cr indexed by Ratings_Type_Id_Last_Value
cross join Ratings cr indexed by Ratings_Type_Id_Last_Value
on cr.Type = 2 and cr.Last = 1 and cr.Id = t.Id and cr.Value > 0
)sql" + langFilter + R"sql(
join Transactions u indexed by Transactions_Type_Last_String1_Height_Id
cross join Transactions u indexed by Transactions_Type_Last_String1_Height_Id
on u.Type in (100) and u.Last = 1 and u.Height > 0 and u.String1 = t.String1
left join Ratings ur indexed by Ratings_Type_Id_Last_Height
on ur.Type = 0 and ur.Last = 1 and ur.Id = u.Id
where t.Type in )sql" + contentTypesWhere + R"sql(
and t.Last = 1
and t.String3 is null
--and t.String3 is null
and t.Height > ?
and t.Height <= ?
Expand Down Expand Up @@ -2884,7 +2884,7 @@ namespace PocketDb
) )sql";
}

sql += " order by t.Id desc ";
sql += " order by cr.Value desc ";
sql += " limit ? ";

// ---------------------------------------------
Expand Down
16 changes: 9 additions & 7 deletions src/pocketdb/web/PocketContentRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,19 @@ namespace PocketWeb::PocketWebRpc
}
}

// feed's address
if (request.params.size() > 10)
{
RPCTypeCheckArgument(request.params[10], UniValue::VSTR);
address_feed = request.params[10].get_str();
if (!address_feed.empty())
// feed's address
if (request.params[10].isStr())
{
CTxDestination dest = DecodeDestination(address_feed);
address_feed = request.params[10].get_str();
if (!address_feed.empty())
{
CTxDestination dest = DecodeDestination(address_feed);

if (!IsValidDestination(dest))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Pocketcoin address: ") + address_feed);
if (!IsValidDestination(dest))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Pocketcoin address: ") + address_feed);
}
}
}
}
Expand Down
9 changes: 0 additions & 9 deletions src/pocketdb/web/PocketRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ static const CRPCCommand commands[] =
{"search", "searchusers", &SearchUsers, {"keyword", "fieldtypes", "orderbyrank"}},

// Recomendations
// TODO (o1q): Remove below methods when the client gui switches to new methods
{"search", "getrecomendedaccountsbysubscriptions", &GetRecomendedAccountsBySubscriptions, {"address", "count"}},
{"search", "getrecomendedaccountsbyscoresonsimilaraccounts", &GetRecomendedAccountsByScoresOnSimilarAccounts, {"address", "contenttypes", "height", "depth", "count"}},
{"search", "getrecomendedaccountsbyscoresfromaddress", &GetRecomendedAccountsByScoresFromAddress, {"address", "contenttypes", "height", "depth", "count"}},
{"search", "getrecomendedaccountsbytags", &GetRecomendedAccountsByTags, {"tags", "count"}},
{"search", "getrecomendedcontentsbyscoresonsimilarcontents", &GetRecomendedContentsByScoresOnSimilarContents, {"contentid", "contenttypes", "depth", "count"}},
{"search", "getrecomendedcontentsbyscoresfromaddress", &GetRecomendedContentsByScoresFromAddress, {"address", "contenttypes", "height", "depth", "count"}},
// TODO (o1q): Remove above methods when the client gui switches to new (below) methods
{"search", "getrecommendedcontentbycontentid", &GetRecommendedContentByContentId, {"contentid", "address", "contenttypes", "lang", "count"}},
{"search", "getrecommendedcontentbyaddress", &GetRecommendedContentByAddress, {"address", "addressExclude", "contenttypes", "lang", "count"}},
{"search", "getrecommendedaccountbyaddress", &GetRecommendedAccountByAddress, {"address", "addressExclude", "contenttypes", "lang", "count"}},

Expand Down
Loading

0 comments on commit b049782

Please sign in to comment.