pub struct Service<D, S, G> { /* private fields */ }Expand description
The node service.
Implementations§
Source§impl<D, S, G> Service<D, S, G>
impl<D, S, G> Service<D, S, G>
pub fn new( config: Config, db: Stores<D>, storage: S, policies: Config<Write>, signer: Device<G>, rng: Rng, node: NodeAnnouncement, emitter: Emitter<Event>, ) -> Self
Sourcepub fn started(&self) -> Option<LocalTime>
pub fn started(&self) -> Option<LocalTime>
Whether the service was started (initialized) and if so, at what time.
Sourcepub fn seed(&mut self, id: &RepoId, scope: Scope) -> Result<bool, Error>
pub fn seed(&mut self, id: &RepoId, scope: Scope) -> Result<bool, Error>
Seed a repository. Returns whether or not the repo policy was updated.
Sourcepub fn unseed(&mut self, id: &RepoId) -> Result<bool, Error>
pub fn unseed(&mut self, id: &RepoId) -> Result<bool, Error>
Unseed a repository. Returns whether or not the repo policy was updated. Note that when unseeding, we don’t announce anything to the network. This is because by simply not announcing it anymore, it will eventually be pruned by nodes.
Sourcepub fn closest_peers(&self, n: usize) -> Vec<NodeId> ⓘ
pub fn closest_peers(&self, n: usize) -> Vec<NodeId> ⓘ
Find the closest n peers by proximity in seeding graphs.
Returns a sorted list from the closest peer to the furthest.
Peers with more seedings in common score score higher.
Sourcepub fn database_mut(&mut self) -> &mut Stores<D>
pub fn database_mut(&mut self) -> &mut Stores<D>
Get the mutable database.
Sourcepub fn storage_mut(&mut self) -> &mut S
pub fn storage_mut(&mut self) -> &mut S
Get the mutable storage instance.
Sourcepub fn lookup(&self, rid: RepoId) -> Result<Lookup, LookupError>
pub fn lookup(&self, rid: RepoId) -> Result<Lookup, LookupError>
Lookup a repository, both locally and in the routing table.
Sourcepub fn initialize(&mut self, time: LocalTime) -> Result<(), Error>
pub fn initialize(&mut self, time: LocalTime) -> Result<(), Error>
Initialize service with current time. Call this once.
pub fn tick(&mut self, now: LocalTime, metrics: &Metrics)
pub fn wake(&mut self)
pub fn command(&mut self, cmd: Command)
pub fn fetched( &mut self, rid: RepoId, remote: NodeId, result: Result<FetchResult, FetchError>, )
Sourcepub fn dequeue_fetches(&mut self)
pub fn dequeue_fetches(&mut self)
Attempt to dequeue fetches from all peers. At most one fetch is dequeued per peer. If the fetch cannot be processed, it is put back on the queue for that peer.
Fetches are queued for two reasons:
- The RID was already being fetched.
- The session was already at fetch capacity.
pub fn attempted(&mut self, nid: NodeId, addr: Address)
pub fn listening(&mut self, local_addr: SocketAddr)
pub fn connected(&mut self, remote: NodeId, addr: Address, link: Link)
pub fn disconnected( &mut self, remote: NodeId, link: Link, reason: &DisconnectReason, )
pub fn received_message(&mut self, remote: NodeId, message: Message)
Sourcepub fn handle_announcement(
&mut self,
relayer: &NodeId,
relayer_addr: &Address,
announcement: &Announcement,
) -> Result<Option<AnnouncementId>, Error>
pub fn handle_announcement( &mut self, relayer: &NodeId, relayer_addr: &Address, announcement: &Announcement, ) -> Result<Option<AnnouncementId>, Error>
Handle an announcement message.
Returns true if this announcement should be stored and relayed to connected peers,
and false if it should not.
pub fn handle_info(&mut self, remote: NodeId, info: &Info) -> Result<(), Error>
pub fn handle_message( &mut self, remote: &NodeId, message: Message, ) -> Result<(), Error>
Trait Implementations§
Auto Trait Implementations§
impl<D, S, G> !Freeze for Service<D, S, G>
impl<D, S, G> !RefUnwindSafe for Service<D, S, G>
impl<D, S, G> Send for Service<D, S, G>
impl<D, S, G> !Sync for Service<D, S, G>
impl<D, S, G> Unpin for Service<D, S, G>
impl<D, S, G> !UnwindSafe for Service<D, S, G>
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> 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 more