From 395f10cf91a0e08e6e4f8dbec64a5f08f82972cb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Apr 2018 21:09:51 +0300 Subject: [PATCH] Test --- src/main.cpp | 3 +++ src/main.h | 2 +- src/miner.cpp | 41 +++++++++++++++++++++-------------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index af10d91be..c1ca3f9a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,6 +56,7 @@ extern uint8_t NOTARY_PUBKEY33[33]; extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN; int32_t KOMODO_NEWBLOCKS; int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); +void komodo_broadcast(CBlock *pblock,int32_t limit); BlockMap mapBlockIndex; CChain chainActive; @@ -3218,6 +3219,8 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1; LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001); + if ( ASSETHCHAINS_SYMBOL[0] == 0 ) + komodo_broadcast(pblock,8); return true; } diff --git a/src/main.h b/src/main.h index 956d8351e..ef46cd83d 100644 --- a/src/main.h +++ b/src/main.h @@ -94,7 +94,7 @@ static const unsigned int MAX_HEADERS_RESULTS = 160; * Larger windows tolerate larger download speed differences between peer, but increase the potential * degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning * harder). We'll probably want to make this a per-peer adaptive value at some point. */ -static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024 * 2; +static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024; /** Time to wait (in seconds) between writing blocks/block index to disk. */ static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60; /** Time to wait (in seconds) between flushing chainstate to disk. */ diff --git a/src/miner.cpp b/src/miner.cpp index d9da98f3c..25c71918d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -584,6 +584,26 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) return CreateNewBlock(scriptPubKey); } +void komodo_broadcast(CBlock *pblock,int32_t limit) +{ + int32_t n = 1; + //fprintf(stderr,"broadcast new block t.%u\n",(uint32_t)time(NULL)); + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if ( pnode->hSocket == INVALID_SOCKET ) + continue; + if ( (rand() % n) == 0 ) + { + pnode->PushMessage("block", *pblock); + if ( n++ > limit ) + break; + } + } + } + //fprintf(stderr,"finished broadcast new block t.%u\n",(uint32_t)time(NULL)); +} static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) #else @@ -635,26 +655,7 @@ static bool ProcessBlockFound(CBlock* pblock) return error("KomodoMiner: ProcessNewBlock, block not accepted"); TrackMinedBlock(pblock->GetHash()); - //if ( vNodes.size() < KOMODO_LIMITED_NETWORKSIZE*2 ) - { - int32_t n = 1; - //fprintf(stderr,"broadcast new block t.%u\n",(uint32_t)time(NULL)); - { - LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) - { - if ( pnode->hSocket == INVALID_SOCKET ) - continue; - if ( (rand() % n) == 0 ) - { - pnode->PushMessage("block", *pblock); - if ( n++ > 8 ) - break; - } - } - } - //fprintf(stderr,"finished broadcast new block t.%u\n",(uint32_t)time(NULL)); - } + komodo_broadcast(pblock,16); return true; }