aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-12-05 14:01:03 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2012-12-05 14:01:03 -0800
commita485c1b69e282883414dfb387d0aac1cfa21533d (patch)
tree8d6108b0ec18ea7164deb5c2e943f8bb5c5ef344 /src
parent85887020dc6080e5707632a4ea68232f66d51d69 (diff)
parenta8a4b9673e1f4acabe835a692840c54c50862449 (diff)
downloadbitcoin-a485c1b69e282883414dfb387d0aac1cfa21533d.tar.xz
Merge pull request #2063 from Diapolo/CDiskBlockPos
add 2 constructors in CDiskBlockPos to simplify class usage
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp4
-rw-r--r--src/main.cpp4
-rw-r--r--src/main.h15
3 files changed, 13 insertions, 10 deletions
diff --git a/src/init.cpp b/src/init.cpp
index e0fbb31338..a224b336ce 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -346,9 +346,7 @@ void ThreadImport(void *data) {
CImportingNow imp;
int nFile = 0;
while (!fShutdown) {
- CDiskBlockPos pos;
- pos.nFile = nFile;
- pos.nPos = 0;
+ CDiskBlockPos pos(nFile, 0);
FILE *file = OpenBlockFile(pos, true);
if (!file)
break;
diff --git a/src/main.cpp b/src/main.cpp
index 21c54befcb..84571e11ef 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1535,9 +1535,7 @@ void static FlushBlockFile()
{
LOCK(cs_LastBlockFile);
- CDiskBlockPos posOld;
- posOld.nFile = nLastBlockFile;
- posOld.nPos = 0;
+ CDiskBlockPos posOld(nLastBlockFile, 0);
FILE *fileOld = OpenBlockFile(posOld);
FileCommit(fileOld);
diff --git a/src/main.h b/src/main.h
index 4bd4782ccb..fbd68127a4 100644
--- a/src/main.h
+++ b/src/main.h
@@ -192,6 +192,15 @@ public:
READWRITE(VARINT(nPos));
)
+ CDiskBlockPos() {
+ SetNull();
+ }
+
+ CDiskBlockPos(int nFileIn, unsigned int nPosIn) {
+ nFile = nFileIn;
+ nPos = nPosIn;
+ }
+
friend bool operator==(const CDiskBlockPos &a, const CDiskBlockPos &b) {
return (a.nFile == b.nFile && a.nPos == b.nPos);
}
@@ -1493,8 +1502,7 @@ public:
if (nStatus & BLOCK_HAVE_DATA) {
ret.nFile = nFile;
ret.nPos = nDataPos;
- } else
- ret.SetNull();
+ }
return ret;
}
@@ -1503,8 +1511,7 @@ public:
if (nStatus & BLOCK_HAVE_UNDO) {
ret.nFile = nFile;
ret.nPos = nUndoPos;
- } else
- ret.SetNull();
+ }
return ret;
}