MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / ReadFromDisk

Method ReadFromDisk

src/persistence/blockundo.cpp:74–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74bool CBlockUndo::ReadFromDisk(const CDiskBlockPos &pos, const uint256 &blockHash) {
75 // Open history file to read
76 CAutoFile filein = CAutoFile(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION);
77 if (!filein)
78 return ERRORMSG("CBlockUndo::ReadFromDisk : OpenBlockFile failed");
79
80 // Read block
81 uint256 hashChecksum;
82 try {
83 filein >> *this;
84 filein >> hashChecksum;
85 } catch (std::exception &e) {
86 return ERRORMSG("Deserialize or I/O error - %s", e.what());
87 }
88
89 // Verify checksum
90 CHashWriter hasher(SER_GETHASH, PROTOCOL_VERSION);
91 hasher << blockHash;
92 hasher << *this;
93
94 if (hashChecksum != hasher.GetHash())
95 return ERRORMSG("CBlockUndo::ReadFromDisk : Checksum mismatch");
96 return true;
97}
98
99string CBlockUndo::ToString() const {
100 string str;

Callers 3

DisconnectBlockFunction · 0.80
VerifyDBFunction · 0.80
getblockundoFunction · 0.80

Calls 4

CAutoFileClass · 0.85
OpenUndoFileFunction · 0.85
whatMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected