mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Moved ReadBlockFromDisk implementation to main.cpp
This commit is contained in:
parent
7db120d531
commit
8031399494
24
src/main.cpp
24
src/main.cpp
@ -1172,6 +1172,30 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
||||||
|
{
|
||||||
|
block.SetNull();
|
||||||
|
|
||||||
|
// Open history file to read
|
||||||
|
CAutoFile filein = CAutoFile(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
|
||||||
|
if (!filein)
|
||||||
|
return error("ReadBlockFromDisk(CBlock&, CDiskBlockPos&) : OpenBlockFile failed");
|
||||||
|
|
||||||
|
// Read block
|
||||||
|
try {
|
||||||
|
filein >> block;
|
||||||
|
}
|
||||||
|
catch (std::exception &e) {
|
||||||
|
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the header
|
||||||
|
if (!CheckProofOfWork(block.GetHash(), block.nBits))
|
||||||
|
return error("ReadBlockFromDisk(CBlock&, CDiskBlockPos&) : errors in block header");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
|
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
|
||||||
{
|
{
|
||||||
if (!ReadBlockFromDisk(block, pindex->GetBlockPos()))
|
if (!ReadBlockFromDisk(block, pindex->GetBlockPos()))
|
||||||
|
25
src/main.h
25
src/main.h
@ -726,30 +726,7 @@ public:
|
|||||||
|
|
||||||
/** Functions for disk access for blocks */
|
/** Functions for disk access for blocks */
|
||||||
bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos);
|
bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos);
|
||||||
inline bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos);
|
||||||
{
|
|
||||||
block.SetNull();
|
|
||||||
|
|
||||||
// Open history file to read
|
|
||||||
CAutoFile filein = CAutoFile(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
|
|
||||||
if (!filein)
|
|
||||||
return error("ReadBlockFromDisk(CBlock&, CDiskBlockPos&) : OpenBlockFile failed");
|
|
||||||
|
|
||||||
// Read block
|
|
||||||
try {
|
|
||||||
filein >> block;
|
|
||||||
}
|
|
||||||
catch (std::exception &e) {
|
|
||||||
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the header
|
|
||||||
if (!CheckProofOfWork(block.GetHash(), block.nBits))
|
|
||||||
return error("ReadBlockFromDisk(CBlock&, CDiskBlockPos&) : errors in block header");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
|
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user