mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Fix Bus Error (core dumped) when validating fast sync txhashset (#956)
This PR fixes #953 by introducing a lock for txhashet_write. It's not enough to synchronize access to in memory data, files also needs to be protected, so a general txhashset lock was introduced.
This commit is contained in:
parent
cbfd3803bf
commit
8e26d4dbac
1 changed files with 3 additions and 0 deletions
|
@ -127,6 +127,7 @@ pub struct Chain {
|
||||||
|
|
||||||
head: Arc<Mutex<Tip>>,
|
head: Arc<Mutex<Tip>>,
|
||||||
orphans: Arc<OrphanBlockPool>,
|
orphans: Arc<OrphanBlockPool>,
|
||||||
|
txhashset_lock: Arc<Mutex<bool>>,
|
||||||
txhashset: Arc<RwLock<txhashset::TxHashSet>>,
|
txhashset: Arc<RwLock<txhashset::TxHashSet>>,
|
||||||
|
|
||||||
// POW verification function
|
// POW verification function
|
||||||
|
@ -233,6 +234,7 @@ impl Chain {
|
||||||
adapter: adapter,
|
adapter: adapter,
|
||||||
head: Arc::new(Mutex::new(head)),
|
head: Arc::new(Mutex::new(head)),
|
||||||
orphans: Arc::new(OrphanBlockPool::new()),
|
orphans: Arc::new(OrphanBlockPool::new()),
|
||||||
|
txhashset_lock: Arc::new(Mutex::new(false)),
|
||||||
txhashset: Arc::new(RwLock::new(txhashset)),
|
txhashset: Arc::new(RwLock::new(txhashset)),
|
||||||
pow_verifier: pow_verifier,
|
pow_verifier: pow_verifier,
|
||||||
})
|
})
|
||||||
|
@ -526,6 +528,7 @@ impl Chain {
|
||||||
rewind_to_kernel: u64,
|
rewind_to_kernel: u64,
|
||||||
txhashset_data: File,
|
txhashset_data: File,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
let _lock = self.txhashset_lock.lock().unwrap();
|
||||||
let head = self.head().unwrap();
|
let head = self.head().unwrap();
|
||||||
let header_head = self.get_header_head().unwrap();
|
let header_head = self.get_header_head().unwrap();
|
||||||
if header_head.height - head.height < global::cut_through_horizon() as u64 {
|
if header_head.height - head.height < global::cut_through_horizon() as u64 {
|
||||||
|
|
Loading…
Reference in a new issue