libp2p/protocols/kademlia/types

Search:
Group by:
Source   Edit  

Currently a string, because for some reason, that's what is chosen at the protobuf level TODO: convert between RFC3339 strings and use of integers (i.e. the _correct way)

Types

Bucket = object
  peers*: seq[NodeEntry]
Source   Edit  
CandidatePeers = ref HashSet[PeerId]
Source   Edit  
DefaultEntrySelector = ref object of EntrySelector
Source   Edit  
EntryRecord = object
  value*: seq[byte]
  time*: TimeStamp
Source   Edit  
EntrySelector = ref object of RootObj
Source   Edit  
EntryValidator = ref object of RootObj
Source   Edit  
KadDHT = ref object of LPProtocol
  switch*: Switch
  rng*: ref HmacDrbgContext
  rtable*: RoutingTable
  maintenanceLoop*: Future[void]
  republishLoop*: Future[void]
  expiredLoop*: Future[void]
  dataTable*: LocalTable
  bootstrapNodes*: seq[(PeerId, seq[MultiAddress])]
  providerManager*: ProviderManager
  config*: KadDHTConfig
Source   Edit  
KadDHTConfig = ref object
  validator*: EntryValidator
  selector*: EntrySelector
  timeout*: chronos.Duration
  bucketRefreshTime*: chronos.Duration
  retries*: int
  replication*: int
  alpha*: int
  ttl*: chronos.Duration
  quorum*: int
  providerRecordCapacity*: int
  providedKeyCapacity*: int
  republishProvidedKeysInterval*: chronos.Duration
  cleanupProvidersInterval*: chronos.Duration
  providerExpirationInterval*: chronos.Duration
Source   Edit  
Key = seq[byte]
Source   Edit  
LocalTable = Table[Key, EntryRecord]
Source   Edit  
NodeEntry = object
  nodeId*: Key
  lastSeen*: Moment
Source   Edit  
ProvidedKeys = ref object
  provided*: Table[Cid, Moment]
  capacity*: int
Source   Edit  
Provider = Peer
Source   Edit  
ProviderManager = ref object
  providerRecords*: ProviderRecords
  providedKeys*: ProvidedKeys
  knownKeys*: Table[Cid, HashSet[Provider]]
Source   Edit  
ProviderRecord = object
  provider*: Provider
  expiresAt*: chronos.Moment
  key*: Cid
Source   Edit  
ProviderRecords = ref object
  records*: HeapQueue[ProviderRecord]
  capacity*: int
Source   Edit  
ReceivedTable = TableRef[PeerId, Opt[EntryRecord]]
Source   Edit  
RoutingTable = ref object
  selfId*: Key
  buckets*: seq[Bucket]
  config*: RoutingTableConfig
Source   Edit  
RoutingTableConfig = ref object
  replication*: int
  hasher*: Opt[XorDHasher]
  maxBuckets*: int
Source   Edit  
TimeStamp = string
Source   Edit  
XorDHasher = proc (input: seq[byte]): array[IdLength, byte] {....raises: [],
    nimcall, noSideEffect, ...gcsafe.}
Source   Edit  
XorDistance = array[IdLength, byte]
Source   Edit  

Consts

DefaultAlpha = 10
Source   Edit  
DefaultBucketRefreshTime = (value: 600000000000)
Source   Edit  
DefaultCleanupProvidersInterval = (value: 600000000000)
Source   Edit  
DefaultMaxBuckets = 256
Source   Edit  
DefaultProviderExpirationInterval = (value: 1800000000000)
Source   Edit  
DefaultQuorum = 5
Source   Edit  
DefaultReplication = 20
aka k in the spec Source   Edit  
DefaultRepublishInterval = (value: 600000000000)
Source   Edit  
DefaultRetries = 5
Source   Edit  
DefaultTimeout = (value: 5000000000)
Source   Edit  
IdLength = 32
Source   Edit  
KadCodec = "/ipfs/kad/1.0.0"
Source   Edit  
MaxMsgSize = 4096
Source   Edit  

Procs

proc `<`(a, b: XorDistance): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc `<=`(a, b: XorDistance): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc cmp(a, b: XorDistance): int {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc countLeadingZeroBits(b: byte): int {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc get(self: LocalTable; key: Key): Opt[EntryRecord] {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc init(T: typedesc[EntryRecord]; value: Key; time: Opt[TimeStamp]): EntryRecord {.
    ...gcsafe, raises: [].}
Source   Edit  
proc insert(self: var LocalTable; key: Key; value: sink seq[byte];
            time: TimeStamp) {....raises: [], tags: [WriteIOEffect], forbids: [].}
Source   Edit  
proc leadingZeros(dist: XorDistance): int {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc new(T: typedesc[KadDHTConfig];
         validator: EntryValidator = DefaultEntryValidator();
         selector: EntrySelector = DefaultEntrySelector();
         timeout: chronos.Duration = DefaultTimeout;
         bucketRefreshTime: chronos.Duration = DefaultBucketRefreshTime;
         retries: int = DefaultRetries; replication: int = DefaultReplication;
         alpha: int = DefaultAlpha; quorum: int = DefaultQuorum;
         providerRecordCapacity = DefaultProviderRecordCapacity;
         providedKeyCapacity = DefaultProvidedKeyCapacity;
    republishProvidedKeysInterval: chronos.Duration = DefaultRepublishInterval;
    cleanupProvidersInterval: chronos.Duration = DefaultCleanupProvidersInterval;
    providerExpirationInterval: chronos.Duration = DefaultProviderExpirationInterval): T:type {.
    ...raises: [].}
Source   Edit  
proc new(T: typedesc[ProviderManager]; providerRecordCapacity: int;
         providedKeyCapacity: int): T:type
Source   Edit  
proc noOpHasher(input: seq[byte]): array[IdLength, byte] {....raises: [], nimcall,
    noSideEffect, ...gcsafe, tags: [], forbids: [].}
Source   Edit  
proc shortLog(k: Key): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc toCid(k: Key): Cid {....raises: [], tags: [WriteIOEffect, RootEffect],
                          forbids: [].}
Source   Edit  
proc toKey(c: Cid): Key {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc toKey(mh: MultiHash): Key {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc toKey(p: PeerId): Key {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc toPeer(k: Key; switch: Switch): Result[Peer, string] {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc toPeer(peerInfo: PeerInfo): Peer {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc toPeerId(k: Key): Result[PeerId, string] {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc toPeerIds(peers: seq[Peer]): seq[PeerId] {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc xorDistance(a, b: Key; hasher: Opt[XorDHasher]): XorDistance {....raises: [],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc xorDistance(a, b: PeerId; hasher: Opt[XorDHasher]): XorDistance {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  
proc xorDistance(a: Key; b: PeerId; hasher: Opt[XorDHasher]): XorDistance {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  
proc xorDistance(a: PeerId; b: Key; hasher: Opt[XorDHasher]): XorDistance {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  

Methods

method isValid(self: DefaultEntryValidator; key: Key; record: EntryRecord): bool {.
    ...raises: [], gcsafe, tags: [], forbids: [].}
Source   Edit  
method isValid(self: EntryValidator; key: Key; record: EntryRecord): bool {.
    base, ...raises: [], gcsafe, tags: [], forbids: [].}
Source   Edit  
method select(self: DefaultEntrySelector; key: Key; records: seq[EntryRecord]): Result[
    int, string] {....raises: [], gcsafe, tags: [], forbids: [].}
Source   Edit  
method select(self: EntrySelector; key: Key; records: seq[EntryRecord]): Result[
    int, string] {.base, ...raises: [], gcsafe, tags: [], forbids: [].}
Source   Edit  

Templates

template formatItIMPL(it: Key): auto
Source   Edit