From c66eb36d51a64b511b75d2eda2eaf4820595ca01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 27 Jul 2018 01:12:00 -1100 Subject: [PATCH] Add pause if scriptcheckqueue isn't idle --- src/cc/CCassets.h | 2 ++ src/cc/CCassetstx.cpp | 8 ++++++++ src/main.cpp | 8 ++++++++ src/rpcserver.cpp | 2 ++ src/rpcserver.h | 2 ++ src/wallet/rpcwallet.cpp | 21 +++++++++++++++++++++ 6 files changed, 43 insertions(+) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index 77e3e6313..9a0f2a0ea 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -50,6 +50,8 @@ bool AssetExactAmounts(struct CCcontract_info *cp,int64_t &inputs,int32_t starti int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); int64_t AddAssetInputs(CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs); UniValue AssetOrders(uint256 tokenid); +UniValue AssetInfo(uint256 tokenid); +UniValue AssetList(); std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description); std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total); std::string CreateBuyOffer(int64_t txfee,int64_t bidamount,uint256 assetid,int64_t pricetotal); diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index d5a0b4999..26a2682da 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -57,6 +57,14 @@ int64_t GetAssetBalance(CPubKey pk,uint256 tokenid) return(AddAssetInputs(cp,mtx,pk,tokenid,0,0)); } +UniValue AssetList(uint256 refassetid) +{ +} + +UniValue AssetInfo() +{ +} + UniValue AssetOrders(uint256 refassetid) { static uint256 zero; diff --git a/src/main.cpp b/src/main.cpp index ca64a9130..66d7f89fa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2825,6 +2825,14 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin CBlockUndo blockundo; + if ( ASSETCHAINS_CC != 0 ) + { + if ( pqueue->IsIdle() == 0 ) + { + fprintf(stderr,"scriptcheckqueue isnt idle\n"); + sleep(1); + } + } CCheckQueueControl control(fExpensiveChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL); int64_t nTimeStart = GetTimeMicros(); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index c31204d29..1e665cea5 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -371,6 +371,8 @@ static const CRPCCommand vRPCCommands[] = { "dice", "diceaddress", &diceaddress, true }, /* tokens */ + { "tokens", "tokeninfo", &tokeninfo, true }, + { "tokens", "tokenlist", &tokenlist, true }, { "tokens", "tokenorders", &tokenorders, true }, { "tokens", "tokenaddress", &tokenaddress, true }, { "tokens", "tokenbalance", &tokenbalance, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 17b6bf812..2b82e6e64 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -208,6 +208,8 @@ extern UniValue submitblock(const UniValue& params, bool fHelp); extern UniValue estimatefee(const UniValue& params, bool fHelp); extern UniValue estimatepriority(const UniValue& params, bool fHelp); extern UniValue coinsupply(const UniValue& params, bool fHelp); +extern UniValue tokeninfo(const UniValue& params, bool fHelp); +extern UniValue tokenlist(const UniValue& params, bool fHelp); extern UniValue tokenorders(const UniValue& params, bool fHelp); extern UniValue tokenbalance(const UniValue& params, bool fHelp); extern UniValue tokenaddress(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f2811260b..e06e4292e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5122,6 +5122,27 @@ UniValue dicebet(const UniValue& params, bool fHelp) return(result); } +UniValue tokenlist(const UniValue& params, bool fHelp) +{ + uint256 tokenid; + if ( fHelp || params.size() > 0 ) + throw runtime_error("tokenlist\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + return(AssetList()); +} + +UniValue tokeninfo(const UniValue& params, bool fHelp) +{ + uint256 tokenid; + if ( fHelp || params.size() != 1 ) + throw runtime_error("tokeninfo tokenid\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + tokenid = Parseuint256((char *)params[0].get_str().c_str()); + return(AssetInfo(tokenid)); +} + UniValue tokenorders(const UniValue& params, bool fHelp) { uint256 tokenid;