From 0068960aed4ca913a6b71b4cac96d1d8d4968bab Mon Sep 17 00:00:00 2001 From: erqan Date: Sat, 2 May 2015 16:57:00 +0300 Subject: [PATCH] changes getlasthave method for any possible group implementation on client side --- src/bitcoinrpc.cpp | 1 + src/twister.cpp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 6d2de73b..b8841cc5 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1316,6 +1316,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 4) ConvertTo(params[4]); if (strMethod == "newrtmsg" && n > 1) ConvertTo(params[1]); if (strMethod == "newrtmsg" && n > 2) ConvertTo(params[2]); + if (strMethod == "getlasthave" && n > 1) ConvertTo(params[1]); if (strMethod == "getposts" && n > 0) ConvertTo(params[0]); if (strMethod == "getposts" && n > 1) ConvertTo(params[1]); if (strMethod == "getposts" && n > 2) ConvertTo(params[2]); diff --git a/src/twister.cpp b/src/twister.cpp index 7232618c..f0bedcbf 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -2643,14 +2643,22 @@ Value getfollowing(const Array& params, bool fHelp) Value getlasthave(const Array& params, bool fHelp) { - if (fHelp || (params.size() != 1)) + if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "getlasthave \n" - "get last 'have' (higher post number) of each user user we follow"); - - string localUser = params[0].get_str(); + "getlasthave | [user1,user2...]\n" + "get last 'have' (higher post number) of each user local user follows.\n" + "if a groupname with an array is given, only those users' last 'have' values will be returned."); std::set following; + + string localUser = params[0].get_str(); + if (params.size() > 1) + { + Array userlist = params[1].get_array(); + for (unsigned int i = 0; i < userlist.size(); i++) + following.insert(userlist[i].get_str()); + } + else { LOCK(cs_twister); if( m_users.count(localUser) )