Merge pull request #2063 from Diapolo/CDiskBlockPos
add 2 constructors in CDiskBlockPos to simplify class usage
This commit is contained in:
commit
a485c1b69e
3 changed files with 13 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
15
src/main.h
15
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue