Fixed lock order

This commit is contained in:
arkpar 2016-02-29 19:49:29 +01:00
parent dff7f2e8e5
commit cb4d17825b
2 changed files with 44 additions and 35 deletions

View File

@ -35,3 +35,4 @@ name = "parity"
[profile.release]
debug = false
lto = false

View File

@ -433,6 +433,7 @@ impl BlockChain {
batch.put(b"best", &update.info.hash).unwrap();
// These cached values must be updated atomically
{
let mut best_block = self.best_block.write().unwrap();
let mut write_hashes = self.block_hashes.write().unwrap();
let mut write_txs = self.transaction_addresses.write().unwrap();
@ -454,28 +455,35 @@ impl BlockChain {
write_hashes.remove(number);
}
for (hash, tx_address) in &update.transactions_addresses {
batch.put_extras(hash, tx_address);
write_txs.remove(hash);
}
}
{
let mut write_details = self.block_details.write().unwrap();
for (hash, details) in update.block_details.into_iter() {
batch.put_extras(&hash, &details);
write_details.insert(hash, details);
}
}
{
let mut write_receipts = self.block_receipts.write().unwrap();
for (hash, receipt) in &update.block_receipts {
batch.put_extras(hash, receipt);
write_receipts.remove(hash);
}
for (hash, tx_address) in &update.transactions_addresses {
batch.put_extras(hash, tx_address);
write_txs.remove(hash);
}
{
let mut write_blocks_blooms = self.blocks_blooms.write().unwrap();
for (bloom_hash, blocks_bloom) in &update.blocks_blooms {
batch.put_extras(bloom_hash, blocks_bloom);
write_blocks_blooms.remove(bloom_hash);
}
}
// update extras database
self.extras_db.write(batch).unwrap();