aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Lombrozo <elombrozo@gmail.com>2013-06-23 18:21:33 -0700
committerEric Lombrozo <elombrozo@gmail.com>2013-06-23 19:59:34 -0700
commit8031399494cc4cdf47fcaa9763282a930444033f (patch)
tree71cb9a46b9779e9b1e817aaad3b466529e4ea503 /src
parent7db120d5314578f7360c868bb937e779c33f113a (diff)
downloadbitcoin-8031399494cc4cdf47fcaa9763282a930444033f.tar.xz
Moved ReadBlockFromDisk implementation to main.cpp
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp24
-rw-r--r--src/main.h25
2 files changed, 25 insertions, 24 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 67a989559e..7be5c5a79d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1172,6 +1172,30 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos)
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)
{
if (!ReadBlockFromDisk(block, pindex->GetBlockPos()))
diff --git a/src/main.h b/src/main.h
index 3cd0143c65..47a9fb3381 100644
--- a/src/main.h
+++ b/src/main.h
@@ -726,30 +726,7 @@ public:
/** Functions for disk access for blocks */
bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos);
-inline 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 CDiskBlockPos& pos);
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);