pub struct Metagraph {
pub netuid: u16,
pub neurons: Vec<NeuronInfo>,
pub n: u16,
pub block: u64,
/* private fields */
}Expand description
In-memory snapshot of a Bittensor subnet’s metagraph.
Call sync to fetch the latest state from a subtensor node.
Fields§
§netuid: u16Subnet network UID.
neurons: Vec<NeuronInfo>All neurons in the subnet at the last sync point.
n: u16Number of neurons in the subnet (SubnetworkN).
block: u64Block number at which the metagraph was last synced.
Implementations§
Source§impl Metagraph
impl Metagraph
Sourcepub fn new(netuid: u16) -> Self
pub fn new(netuid: u16) -> Self
Creates an empty metagraph for the given subnet. Call sync to populate.
Sourcepub async fn sync(
&mut self,
client: &OnlineClient<PolkadotConfig>,
) -> Result<()>
pub async fn sync( &mut self, client: &OnlineClient<PolkadotConfig>, ) -> Result<()>
Fetches the latest metagraph from a subtensor node, replacing all neuron data. Tries the runtime API first, falling back to individual storage queries.
Sourcepub fn quic_miners(&self) -> Vec<QuicAxonInfo>
pub fn quic_miners(&self) -> Vec<QuicAxonInfo>
Returns axon info for active, non-validator neurons advertising QUIC (protocol 4) on a globally routable IPv4 address.
Sourcepub fn validator_axon_ips(&self) -> HashSet<IpAddr>
pub fn validator_axon_ips(&self) -> HashSet<IpAddr>
Returns the set of source IP addresses for neurons holding a validator_permit.
Wrap with SourceAllowlist::Enforce when feeding a
SourceAddressResolver implementation. Neurons without
a routable axon IP are skipped, so subnets where validators do not serve_axon will
produce an empty set and should return [SourceAllowlist::Bypass] instead of feeding
it through as Enforce, otherwise every connection is silently dropped.
Sourcepub fn get_neuron(&self, uid: u16) -> Option<&NeuronInfo>
pub fn get_neuron(&self, uid: u16) -> Option<&NeuronInfo>
Looks up a neuron by UID.
Sourcepub fn get_uid_by_hotkey(&self, hotkey: &str) -> Option<u16>
pub fn get_uid_by_hotkey(&self, hotkey: &str) -> Option<u16>
Looks up a neuron’s UID by SS58 hotkey.
Auto Trait Implementations§
impl Freeze for Metagraph
impl RefUnwindSafe for Metagraph
impl Send for Metagraph
impl Sync for Metagraph
impl Unpin for Metagraph
impl UnsafeUnpin for Metagraph
impl UnwindSafe for Metagraph
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> 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, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.