aboutsummaryrefslogtreecommitdiff
path: root/src/chain.h
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2022-01-19 13:42:32 +0100
committerJon Atack <jon@atack.com>2022-01-25 20:46:52 +0100
commit6ea56827842b9b2bd730edc38f3a7b1f46f6247b (patch)
tree640d733a2bdcd1bce0156f74ff0ff2fd92fef583 /src/chain.h
parent5d59ae0ba88849b1eb0d7350871bc19fcd5ef601 (diff)
Guard CBlockIndex::nStatus/nFile/nDataPos/nUndoPos by cs_main
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
Diffstat (limited to 'src/chain.h')
-rw-r--r--src/chain.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/chain.h b/src/chain.h
index fbc033281f..8b03e66a96 100644
--- a/src/chain.h
+++ b/src/chain.h
@@ -164,13 +164,13 @@ public:
int nHeight{0};
//! Which # file this block is stored in (blk?????.dat)
- int nFile{0};
+ int nFile GUARDED_BY(::cs_main){0};
//! Byte offset within blk?????.dat where this block's data is stored
- unsigned int nDataPos{0};
+ unsigned int nDataPos GUARDED_BY(::cs_main){0};
//! Byte offset within rev?????.dat where this block's undo data is stored
- unsigned int nUndoPos{0};
+ unsigned int nUndoPos GUARDED_BY(::cs_main){0};
//! (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
arith_uint256 nChainWork{};
@@ -198,7 +198,7 @@ public:
//! load to avoid the block index being spuriously rewound.
//! @sa NeedsRedownload
//! @sa ActivateSnapshot
- uint32_t nStatus{0};
+ uint32_t nStatus GUARDED_BY(::cs_main){0};
//! block header
int32_t nVersion{0};
@@ -382,6 +382,7 @@ public:
SERIALIZE_METHODS(CDiskBlockIndex, obj)
{
+ LOCK(::cs_main);
int _nVersion = s.GetVersion();
if (!(s.GetType() & SER_GETHASH)) READWRITE(VARINT_MODE(_nVersion, VarIntMode::NONNEGATIVE_SIGNED));