mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-03 17:40:34 +00:00
cargo +nightly fmt
This commit is contained in:
parent
88f88b574c
commit
3c38a0ec11
10 changed files with 40 additions and 40 deletions
|
@ -306,11 +306,13 @@ impl Polyseed {
|
||||||
check_if_matches(
|
check_if_matches(
|
||||||
lang.has_prefix,
|
lang.has_prefix,
|
||||||
lang.words.iter().map(|lang_word| ascii(lang_word)),
|
lang.words.iter().map(|lang_word| ascii(lang_word)),
|
||||||
&ascii(word)
|
&ascii(word),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
check_if_matches(lang.has_prefix, lang.words.iter(), word)
|
check_if_matches(lang.has_prefix, lang.words.iter(), word)
|
||||||
}) else { continue 'language; };
|
}) else {
|
||||||
|
continue 'language;
|
||||||
|
};
|
||||||
|
|
||||||
// WordList asserts the word list length is less than u16::MAX
|
// WordList asserts the word list length is less than u16::MAX
|
||||||
poly[i] = u16::try_from(coeff).expect("coeff exceeded u16");
|
poly[i] = u16::try_from(coeff).expect("coeff exceeded u16");
|
||||||
|
|
|
@ -681,7 +681,7 @@ async fn main() {
|
||||||
let Ok(serai) = Serai::new("ws://127.0.0.1:9944").await else {
|
let Ok(serai) = Serai::new("ws://127.0.0.1:9944").await else {
|
||||||
log::error!("couldn't connect to the Serai node");
|
log::error!("couldn't connect to the Serai node");
|
||||||
sleep(Duration::from_secs(5)).await;
|
sleep(Duration::from_secs(5)).await;
|
||||||
continue
|
continue;
|
||||||
};
|
};
|
||||||
return serai;
|
return serai;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,8 +171,8 @@ impl<T: Transaction> Block<T> {
|
||||||
Err(BlockError::ProvidedAfterNonProvided)?;
|
Err(BlockError::ProvidedAfterNonProvided)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(local) =
|
let Some(local) = locally_provided.get_mut(order).and_then(|deque| deque.pop_front())
|
||||||
locally_provided.get_mut(order).and_then(|deque| deque.pop_front()) else {
|
else {
|
||||||
Err(BlockError::NonLocalProvided(txs.pop().unwrap()))?
|
Err(BlockError::NonLocalProvided(txs.pop().unwrap()))?
|
||||||
};
|
};
|
||||||
if tx != &local {
|
if tx != &local {
|
||||||
|
|
|
@ -229,9 +229,9 @@ impl<D: Db, T: Transaction, P: P2p> Tributary<D, T, P> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(&TENDERMINT_MESSAGE) => {
|
Some(&TENDERMINT_MESSAGE) => {
|
||||||
let Ok(msg) = SignedMessageFor::<TendermintNetwork<D, T, P>>::decode::<&[u8]>(
|
let Ok(msg) =
|
||||||
&mut &msg[1 ..]
|
SignedMessageFor::<TendermintNetwork<D, T, P>>::decode::<&[u8]>(&mut &msg[1 ..])
|
||||||
) else {
|
else {
|
||||||
log::error!("received invalid tendermint message");
|
log::error!("received invalid tendermint message");
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,9 +63,7 @@ impl<D: Db, T: Transaction> ProvidedTransactions<D, T> {
|
||||||
|
|
||||||
/// Provide a transaction for inclusion in a block.
|
/// Provide a transaction for inclusion in a block.
|
||||||
pub(crate) fn provide(&mut self, tx: T) -> Result<(), ProvidedError> {
|
pub(crate) fn provide(&mut self, tx: T) -> Result<(), ProvidedError> {
|
||||||
let TransactionKind::Provided(order) = tx.kind() else {
|
let TransactionKind::Provided(order) = tx.kind() else { Err(ProvidedError::NotProvided)? };
|
||||||
Err(ProvidedError::NotProvided)?
|
|
||||||
};
|
|
||||||
|
|
||||||
match verify_transaction(&tx, self.genesis, &mut HashMap::new()) {
|
match verify_transaction(&tx, self.genesis, &mut HashMap::new()) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
|
|
|
@ -140,7 +140,9 @@ async fn main() {
|
||||||
NetworkId::Bitcoin => "BITCOIN_KEY",
|
NetworkId::Bitcoin => "BITCOIN_KEY",
|
||||||
NetworkId::Ethereum => "ETHEREUM_KEY",
|
NetworkId::Ethereum => "ETHEREUM_KEY",
|
||||||
NetworkId::Monero => "MONERO_KEY",
|
NetworkId::Monero => "MONERO_KEY",
|
||||||
}) else { continue };
|
}) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
register_service(Service::Processor(network), key);
|
register_service(Service::Processor(network), key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -528,7 +528,8 @@ async fn boot<N: Network, D: Db>(
|
||||||
info!("reloading plan {}: {:?}", hex::encode(id), plan);
|
info!("reloading plan {}: {:?}", hex::encode(id), plan);
|
||||||
|
|
||||||
let (Some((tx, eventuality)), _) =
|
let (Some((tx, eventuality)), _) =
|
||||||
prepare_send(network, signer.keys(), block_number, fee, plan).await else {
|
prepare_send(network, signer.keys(), block_number, fee, plan).await
|
||||||
|
else {
|
||||||
panic!("previously created transaction is no longer being created")
|
panic!("previously created transaction is no longer being created")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,8 @@ impl Serai {
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(finalized) =
|
let Some(finalized) =
|
||||||
self.0.rpc().header(Some(finalized)).await.map_err(SeraiError::RpcError)? else {
|
self.0.rpc().header(Some(finalized)).await.map_err(SeraiError::RpcError)?
|
||||||
|
else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -220,12 +221,8 @@ impl Serai {
|
||||||
// chain
|
// chain
|
||||||
// If that hash is this hash, this block is finalized
|
// If that hash is this hash, this block is finalized
|
||||||
let Some(hash) =
|
let Some(hash) =
|
||||||
self
|
self.0.rpc().block_hash(Some(header.number().into())).await.map_err(SeraiError::RpcError)?
|
||||||
.0
|
else {
|
||||||
.rpc()
|
|
||||||
.block_hash(Some(header.number().into()))
|
|
||||||
.await
|
|
||||||
.map_err(SeraiError::RpcError)? else {
|
|
||||||
// This is an error since there is a block at this index
|
// This is an error since there is a block at this index
|
||||||
Err(SeraiError::InvalidNode)?
|
Err(SeraiError::InvalidNode)?
|
||||||
};
|
};
|
||||||
|
@ -234,8 +231,8 @@ impl Serai {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_block(&self, hash: [u8; 32]) -> Result<Option<Block>, SeraiError> {
|
pub async fn get_block(&self, hash: [u8; 32]) -> Result<Option<Block>, SeraiError> {
|
||||||
let Some(res) =
|
let Some(res) = self.0.rpc().block(Some(hash.into())).await.map_err(SeraiError::RpcError)?
|
||||||
self.0.rpc().block(Some(hash.into())).await.map_err(SeraiError::RpcError)? else {
|
else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -254,7 +251,8 @@ impl Serai {
|
||||||
// In practice, the block is likely more useful than the header
|
// In practice, the block is likely more useful than the header
|
||||||
pub async fn get_block_by_number(&self, number: u64) -> Result<Option<Block>, SeraiError> {
|
pub async fn get_block_by_number(&self, number: u64) -> Result<Option<Block>, SeraiError> {
|
||||||
let Some(hash) =
|
let Some(hash) =
|
||||||
self.0.rpc().block_hash(Some(number.into())).await.map_err(SeraiError::RpcError)? else {
|
self.0.rpc().block_hash(Some(number.into())).await.map_err(SeraiError::RpcError)?
|
||||||
|
else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
self.get_block(hash.into()).await
|
self.get_block(hash.into()).await
|
||||||
|
|
|
@ -120,9 +120,7 @@ pub mod pallet {
|
||||||
Err(Error::AlreadyGeneratedKeys)?
|
Err(Error::AlreadyGeneratedKeys)?
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(musig_key) = MuSigKeys::<T>::get(set) else {
|
let Some(musig_key) = MuSigKeys::<T>::get(set) else { Err(Error::NonExistentValidatorSet)? };
|
||||||
Err(Error::NonExistentValidatorSet)?
|
|
||||||
};
|
|
||||||
if !musig_key.verify(&set_keys_message(&set, key_pair), signature) {
|
if !musig_key.verify(&set_keys_message(&set, key_pair), signature) {
|
||||||
Err(Error::BadSignature)?;
|
Err(Error::BadSignature)?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ pub fn reproducibly_builds() {
|
||||||
|
|
||||||
let logs = Command::new("docker").arg("logs").arg(container).output().unwrap();
|
let logs = Command::new("docker").arg("logs").arg(container).output().unwrap();
|
||||||
let Some(last_log) =
|
let Some(last_log) =
|
||||||
std::str::from_utf8(&logs.stdout).expect("output wasn't utf-8").lines().last() else {
|
std::str::from_utf8(&logs.stdout).expect("output wasn't utf-8").lines().last()
|
||||||
|
else {
|
||||||
continue 'runner;
|
continue 'runner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue