|
|
|
@ -180,6 +180,9 @@ bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, b
@@ -180,6 +180,9 @@ bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, b
|
|
|
|
|
bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew); |
|
|
|
|
/** Find the best known block, and make it the tip of the block chain */ |
|
|
|
|
bool ConnectBestBlock(CValidationState &state); |
|
|
|
|
|
|
|
|
|
void UpdateTime(CBlockHeader& block, const CBlockIndex* pindexPrev); |
|
|
|
|
|
|
|
|
|
/** Create a new block index entry for a given block hash */ |
|
|
|
|
CBlockIndex * InsertBlockIndex(uint256 hash); |
|
|
|
|
/** Verify a signature */ |
|
|
|
@ -576,69 +579,6 @@ public:
@@ -576,69 +579,6 @@ public:
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Nodes collect new transactions into a block, hash them into a hash tree,
|
|
|
|
|
* and scan through nonce values to make the block's hash satisfy proof-of-work |
|
|
|
|
* requirements. When they solve the proof-of-work, they broadcast the block |
|
|
|
|
* to everyone and the block is added to the block chain. The first transaction |
|
|
|
|
* in the block is a special one that creates a new coin owned by the creator |
|
|
|
|
* of the block. |
|
|
|
|
*/ |
|
|
|
|
class CBlockHeader |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
// header
|
|
|
|
|
static const int CURRENT_VERSION=2; |
|
|
|
|
int nVersion; |
|
|
|
|
uint256 hashPrevBlock; |
|
|
|
|
uint256 hashMerkleRoot; |
|
|
|
|
unsigned int nTime; |
|
|
|
|
unsigned int nBits; |
|
|
|
|
unsigned int nNonce; |
|
|
|
|
|
|
|
|
|
CBlockHeader() |
|
|
|
|
{ |
|
|
|
|
SetNull(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IMPLEMENT_SERIALIZE |
|
|
|
|
( |
|
|
|
|
READWRITE(this->nVersion); |
|
|
|
|
nVersion = this->nVersion; |
|
|
|
|
READWRITE(hashPrevBlock); |
|
|
|
|
READWRITE(hashMerkleRoot); |
|
|
|
|
READWRITE(nTime); |
|
|
|
|
READWRITE(nBits); |
|
|
|
|
READWRITE(nNonce); |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
void SetNull() |
|
|
|
|
{ |
|
|
|
|
nVersion = CBlockHeader::CURRENT_VERSION; |
|
|
|
|
hashPrevBlock = 0; |
|
|
|
|
hashMerkleRoot = 0; |
|
|
|
|
nTime = 0; |
|
|
|
|
nBits = 0; |
|
|
|
|
nNonce = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool IsNull() const |
|
|
|
|
{ |
|
|
|
|
return (nBits == 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint256 GetHash() const |
|
|
|
|
{ |
|
|
|
|
return Hash(BEGIN(nVersion), END(nNonce)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int64 GetBlockTime() const |
|
|
|
|
{ |
|
|
|
|
return (int64)nTime; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UpdateTime(const CBlockIndex* pindexPrev); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class CBlock : public CBlockHeader |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|