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()) { if (valRequest.isObject()) {
jreq.parse(valRequest); 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); UniValue result = tableRPC.execute(jreq.strMethod, jreq.params);
// Send reply // 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(url,(char *)"http://127.0.0.1:%u",port);
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
//printf("postdata.(%s) USERPASS.(%s)\n",postdata,KMDUSERPASS); //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); retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
//retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); //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; *kmdnotarized_heightp = 0;
if ( strcmp(dest,"KMD") == 0 ) if ( strcmp(dest,"KMD") == 0 )
{ {
port = BITCOIND_PORT; port = 7771;
userpass = KMDUSERPASS; userpass = KMDUSERPASS;
} }
else if ( strcmp(dest,"BTC") == 0 ) 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 ( strcmp(dest,"KMD") == 0 )
{ {
if ( KMDUSERPASS[0] != 0 ) if ( KMDUSERPASS[0] != 0 )
jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,BITCOIND_PORT); jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771);
//else jsonstr = _dex_getrawtransaction();
else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok
} }
else if ( strcmp(dest,"BTC") == 0 ) else if ( strcmp(dest,"BTC") == 0 )

View File

@@ -1510,6 +1510,7 @@ void komodo_args()
extern int COINBASE_MATURITY; extern int COINBASE_MATURITY;
komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1);
COINBASE_MATURITY = 1; COINBASE_MATURITY = 1;
LogPrintf("ASSETCHAINS_PORT %s %u\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT);
} }
ASSETCHAINS_NOTARIES = GetArg("-ac_notaries",""); ASSETCHAINS_NOTARIES = GetArg("-ac_notaries","");
komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str()); 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); setTips.insert(item.second);
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) 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) if (pprev)
setTips.erase(pprev); setTips.erase(pprev);
} }
@@ -1064,38 +1066,40 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
setTips.insert(chainActive.Tip()); setTips.insert(chainActive.Tip());
/* Construct the output array. */ /* Construct the output array. */
UniValue res(UniValue::VARR); UniValue res(UniValue::VARR); const CBlockIndex *forked;
BOOST_FOREACH(const CBlockIndex* block, setTips) BOOST_FOREACH(const CBlockIndex* block, setTips)
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("height", block->nHeight)); obj.push_back(Pair("height", block->nHeight));
obj.push_back(Pair("hash", block->phashBlock->GetHex())); obj.push_back(Pair("hash", block->phashBlock->GetHex()));
forked = chainActive.FindFork(block);
if ( forked != 0 )
{
const int branchLen = block->nHeight - forked->nHeight;
obj.push_back(Pair("branchlen", branchLen));
const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight; string status;
obj.push_back(Pair("branchlen", branchLen)); if (chainActive.Contains(block)) {
// This block is part of the currently active chain.
string status; status = "active";
if (chainActive.Contains(block)) { } else if (block->nStatus & BLOCK_FAILED_MASK) {
// This block is part of the currently active chain. // This block or one of its ancestors is invalid.
status = "active"; status = "invalid";
} else if (block->nStatus & BLOCK_FAILED_MASK) { } else if (block->nChainTx == 0) {
// This block or one of its ancestors is invalid. // This block cannot be connected because full block data for it or one of its parents is missing.
status = "invalid"; status = "headers-only";
} else if (block->nChainTx == 0) { } else if (block->IsValid(BLOCK_VALID_SCRIPTS)) {
// This block cannot be connected because full block data for it or one of its parents is missing. // This block is fully validated, but no longer part of the active chain. It was probably the active block once, but was reorganized.
status = "headers-only"; status = "valid-fork";
} else if (block->IsValid(BLOCK_VALID_SCRIPTS)) { } else if (block->IsValid(BLOCK_VALID_TREE)) {
// This block is fully validated, but no longer part of the active chain. It was probably the active block once, but was reorganized. // The headers for this block are valid, but it has not been validated. It was probably never part of the most-work chain.
status = "valid-fork"; status = "valid-headers";
} else if (block->IsValid(BLOCK_VALID_TREE)) { } else {
// The headers for this block are valid, but it has not been validated. It was probably never part of the most-work chain. // No clue.
status = "valid-headers"; status = "unknown";
} else { }
// No clue. obj.push_back(Pair("status", status));
status = "unknown";
} }
obj.push_back(Pair("status", status));
res.push_back(obj); res.push_back(obj);
} }