Merge pull request #476 from jl777/dev

fixed wrong port used by assetchains, which caused error many times, each with 250ms sleep
This commit is contained in:
jl777
2017-10-01 19:58:30 +03:00
committed by GitHub
4 changed files with 44 additions and 30 deletions

View File

@@ -127,6 +127,15 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
if (valRequest.isObject()) {
jreq.parse(valRequest);
if (!RPCAuthorized(authHeader.second)) {
LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", req->GetPeer().ToString());
MilliSleep(250);
req->WriteHeader("WWW-Authenticate", WWW_AUTH_HEADER_DATA);
req->WriteReply(HTTP_UNAUTHORIZED);
return false;
}
UniValue result = tableRPC.execute(jreq.strMethod, jreq.params);
// Send reply

View File

@@ -340,6 +340,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
sprintf(url,(char *)"http://127.0.0.1:%u",port);
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
//printf("postdata.(%s) USERPASS.(%s)\n",postdata,KMDUSERPASS);
//LogPrintf("komodo_issuemethod userpass.(%s) %s %s port.%u\n",userpass,method,params,port);
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
//retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0);
}
@@ -353,7 +354,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig
*kmdnotarized_heightp = 0;
if ( strcmp(dest,"KMD") == 0 )
{
port = BITCOIND_PORT;
port = 7771;
userpass = KMDUSERPASS;
}
else if ( strcmp(dest,"BTC") == 0 )
@@ -431,8 +432,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
if ( strcmp(dest,"KMD") == 0 )
{
if ( KMDUSERPASS[0] != 0 )
jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,BITCOIND_PORT);
//else jsonstr = _dex_getrawtransaction();
jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771);
else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok
}
else if ( strcmp(dest,"BTC") == 0 )

View File

@@ -1510,6 +1510,7 @@ void komodo_args()
extern int COINBASE_MATURITY;
komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1);
COINBASE_MATURITY = 1;
LogPrintf("ASSETCHAINS_PORT %s %u\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT);
}
ASSETCHAINS_NOTARIES = GetArg("-ac_notaries","");
komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str());

View File

@@ -1055,7 +1055,9 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
setTips.insert(item.second);
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex)
{
const CBlockIndex* pprev = item.second->pprev;
const CBlockIndex* pprev=0;
if ( item.second != 0 )
pprev = item.second->pprev;
if (pprev)
setTips.erase(pprev);
}
@@ -1064,14 +1066,16 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
setTips.insert(chainActive.Tip());
/* Construct the output array. */
UniValue res(UniValue::VARR);
UniValue res(UniValue::VARR); const CBlockIndex *forked;
BOOST_FOREACH(const CBlockIndex* block, setTips)
{
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("height", block->nHeight));
obj.push_back(Pair("hash", block->phashBlock->GetHex()));
const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight;
forked = chainActive.FindFork(block);
if ( forked != 0 )
{
const int branchLen = block->nHeight - forked->nHeight;
obj.push_back(Pair("branchlen", branchLen));
string status;
@@ -1095,7 +1099,7 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
status = "unknown";
}
obj.push_back(Pair("status", status));
}
res.push_back(obj);
}