mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
blockchain/*: minore code look cleanup
This commit is contained in:
@@ -196,13 +196,13 @@ impl BlockStore {
|
||||
if let Some(found) = self.0.get(hash.as_bytes())? {
|
||||
let block = deserialize(&found)?;
|
||||
ret.push(Some(block));
|
||||
} else {
|
||||
if strict {
|
||||
let s = hash.to_hex().as_str().to_string();
|
||||
return Err(Error::BlockNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
let s = hash.to_hex().as_str().to_string();
|
||||
return Err(Error::BlockNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
@@ -261,13 +261,13 @@ impl BlockStoreOverlay {
|
||||
if let Some(found) = lock.get(SLED_BLOCK_TREE, hash.as_bytes())? {
|
||||
let block = deserialize(&found)?;
|
||||
ret.push(Some(block));
|
||||
} else {
|
||||
if strict {
|
||||
let s = hash.to_hex().as_str().to_string();
|
||||
return Err(Error::BlockNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
let s = hash.to_hex().as_str().to_string();
|
||||
return Err(Error::BlockNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
@@ -340,12 +340,12 @@ impl BlockOrderStore {
|
||||
if let Some(found) = self.0.get(number.to_be_bytes())? {
|
||||
let block_hash = deserialize(&found)?;
|
||||
ret.push(Some(block_hash));
|
||||
} else {
|
||||
if strict {
|
||||
return Err(Error::BlockNumberNotFound(*number))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
return Err(Error::BlockNumberNotFound(*number))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
@@ -457,12 +457,12 @@ impl BlockOrderStoreOverlay {
|
||||
if let Some(found) = lock.get(SLED_BLOCK_ORDER_TREE, &number.to_be_bytes())? {
|
||||
let block_hash = deserialize(&found)?;
|
||||
ret.push(Some(block_hash));
|
||||
} else {
|
||||
if strict {
|
||||
return Err(Error::BlockNumberNotFound(*number))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
return Err(Error::BlockNumberNotFound(*number))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
@@ -661,12 +661,12 @@ impl BlockDifficultyStore {
|
||||
if let Some(found) = self.0.get(height.to_be_bytes())? {
|
||||
let block_difficulty = deserialize(&found)?;
|
||||
ret.push(Some(block_difficulty));
|
||||
} else {
|
||||
if strict {
|
||||
return Err(Error::BlockDifficultyNotFound(*height))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
return Err(Error::BlockDifficultyNotFound(*height))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
|
||||
@@ -130,13 +130,13 @@ impl HeaderStore {
|
||||
if let Some(found) = self.0.get(hash.as_bytes())? {
|
||||
let header = deserialize(&found)?;
|
||||
ret.push(Some(header));
|
||||
} else {
|
||||
if strict {
|
||||
let s = hash.to_hex().as_str().to_string();
|
||||
return Err(Error::HeaderNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
let s = hash.to_hex().as_str().to_string();
|
||||
return Err(Error::HeaderNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
@@ -195,13 +195,13 @@ impl HeaderStoreOverlay {
|
||||
if let Some(found) = lock.get(SLED_HEADER_TREE, hash.as_bytes())? {
|
||||
let header = deserialize(&found)?;
|
||||
ret.push(Some(header));
|
||||
} else {
|
||||
if strict {
|
||||
let s = hash.to_hex().as_str().to_string();
|
||||
return Err(Error::HeaderNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
let s = hash.to_hex().as_str().to_string();
|
||||
return Err(Error::HeaderNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
|
||||
@@ -81,7 +81,7 @@ impl TxStore {
|
||||
/// The resulting vector contains `Option`, which is `Some` if the tx
|
||||
/// was found in the txstore, and otherwise it is `None`, if it has not.
|
||||
/// The second parameter is a boolean which tells the function to fail in
|
||||
/// case at least one block was not found.
|
||||
/// case at least one tx was not found.
|
||||
pub fn get(
|
||||
&self,
|
||||
tx_hashes: &[blake3::Hash],
|
||||
@@ -93,13 +93,13 @@ impl TxStore {
|
||||
if let Some(found) = self.0.get(tx_hash.as_bytes())? {
|
||||
let tx = deserialize(&found)?;
|
||||
ret.push(Some(tx));
|
||||
} else {
|
||||
if strict {
|
||||
let s = tx_hash.to_hex().as_str().to_string();
|
||||
return Err(Error::TransactionNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
let s = tx_hash.to_hex().as_str().to_string();
|
||||
return Err(Error::TransactionNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
@@ -160,7 +160,7 @@ impl TxStoreOverlay {
|
||||
/// The resulting vector contains `Option`, which is `Some` if the tx
|
||||
/// was found in the overlay, and otherwise it is `None`, if it has not.
|
||||
/// The second parameter is a boolean which tells the function to fail in
|
||||
/// case at least one block was not found.
|
||||
/// case at least one tx was not found.
|
||||
pub fn get(
|
||||
&self,
|
||||
tx_hashes: &[blake3::Hash],
|
||||
@@ -173,13 +173,13 @@ impl TxStoreOverlay {
|
||||
if let Some(found) = lock.get(SLED_TX_TREE, tx_hash.as_bytes())? {
|
||||
let tx = deserialize(&found)?;
|
||||
ret.push(Some(tx));
|
||||
} else {
|
||||
if strict {
|
||||
let s = tx_hash.to_hex().as_str().to_string();
|
||||
return Err(Error::TransactionNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
let s = tx_hash.to_hex().as_str().to_string();
|
||||
return Err(Error::TransactionNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
@@ -239,7 +239,7 @@ impl PendingTxStore {
|
||||
/// The resulting vector contains `Option`, which is `Some` if the tx
|
||||
/// was found in the pending tx store, and otherwise it is `None`, if it has not.
|
||||
/// The second parameter is a boolean which tells the function to fail in
|
||||
/// case at least one block was not found.
|
||||
/// case at least one tx was not found.
|
||||
pub fn get(
|
||||
&self,
|
||||
tx_hashes: &[blake3::Hash],
|
||||
@@ -251,13 +251,13 @@ impl PendingTxStore {
|
||||
if let Some(found) = self.0.get(tx_hash.as_bytes())? {
|
||||
let tx = deserialize(&found)?;
|
||||
ret.push(Some(tx));
|
||||
} else {
|
||||
if strict {
|
||||
let s = tx_hash.to_hex().as_str().to_string();
|
||||
return Err(Error::TransactionNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
continue
|
||||
}
|
||||
if strict {
|
||||
let s = tx_hash.to_hex().as_str().to_string();
|
||||
return Err(Error::TransactionNotFound(s))
|
||||
}
|
||||
ret.push(None);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
|
||||
Reference in New Issue
Block a user