mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 05:29:25 +00:00
Add a TributaryReader which doesn't require a borrow to operate
Reduces lock contention. Additionally changes block_key to include the genesis. While not technically needed, the lack of genesis introduced a side effect where any Tributary on the the database could return the block of any other Tributary. While that wasn't a security issue, returning it suggested it was on-chain when it wasn't. This may have been usable to create issues.
This commit is contained in:
@@ -117,6 +117,7 @@ pub async fn wait_for_tx_inclusion(
|
||||
mut last_checked: [u8; 32],
|
||||
hash: [u8; 32],
|
||||
) -> [u8; 32] {
|
||||
let reader = tributary.reader();
|
||||
loop {
|
||||
let tip = tributary.tip().await;
|
||||
if tip == last_checked {
|
||||
@@ -124,14 +125,14 @@ pub async fn wait_for_tx_inclusion(
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut queue = vec![tributary.block(&tip).unwrap()];
|
||||
let mut queue = vec![reader.block(&tip).unwrap()];
|
||||
let mut block = None;
|
||||
while {
|
||||
let parent = queue.last().unwrap().parent();
|
||||
if parent == tributary.genesis() {
|
||||
false
|
||||
} else {
|
||||
block = Some(tributary.block(&parent).unwrap());
|
||||
block = Some(reader.block(&parent).unwrap());
|
||||
block.as_ref().unwrap().hash() != last_checked
|
||||
}
|
||||
} {
|
||||
|
||||
Reference in New Issue
Block a user