mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 13:09:24 +00:00
Support running TendermintMachine when not a validator
This supports validators who leave the current set, without crashing their nodes, along with nodes trying to become validators (who will now seamlessly transition in).
This commit is contained in:
@@ -123,17 +123,14 @@ impl<T: TendermintClient> Signer for TendermintSigner<T> {
|
||||
type ValidatorId = u16;
|
||||
type Signature = Signature;
|
||||
|
||||
async fn validator_id(&self) -> u16 {
|
||||
async fn validator_id(&self) -> Option<u16> {
|
||||
let key = self.get_public_key().await;
|
||||
for (i, k) in (*self.1 .0).read().unwrap().lookup.iter().enumerate() {
|
||||
if k == &key {
|
||||
return u16::try_from(i).unwrap();
|
||||
return Some(u16::try_from(i).unwrap());
|
||||
}
|
||||
}
|
||||
// TODO: Enable switching between being a validator and not being one, likely be returning
|
||||
// Option<u16> here. Non-validators should be able to simply not broadcast when they think
|
||||
// they have messages.
|
||||
panic!("not a validator");
|
||||
None
|
||||
}
|
||||
|
||||
async fn sign(&self, msg: &[u8]) -> Signature {
|
||||
|
||||
Reference in New Issue
Block a user