Merge pull request #164 from jl777/dPoW

DPoW
This commit is contained in:
jl777
2017-02-03 17:36:52 +02:00
committed by GitHub
3 changed files with 32 additions and 22 deletions

View File

@@ -3855,9 +3855,15 @@ void UnloadBlockIndex()
bool LoadBlockIndex() bool LoadBlockIndex()
{ {
extern int32_t KOMODO_LOADINGBLOCKS;
// Load block index from databases // Load block index from databases
KOMODO_LOADINGBLOCKS = 1;
if (!fReindex && !LoadBlockIndexDB()) if (!fReindex && !LoadBlockIndexDB())
{
KOMODO_LOADINGBLOCKS = 0;
return false; return false;
}
KOMODO_LOADINGBLOCKS = 0;
return true; return true;
} }
@@ -4343,31 +4349,35 @@ void static ProcessGetData(CNode* pfrom)
// Send block from disk // Send block from disk
CBlock block; CBlock block;
if (!ReadBlockFromDisk(block, (*mi).second)) if (!ReadBlockFromDisk(block, (*mi).second))
assert(!"cannot load block from disk");
if (inv.type == MSG_BLOCK)
pfrom->PushMessage("block", block);
else // MSG_FILTERED_BLOCK)
{ {
LOCK(pfrom->cs_filter); assert(!"cannot load block from disk");
if (pfrom->pfilter) }
else
{
if (inv.type == MSG_BLOCK)
pfrom->PushMessage("block", block);
else // MSG_FILTERED_BLOCK)
{ {
CMerkleBlock merkleBlock(block, *pfrom->pfilter); LOCK(pfrom->cs_filter);
pfrom->PushMessage("merkleblock", merkleBlock); if (pfrom->pfilter)
// CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see {
// This avoids hurting performance by pointlessly requiring a round-trip CMerkleBlock merkleBlock(block, *pfrom->pfilter);
// Note that there is currently no way for a node to request any single transactions we didn't send here - pfrom->PushMessage("merkleblock", merkleBlock);
// they must either disconnect and retry or request the full block. // CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see
// Thus, the protocol spec specified allows for us to provide duplicate txn here, // This avoids hurting performance by pointlessly requiring a round-trip
// however we MUST always provide at least what the remote peer needs // Note that there is currently no way for a node to request any single transactions we didn't send here -
typedef std::pair<unsigned int, uint256> PairType; // they must either disconnect and retry or request the full block.
BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn) // Thus, the protocol spec specified allows for us to provide duplicate txn here,
// however we MUST always provide at least what the remote peer needs
typedef std::pair<unsigned int, uint256> PairType;
BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn)
if (!pfrom->setInventoryKnown.count(CInv(MSG_TX, pair.second))) if (!pfrom->setInventoryKnown.count(CInv(MSG_TX, pair.second)))
pfrom->PushMessage("tx", block.vtx[pair.first]); pfrom->PushMessage("tx", block.vtx[pair.first]);
} }
// else // else
// no response // no response
}
} }
// Trigger the peer node to send a getblocks request for the next batch of inventory // Trigger the peer node to send a getblocks request for the next batch of inventory
if (inv.hash == pfrom->hashContinue) if (inv.hash == pfrom->hashContinue)
{ {

View File

@@ -100,7 +100,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
#define ASSETCHAINS_MINHEIGHT 100 #define ASSETCHAINS_MINHEIGHT 100
#define KOMODO_ELECTION_GAP 2000 #define KOMODO_ELECTION_GAP 2000
#define ROUNDROBIN_DELAY 58 #define ROUNDROBIN_DELAY 60
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE;
extern char ASSETCHAINS_SYMBOL[16]; extern char ASSETCHAINS_SYMBOL[16];
extern std::string NOTARY_PUBKEY; extern std::string NOTARY_PUBKEY;

View File

@@ -114,7 +114,7 @@ extern int32_t KOMODO_CHOSEN_ONE;
#define KOMODO_ELECTION_GAP 2000 #define KOMODO_ELECTION_GAP 2000
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height); int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height);
int32_t KOMODO_LOADINGBLOCKS;
extern std::string NOTARY_PUBKEY; extern std::string NOTARY_PUBKEY;
@@ -167,7 +167,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
// Check proof of work matches claimed amount // Check proof of work matches claimed amount
if ( UintToArith256(hash) > bnTarget ) if ( UintToArith256(hash) > bnTarget )
{ {
if ( nonzpkeys > 0 && height > 182500 && KOMODO_REWIND == 0 && komodo_chainactive(height) != 0 ) if ( KOMODO_LOADINGBLOCKS == 0 && height > 182507 && KOMODO_REWIND == 0 )//&& komodo_chainactive(height) != 0 && nonzpkeys > 0
{ {
int32_t i; int32_t i;
for (i=31; i>=0; i--) for (i=31; i>=0; i--)