Changeset View
Changeset View
Standalone View
Standalone View
src/primitives/block.h
Show All 22 Lines | public: | ||||
// header | // header | ||||
int32_t nVersion; | int32_t nVersion; | ||||
uint256 hashPrevBlock; | uint256 hashPrevBlock; | ||||
uint256 hashMerkleRoot; | uint256 hashMerkleRoot; | ||||
uint32_t nTime; | uint32_t nTime; | ||||
uint32_t nBits; | uint32_t nBits; | ||||
uint32_t nNonce; | uint32_t nNonce; | ||||
// local header metadata (never include these in CBlockHeader serialization) | |||||
uint64_t nTimeReceived; // microseconds | |||||
deadalnix: This is supposed to contains the block data themselves. The CBlockIndex or whatever its name is… | |||||
jasonbcoxAuthorUnsubmitted Done Inline ActionsConceptually, this makes sense. I'll keep digging to see if I can remove this without clobbering the implementation more so than this line already does. jasonbcox: Conceptually, this makes sense. I'll keep digging to see if I can remove this without… | |||||
jasonbcoxAuthorUnsubmitted Done Inline ActionsDid some digging and confirmed it's possible to remove this from block.h. My initial impression is to add nTimeReceived as a param to ProcessNewBlock(). This way, once the index pointer is acquired, nTimeReceived can be set. And this operation should be done for all new blocks received. jasonbcox: Did some digging and confirmed it's possible to remove this from block.h. My initial… | |||||
CBlockHeader() { SetNull(); } | CBlockHeader() { SetNull(); } | ||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITE(this->nVersion); | READWRITE(this->nVersion); | ||||
READWRITE(hashPrevBlock); | READWRITE(hashPrevBlock); | ||||
READWRITE(hashMerkleRoot); | READWRITE(hashMerkleRoot); | ||||
READWRITE(nTime); | READWRITE(nTime); | ||||
READWRITE(nBits); | READWRITE(nBits); | ||||
READWRITE(nNonce); | READWRITE(nNonce); | ||||
} | } | ||||
void SetNull() { | void SetNull() { | ||||
nVersion = 0; | nVersion = 0; | ||||
hashPrevBlock.SetNull(); | hashPrevBlock.SetNull(); | ||||
hashMerkleRoot.SetNull(); | hashMerkleRoot.SetNull(); | ||||
nTime = 0; | nTime = 0; | ||||
nTimeReceived = 0; | |||||
nBits = 0; | nBits = 0; | ||||
nNonce = 0; | nNonce = 0; | ||||
} | } | ||||
bool IsNull() const { return (nBits == 0); } | bool IsNull() const { return (nBits == 0); } | ||||
uint256 GetHash() const; | uint256 GetHash() const; | ||||
Show All 30 Lines | public: | ||||
} | } | ||||
CBlockHeader GetBlockHeader() const { | CBlockHeader GetBlockHeader() const { | ||||
CBlockHeader block; | CBlockHeader block; | ||||
block.nVersion = nVersion; | block.nVersion = nVersion; | ||||
block.hashPrevBlock = hashPrevBlock; | block.hashPrevBlock = hashPrevBlock; | ||||
block.hashMerkleRoot = hashMerkleRoot; | block.hashMerkleRoot = hashMerkleRoot; | ||||
block.nTime = nTime; | block.nTime = nTime; | ||||
block.nTimeReceived = nTimeReceived; | |||||
block.nBits = nBits; | block.nBits = nBits; | ||||
block.nNonce = nNonce; | block.nNonce = nNonce; | ||||
return block; | return block; | ||||
} | } | ||||
std::string ToString() const; | std::string ToString() const; | ||||
}; | }; | ||||
Show All 27 Lines |
This is supposed to contains the block data themselves. The CBlockIndex or whatever its name is is the right thing for these kind of infos.