mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 03:59:22 +00:00
Update Update
and substrate_signers to [u8; 32] from Vec<u8>
A commit made while testing moved them from network-key-indexed to Substrate-key-indexed. Since Substrate keys have a fixed-length, fitting within the Copy boundary, there's no reason for it to not use an array.
This commit is contained in:
parent
506ded205a
commit
61418b4e9f
3 changed files with 8 additions and 9 deletions
|
@ -176,7 +176,7 @@ pub mod substrate {
|
|||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Zeroize, Serialize, Deserialize)]
|
||||
pub enum ProcessorMessage {
|
||||
Update { key: Vec<u8>, batch: SignedBatch },
|
||||
Update { key: [u8; 32], batch: SignedBatch },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ struct TributaryMutable<N: Network, D: Db> {
|
|||
// The safety of this follows as written above.
|
||||
|
||||
// TODO: There should only be one SubstrateSigner at a time (see #277)
|
||||
substrate_signers: HashMap<Vec<u8>, SubstrateSigner<D>>,
|
||||
substrate_signers: HashMap<[u8; 32], SubstrateSigner<D>>,
|
||||
}
|
||||
|
||||
// Items which are mutably borrowed by Substrate.
|
||||
|
@ -373,10 +373,9 @@ async fn handle_coordinator_msg<D: Db, N: Network, Co: Coordinator>(
|
|||
// See TributaryMutable's struct definition for why this block is safe
|
||||
let KeyConfirmed { substrate_keys, network_keys } =
|
||||
tributary_mutable.key_gen.confirm(txn, set, key_pair).await;
|
||||
tributary_mutable.substrate_signers.insert(
|
||||
substrate_keys.group_key().to_bytes().to_vec(),
|
||||
SubstrateSigner::new(substrate_keys),
|
||||
);
|
||||
tributary_mutable
|
||||
.substrate_signers
|
||||
.insert(substrate_keys.group_key().to_bytes(), SubstrateSigner::new(substrate_keys));
|
||||
|
||||
let key = network_keys.group_key();
|
||||
|
||||
|
@ -520,7 +519,7 @@ async fn boot<N: Network, D: Db>(
|
|||
let substrate_signer = SubstrateSigner::new(substrate_keys);
|
||||
// We don't have to load any state for this since the Scanner will re-fire any events
|
||||
// necessary
|
||||
substrate_signers.insert(substrate_key.to_bytes().to_vec(), substrate_signer);
|
||||
substrate_signers.insert(substrate_key.to_bytes(), substrate_signer);
|
||||
|
||||
let mut signer = Signer::new(network.clone(), network_keys);
|
||||
|
||||
|
@ -612,7 +611,7 @@ async fn run<N: Network, D: Db, Co: Coordinator>(mut raw_db: D, network: N, mut
|
|||
SubstrateSignerEvent::SignedBatch(batch) => {
|
||||
coordinator
|
||||
.send(ProcessorMessage::Substrate(messages::substrate::ProcessorMessage::Update {
|
||||
key: key.clone(),
|
||||
key: *key,
|
||||
batch,
|
||||
}))
|
||||
.await;
|
||||
|
|
|
@ -125,7 +125,7 @@ pub(crate) async fn sign_batch(
|
|||
key,
|
||||
batch: this_batch,
|
||||
}) => {
|
||||
assert_eq!(&key, &id.key);
|
||||
assert_eq!(key.as_slice(), &id.key);
|
||||
|
||||
if batch.is_none() {
|
||||
assert!(PublicKey::from_raw(id.key.clone().try_into().unwrap())
|
||||
|
|
Loading…
Reference in a new issue