pub struct SignerRegistry { /* private fields */ }Expand description
Mutable signer registry attached to a SIGNED_BY collection.
Invariants:
allowedis the exact set of keys that may produce new signatures. Empty set ⇒ collection rejects every insert (the runtime treats an emptySIGNED_BYlist as a parse error, so in practice this only happens after every key is revoked — intentional kill-switch behaviour).historyis append-only.add_signer/revoke_signerpush new entries; nothing ever pops.add_signerof an already-allowed key is a no-op (no history entry written) so that idempotent DDL replays don’t flood the log.revoke_signerof an unknown key returnsfalse.
Implementations§
Source§impl SignerRegistry
impl SignerRegistry
Sourcepub fn from_initial(
initial: &[[u8; 32]],
actor: impl Into<String>,
ts_unix_ms: u128,
) -> SignerRegistry
pub fn from_initial( initial: &[[u8; 32]], actor: impl Into<String>, ts_unix_ms: u128, ) -> SignerRegistry
Build a registry from the initial SIGNED_BY (...) list parsed
at CREATE COLLECTION time. Each key receives one
SignerHistoryAction::Add entry with the supplied actor /
timestamp so the audit trail is non-empty from genesis.
Sourcepub fn from_persisted_parts(
allowed: Vec<[u8; 32]>,
history: Vec<SignerHistoryEntry>,
) -> SignerRegistry
pub fn from_persisted_parts( allowed: Vec<[u8; 32]>, history: Vec<SignerHistoryEntry>, ) -> SignerRegistry
Rebuild a registry from previously-persisted state. Used by the
runtime adapter when loading the registry off red_config — the
caller is responsible for the storage format; this constructor
only stitches the in-memory invariants back together.
Sourcepub fn allowed(&self) -> impl Iterator<Item = &[u8; 32]>
pub fn allowed(&self) -> impl Iterator<Item = &[u8; 32]>
Snapshot of the currently-allowed signers, in stable order.
pub fn allowed_len(&self) -> usize
pub fn history(&self) -> &[SignerHistoryEntry]
pub fn is_allowed(&self, pubkey: &[u8; 32]) -> bool
Sourcepub fn ever_added(&self, pubkey: &[u8; 32]) -> bool
pub fn ever_added(&self, pubkey: &[u8; 32]) -> bool
Returns true if this key was added at any point in the past
(even if later revoked). Used by verify_insert to
distinguish UnknownSigner from RevokedSigner.
Sourcepub fn add_signer(
&mut self,
pubkey: [u8; 32],
actor: impl Into<String>,
ts_unix_ms: u128,
) -> bool
pub fn add_signer( &mut self, pubkey: [u8; 32], actor: impl Into<String>, ts_unix_ms: u128, ) -> bool
Add pubkey to the allowed set. Returns true if the key was
newly added (history entry written), false if it was already
allowed (idempotent no-op).
Sourcepub fn revoke_signer(
&mut self,
pubkey: &[u8; 32],
actor: impl Into<String>,
ts_unix_ms: u128,
) -> bool
pub fn revoke_signer( &mut self, pubkey: &[u8; 32], actor: impl Into<String>, ts_unix_ms: u128, ) -> bool
Remove pubkey from the allowed set. Returns true if the key
was present (and a Revoke history entry written), false if
it was unknown. Past rows signed by pubkey remain valid and
re-verifiable — only future inserts are rejected.
Trait Implementations§
Source§impl Clone for SignerRegistry
impl Clone for SignerRegistry
Source§fn clone(&self) -> SignerRegistry
fn clone(&self) -> SignerRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SignerRegistry
impl Debug for SignerRegistry
Source§impl Default for SignerRegistry
impl Default for SignerRegistry
Source§fn default() -> SignerRegistry
fn default() -> SignerRegistry
Source§impl PartialEq for SignerRegistry
impl PartialEq for SignerRegistry
Source§fn eq(&self, other: &SignerRegistry) -> bool
fn eq(&self, other: &SignerRegistry) -> bool
self and other values to be equal, and is used by ==.impl Eq for SignerRegistry
impl StructuralPartialEq for SignerRegistry
Auto Trait Implementations§
impl Freeze for SignerRegistry
impl RefUnwindSafe for SignerRegistry
impl Send for SignerRegistry
impl Sync for SignerRegistry
impl Unpin for SignerRegistry
impl UnsafeUnpin for SignerRegistry
impl UnwindSafe for SignerRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request