| 1983 | } |
| 1984 | |
| 1985 | bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uint256& hashBlock) |
| 1986 | { |
| 1987 | // Open history file to read |
| 1988 | CAutoFile filein(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION); |
| 1989 | if (filein.IsNull()) |
| 1990 | return error("%s: OpenBlockFile failed", __func__); |
| 1991 | |
| 1992 | // Read block |
| 1993 | uint256 hashChecksum; |
| 1994 | try { |
| 1995 | filein >> blockundo; |
| 1996 | filein >> hashChecksum; |
| 1997 | } |
| 1998 | catch (const std::exception& e) { |
| 1999 | return error("%s: Deserialize or I/O error - %s", __func__, e.what()); |
| 2000 | } |
| 2001 | |
| 2002 | // Verify checksum |
| 2003 | CHashWriter hasher(SER_GETHASH, PROTOCOL_VERSION); |
| 2004 | hasher << hashBlock; |
| 2005 | hasher << blockundo; |
| 2006 | if (hashChecksum != hasher.GetHash()) |
| 2007 | return error("%s: Checksum mismatch", __func__); |
| 2008 | |
| 2009 | return true; |
| 2010 | } |
| 2011 | |
| 2012 | /** Abort with a message */ |
| 2013 | bool AbortNode(const std::string& strMessage, const std::string& userMessage="") |
no test coverage detected