mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-05 10:12:48 +01:00
streams: cache file position within AutoFile
This commit is contained in:
@@ -683,7 +683,7 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
|
||||
fileout << GetParams().MessageStart() << nSize;
|
||||
|
||||
// Write undo data
|
||||
long fileOutPos = ftell(fileout.Get());
|
||||
long fileOutPos = fileout.tell();
|
||||
if (fileOutPos < 0) {
|
||||
LogError("%s: ftell failed\n", __func__);
|
||||
return false;
|
||||
@@ -981,7 +981,7 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
|
||||
fileout << GetParams().MessageStart() << nSize;
|
||||
|
||||
// Write block
|
||||
long fileOutPos = ftell(fileout.Get());
|
||||
long fileOutPos = fileout.tell();
|
||||
if (fileOutPos < 0) {
|
||||
LogError("%s: ftell failed\n", __func__);
|
||||
return false;
|
||||
|
||||
@@ -73,7 +73,9 @@ std::optional<uint256> ReadSnapshotBaseBlockhash(fs::path chaindir)
|
||||
}
|
||||
afile >> base_blockhash;
|
||||
|
||||
if (std::fgetc(afile.Get()) != EOF) {
|
||||
int64_t position = afile.tell();
|
||||
afile.seek(0, SEEK_END);
|
||||
if (position != afile.tell()) {
|
||||
LogPrintf("[snapshot] warning: unexpected trailing data in %s\n", read_from_str);
|
||||
} else if (std::ferror(afile.Get())) {
|
||||
LogPrintf("[snapshot] warning: i/o error reading %s\n", read_from_str);
|
||||
|
||||
Reference in New Issue
Block a user