Stores generic informations about peers.
Example:
# Will keep info of all connected peers + # last 50 disconnected peers let peerStore = PeerStore.new(capacity = 50) # Create a custom book type type MoodBook = ref object of PeerBook[string] var somePeerId = PeerId.random().expect("get random key") peerStore[MoodBook][somePeerId] = "Happy" doAssert peerStore[MoodBook][somePeerId] == "Happy"##############################################################################
Types
AddressBook {.public.} = ref object of SeqPeerBook[MultiAddress]
- Source Edit
PeerBookChangeHandler = proc (peerId: PeerId) {....gcsafe, raises: [].}
- Source Edit
ProtoBook {.public.} = ref object of SeqPeerBook[string]
- Source Edit
ProtoVersionBook {.public.} = ref object of PeerBook[string]
- Source Edit
SeqPeerBook[T] = ref object of PeerBook[seq[T]]
- Source Edit
Procs
proc `[]`[T](p: PeerStore; typ: type[T]): T {.public, ...raises: [].}
- Get a book from the PeerStore (ex: peerStoreAddressBook) Source Edit
proc addHandler[T](peerBook: PeerBook[T]; handler: PeerBookChangeHandler) {. public, ...raises: [].}
- Adds a callback that will be called everytime the book changes Source Edit
proc getMostObservedProtosAndPorts(self: PeerStore): seq[MultiAddress] {. ...raises: [], tags: [], forbids: [].}
- Source Edit
proc guessDialableAddr(self: PeerStore; ma: MultiAddress): MultiAddress {. ...raises: [], tags: [RootEffect], forbids: [].}
- Source Edit
proc updatePeerInfo(peerStore: PeerStore; info: IdentifyInfo) {....raises: [], tags: [RootEffect], forbids: [].}
- Source Edit