libp2p/protocols/kademlia/find

Search:
Group by:
Source   Edit  

Types

DispatchProc = proc (kad: KadDHT; peer: PeerId; target: Key): Future[
    Result[Message, string]] {.async: (...raises: [CancelledError]), ...gcsafe,
                               closure.}
Source   Edit  
LookupState = ref object
  target*: Key
  shortlist*: Table[PeerId, XorDistance]
  responded*: Table[PeerId, RespondedStatus]
  attempts*: Table[PeerId, int]
  inflight*: Table[PeerId, seq[FutureBase]]
Source   Edit  
ReplyHandler = proc (peer: PeerId; msg: Opt[Message]; state: LookupState): Future[
    void] {.async: (...raises: []), ...gcsafe.}
Source   Edit  
RespondedStatus = enum
  Failed, Success
Source   Edit  
StopCond = proc (state: LookupState): bool {....raises: [], gcsafe.}
Source   Edit  

Procs

proc allSortedPeers(state: LookupState): seq[PeerId] {....raises: [], tags: [],
    forbids: [].}
Returns all peers discovered during lookup sorted by XOR distance to target (closest first). Source   Edit  
proc closestAvailableStop(state: LookupState): bool {....raises: [], gcsafe,
    tags: [], forbids: [].}
Source   Edit  
proc dispatchFindNode(kad: KadDHT; peer: PeerId; target: Key; addrs: Opt[
    seq[MultiAddress]] = Opt.none(seq[MultiAddress])): InternalRaisesFuture[
    Result[Message, string], (CancelledError,)] {....gcsafe, stackTrace: false,
    raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Source   Edit  
proc findClosestPeers(kad: KadDHT; target: Key): seq[Peer] {....raises: [],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc findNodeDispatch(kad: KadDHT; peer: PeerId; target: Key): InternalRaisesFuture[
    Result[Message, string], (CancelledError,)] {....gcsafe, stackTrace: false,
    raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Source   Edit  
proc findPeer(kad: KadDHT; target: PeerId): InternalRaisesFuture[
    Result[PeerInfo, string], (CancelledError,)] {....stackTrace: false,
    raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Walks the key space until it finds candidate addresses for a target peer Id Source   Edit  
proc hasResponsesFromClosestAvailable(state: LookupState): bool {....raises: [],
    gcsafe, tags: [], forbids: [].}
True when all closest k AVAILABLE peers have responded. Source   Edit  
proc init(T: type LookupState; kad: KadDHT; target: Key): T:type
Source   Edit  
proc iterativeLookup(kad: KadDHT; target: Key; dispatch: DispatchProc;
                     onReply: ReplyHandler; stopCond: StopCond): InternalRaisesFuture[
    LookupState, (CancelledError,)] {....stackTrace: false, raises: [], gcsafe,
                                      tags: [RootEffect], forbids: [].}
Source   Edit  
proc iterativeLookup(kad: KadDHT; target: Key; rtable: RoutingTable;
                     dispatch: DispatchProc; onReply: ReplyHandler;
                     stopCond: StopCond): InternalRaisesFuture[LookupState,
    (CancelledError,)] {....stackTrace: false, raises: [], gcsafe,
                         tags: [RootEffect], forbids: [].}
Source   Edit  
proc lookOnce(kad: KadDHT; state: LookupState; rtable: RoutingTable;
              dispatch: DispatchProc; onReply: ReplyHandler): InternalRaisesFuture[
    bool, (CancelledError,)] {....stackTrace: false, raises: [], gcsafe,
                               tags: [RootEffect], forbids: [].}
Run a single round of the iterative lookup against state.target. Returns false when no further peers can be queried, signalling the caller to stop driving the lookup. Source   Edit  
proc noopReply(peerId: PeerId; msgOpt: Opt[Message]; state: LookupState): InternalRaisesFuture[
    void, void] {....gcsafe, stackTrace: false, raises: [], gcsafe,
                  tags: [RootEffect], forbids: [].}
Source   Edit  
proc selectCloserPeers(state: LookupState; amount: int;
                       excludeResponded: bool = true): seq[PeerId] {....raises: [],
    tags: [], forbids: [].}
Select closer amount peers Source   Edit  
proc updatePeers(kad: KadDHT; peerInfos: seq[PeerInfo]) {....raises: [],
    tags: [RootEffect, WriteIOEffect], forbids: [].}
Source   Edit  
proc updatePeers(kad: KadDHT; peers: seq[(PeerId, seq[MultiAddress])]) {.
    ...raises: [], tags: [RootEffect, WriteIOEffect], forbids: [].}
Source   Edit  
proc updatePeers(switch: Switch; addressPolicy: PeerAddressPolicy;
                 rtable: RoutingTable; peerInfos: seq[PeerInfo];
                 maxPeersPerIp: int = DefaultMaxPeersPerIp;
                 maxPeersPerIpv4Subnet: int = DefaultMaxPeersPerSubnet;
                 maxPeersPerIpv6Subnet: int = DefaultMaxPeersPerSubnet) {.
    ...raises: [], tags: [RootEffect, WriteIOEffect], forbids: [].}
Source   Edit  
proc updateShortlist(state: LookupState; msg: Message): seq[PeerInfo] {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  

Methods

method findNode(kad: KadDHT; target: Key): InternalRaisesFuture[seq[PeerId],
    (CancelledError,)] {.base, ...stackTrace: false, raises: [], gcsafe,
                         tags: [RootEffect], forbids: [].}
Source   Edit  
method findNode(kad: KadDHT; target: Key; rtable: RoutingTable): InternalRaisesFuture[
    seq[PeerId], (CancelledError,)] {.base, ...stackTrace: false, raises: [],
                                      gcsafe, tags: [RootEffect], forbids: [].}
Iteratively search for the k closest peers to a target key. Source   Edit  
method handleFindNode(kad: KadDHT; stream: Stream; msg: Message): InternalRaisesFuture[
    void, (CancelledError,)] {.base, ...stackTrace: false, raises: [], gcsafe,
                               tags: [RootEffect], forbids: [].}
Source   Edit