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
CandidatePeers = ref HashSet[PeerId]
- Source Edit
DefaultEntrySelector = ref object of EntrySelector
- Source Edit
DefaultEntryValidator = ref object of EntryValidator
- 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
LocalTable = Table[Key, EntryRecord]
- Source Edit
ProvidedKeys = ref object provided*: Table[Cid, Moment] capacity*: int
- 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
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
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 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 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