fix block_store race conditiom
This commit is contained in:
parent
2cc7d9709e
commit
0cd06f48c1
|
@ -96,7 +96,7 @@ impl BlockListener {
|
||||||
blockhash.to_owned(),
|
blockhash.to_owned(),
|
||||||
self.block_store
|
self.block_store
|
||||||
.get(blockhash)
|
.get(blockhash)
|
||||||
.expect("Latest Block Not in Map")
|
.expect("Internal Error: Block store race condition")
|
||||||
.value()
|
.value()
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
)
|
)
|
||||||
|
@ -171,9 +171,12 @@ impl BlockListener {
|
||||||
|
|
||||||
let parent_slot = block.parent_slot;
|
let parent_slot = block.parent_slot;
|
||||||
|
|
||||||
*self.latest_block_hash.write().await = blockhash.clone();
|
// Write to block store first in order to prevent
|
||||||
|
// any race condition i.e prevent some one to
|
||||||
|
// ask the map what it doesn't have rn
|
||||||
self.block_store
|
self.block_store
|
||||||
.insert(blockhash, BlockInformation { slot, block_height });
|
.insert(blockhash.clone(), BlockInformation { slot, block_height });
|
||||||
|
*self.latest_block_hash.write().await = blockhash;
|
||||||
|
|
||||||
if let Some(postgres) = &postgres {
|
if let Some(postgres) = &postgres {
|
||||||
postgres
|
postgres
|
||||||
|
|
Loading…
Reference in New Issue