pub struct GlobalRegistryServer {
pub config: GlobalRegistryServerConfig,
pub seed: u64,
pub entries: HashMap<PeerId, (u64, Address)>,
/* private fields */
}Expand description
Server half of GlobalRegistry. Maintains
PeerId → (expires_at_ns, source_address) over the announced
cohort and exposes the cohort as a
bb_runtime::contracts::PeerSelector source. Eviction is lazy:
Sample / CurrentView drop entries whose expires_at_ns has
elapsed before consulting the registry.
Fields§
§config: GlobalRegistryServerConfigConfigurable TTL bounds + heartbeat policy.
seed: u64RNG seed for deterministic Sample selection. Persisted so a
restored server samples consistently.
entries: HashMap<PeerId, (u64, Address)>Registry: PeerId → (expires_at_ns, source_address). Restored
alongside seed so cohort continuity survives snapshot/restore.
Implementations§
Source§impl GlobalRegistryServer
impl GlobalRegistryServer
Sourcepub fn new(seed: u64) -> Self
pub fn new(seed: u64) -> Self
Construct a fresh server with the default TTL/heartbeat policy
and seed driving deterministic Sample selection.
Sourcepub fn with_config(seed: u64, config: GlobalRegistryServerConfig) -> Self
pub fn with_config(seed: u64, config: GlobalRegistryServerConfig) -> Self
Construct with an explicit config override.
Sourcepub fn heartbeat_interval_ns(&self) -> u64
pub fn heartbeat_interval_ns(&self) -> u64
Server-derived heartbeat interval. Integer division on
default_ttl_ns / 3 gives the client three windows to refresh
before eviction.
Trait Implementations§
Source§impl AnyComponent for GlobalRegistryServer
impl AnyComponent for GlobalRegistryServer
Source§impl Bootstrap for GlobalRegistryServer
impl Bootstrap for GlobalRegistryServer
Source§type Error = Infallible
type Error = Infallible
Source§impl Clone for GlobalRegistryServer
impl Clone for GlobalRegistryServer
Source§impl ConcreteComponent for GlobalRegistryServer
impl ConcreteComponent for GlobalRegistryServer
Source§const TYPE_NAME: &'static str = "GlobalRegistryServer"
const TYPE_NAME: &'static str = "GlobalRegistryServer"
<crate>::<TypeName>.Source§const PACKAGE: ComponentPackage = ::bytesandbrains::concrete::ComponentPackage::Application
const PACKAGE: ComponentPackage = ::bytesandbrains::concrete::ComponentPackage::Application
Application.Source§const DEPENDENCIES: &'static [DependencyDecl]
const DEPENDENCIES: &'static [DependencyDecl]
bb::Concrete derive from #[bb::depends(...)].Source§type Error = Infallible
type Error = Infallible
Self::new; use Infallible if construction
can’t fail.Source§impl Debug for GlobalRegistryServer
impl Debug for GlobalRegistryServer
Source§impl Default for GlobalRegistryServer
impl Default for GlobalRegistryServer
Source§impl<'de> Deserialize<'de> for GlobalRegistryServer
impl<'de> Deserialize<'de> for GlobalRegistryServer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PeerSelector for GlobalRegistryServer
impl PeerSelector for GlobalRegistryServer
Source§fn select(
&mut self,
ctx: &mut RuntimeResourceRef<'_>,
params: SelectParams,
_completion: CompletionHandle<Vec<PeerId>, Self::Error>,
) -> ContractResponse<Vec<PeerId>, Self::Error>
fn select( &mut self, ctx: &mut RuntimeResourceRef<'_>, params: SelectParams, _completion: CompletionHandle<Vec<PeerId>, Self::Error>, ) -> ContractResponse<Vec<PeerId>, Self::Error>
params carries selector-specific
config. Concrete impls handle the variants they support
and fail the unsupported ones via ContractResponse::Now
carrying an error. ctx exposes ctx.peers.addresses
(the framework’s AddressBook), the engine’s per-op
runtime surface, and ctx.dependency::<T>(slot) for
reaching any concrete bound via #[depends(...)].Source§fn current_view(
&mut self,
ctx: &mut RuntimeResourceRef<'_>,
_completion: CompletionHandle<Vec<PeerId>, Self::Error>,
) -> ContractResponse<Vec<PeerId>, Self::Error>
fn current_view( &mut self, ctx: &mut RuntimeResourceRef<'_>, _completion: CompletionHandle<Vec<PeerId>, Self::Error>, ) -> ContractResponse<Vec<PeerId>, Self::Error>
Source§fn sample(
&mut self,
ctx: &mut RuntimeResourceRef<'_>,
n: u32,
completion: CompletionHandle<Vec<PeerId>, Self::Error>,
) -> ContractResponse<Vec<PeerId>, Self::Error>
fn sample( &mut self, ctx: &mut RuntimeResourceRef<'_>, n: u32, completion: CompletionHandle<Vec<PeerId>, Self::Error>, ) -> ContractResponse<Vec<PeerId>, Self::Error>
n peers from the current view. Calls
land on select(SelectParams::Random { n }) by default.
Concrete impls may override to keep an optimized fast path.Source§impl PeerSelectorRuntime for GlobalRegistryServer
impl PeerSelectorRuntime for GlobalRegistryServer
Source§fn atomic_opset(&self) -> AtomicOpsetDecl
fn atomic_opset(&self) -> AtomicOpsetDecl
Source§fn dispatch_atomic(
&mut self,
op_type: &str,
_inputs: &[(&str, &dyn SlotValue)],
_ctx: &mut RuntimeResourceRef<'_>,
) -> Result<DispatchResult, Self::Error>
fn dispatch_atomic( &mut self, op_type: &str, _inputs: &[(&str, &dyn SlotValue)], _ctx: &mut RuntimeResourceRef<'_>, ) -> Result<DispatchResult, Self::Error>
Source§impl ProtocolRuntime for GlobalRegistryServer
impl ProtocolRuntime for GlobalRegistryServer
Source§fn atomic_opset(&self) -> AtomicOpsetDecl
fn atomic_opset(&self) -> AtomicOpsetDecl
Source§fn dispatch_atomic(
&mut self,
op_type: &str,
inputs: &[(&str, &dyn SlotValue)],
ctx: &mut RuntimeResourceRef<'_>,
) -> Result<DispatchResult, OpError>
fn dispatch_atomic( &mut self, op_type: &str, inputs: &[(&str, &dyn SlotValue)], ctx: &mut RuntimeResourceRef<'_>, ) -> Result<DispatchResult, OpError>
Auto Trait Implementations§
impl !Freeze for GlobalRegistryServer
impl RefUnwindSafe for GlobalRegistryServer
impl Send for GlobalRegistryServer
impl Sync for GlobalRegistryServer
impl Unpin for GlobalRegistryServer
impl UnsafeUnpin for GlobalRegistryServer
impl UnwindSafe for GlobalRegistryServer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedComponent for 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>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> SlotValue for T
impl<T> SlotValue for T
Source§fn into_any_boxed(self: Box<T>) -> Box<dyn Any + Sync + Send>
fn into_any_boxed(self: Box<T>) -> Box<dyn Any + Sync + Send>
Box<dyn SlotValue> as Box<dyn Any> for
Box::downcast. Required because the SlotValue and
Any vtables are distinct even though SlotValue: Any.Source§fn clone_boxed(&self) -> Box<dyn SlotValue>
fn clone_boxed(&self) -> Box<dyn SlotValue>
Source§fn to_wire_bytes(&self) -> Result<Vec<u8>, SlotValueError>
fn to_wire_bytes(&self) -> Result<Vec<u8>, SlotValueError>
clone_boxed instead.Source§fn type_hash(&self) -> u64
fn type_hash(&self) -> u64
std::any::type_name::<T>(); receiver decodes only on a
matching hash.Source§fn runtime_type(&self) -> &'static TypeNode
fn runtime_type(&self) -> &'static TypeNode
Source§fn charged_bytes(&self) -> usize
fn charged_bytes(&self) -> usize
NodeConfig::ingress_byte_budget. Slot-table eviction calls
this to release the charge. Default 0 — only
ingress-derived carriers register a non-zero resolver via
[register_charged_bytes!].