private void CheckState(Block block, ChainedBlock pindexPrev) { uint256 hashProof = 0, hashTarget = 0; uint256 hashBlock = block.GetHash(); if (!block.IsProofOfStake()) { return; // error("CheckStake() : %s is not a proof-of-stake block", hashBlock.GetHex()); } // verify hash target and signature of coinstake tx if (!BlockValidator.CheckProofOfStake(this.chainIndex, this.chainIndex, this.chainIndex, pindexPrev, block.Transactions[1], block.Header.Bits.ToCompact(), out hashProof, out hashTarget)) { return; // error("CheckStake() : proof-of-stake checking failed"); } //// debug print //LogPrintf("CheckStake() : new proof-of-stake block found \n hash: %s \nproofhash: %s \ntarget: %s\n", hashBlock.GetHex(), proofHash.GetHex(), hashTarget.GetHex()); //LogPrintf("%s\n", pblock->ToString()); //LogPrintf("out %s\n", FormatMoney(pblock->vtx[1].GetValueOut())); // Found a solution if (block.Header.HashPrevBlock != this.chainIndex.Tip.HashBlock) { return; // error("CheckStake() : generated block is stale"); } // Process this block the same as if we had received it from another node //this.BlockSyncHub.ReceiveBlocks.TryAdd(new HubReceiveBlockItem {Block = block}); ChainedBlock chainedBlock; if (this.blockReceiver.ProcessBlock(null, block, out chainedBlock)) { if (chainedBlock.ChainWork > this.chainIndex.Tip.ChainWork) { // Track how many getdata requests this block gets if (!this.BlockSyncHub.RequestCount.TryAdd(hashBlock, new RequestCounter())) { throw new MinedBlockException(); } // add to alt tips if (!this.minerService.MinedBlocks.TryAdd(chainedBlock, block)) { throw new MinedBlockException(); } // add to wallet //this.walletWorker.AddBlock(block); // let the wallet processes the transaction //this.Cancellation.Token.WaitHandle.WaitOne(1000); // broadcast it this.BlockSyncHub.BroadcastBlockInventory(new[] { hashBlock }); } } }