From 7182f1bad89616ce9dbf56936aa5917a6e3229ba Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Sun, 6 Oct 2013 22:29:17 -0300 Subject: [PATCH] getlasthave --- src/bitcoinrpc.cpp | 1 + src/bitcoinrpc.h | 1 + src/twister.cpp | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index e90c8416..ebfecdd5 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -251,6 +251,7 @@ static const CRPCCommand vRPCCommands[] = { "follow", &follow, false, true }, { "unfollow", &unfollow, false, true }, { "getfollowing", &getfollowing, false, true }, + { "getlasthave", &getlasthave, false, true }, { "listusernamespartial", &listusernamespartial, false, true }, { "getdefaultuser", &getdefaultuser, false, true }, { "setdefaultuser", &setdefaultuser, false, true }, diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h index d05d1c4d..60db29e3 100644 --- a/src/bitcoinrpc.h +++ b/src/bitcoinrpc.h @@ -203,6 +203,7 @@ extern json_spirit::Value getspammsg(const json_spirit::Array& params, bool fHel extern json_spirit::Value follow(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value unfollow(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getfollowing(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getlasthave(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value listusernamespartial(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getdefaultuser(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value setdefaultuser(const json_spirit::Array& params, bool fHelp); diff --git a/src/twister.cpp b/src/twister.cpp index f51aa692..ea254071 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -1164,6 +1164,21 @@ Value getfollowing(const Array& params, bool fHelp) return ret; } +Value getlasthave(const Array& params, bool fHelp) +{ + if (fHelp || (params.size() != 0)) + throw runtime_error( + "getfollowing\n" + "get last 'have' (higher post number) of each user user we follow"); + + Object ret; + BOOST_FOREACH(string username, m_following) { + ret.push_back(Pair(username,lastPostKfromTorrent(username))); + } + + return ret; +} + Value listusernamespartial(const Array& params, bool fHelp) { if (fHelp || (params.size() != 2))