Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
feat: add peer tagging (#255)
Browse files Browse the repository at this point in the history
Allow tagging peers to better prioritise which connections to kill
when hitting limits.  Also for keeping "priority" connections alive.

Refs: libp2p/js-libp2p#369
  • Loading branch information
achingbrain authored Jun 24, 2022
1 parent 9f8d5f4 commit 80dadd9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/interface-peer-store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ export interface PeerStoreInit {
addressFilter?: AddressFilter
}

export interface TagOptions {
value?: number
ttl?: number
}

export interface Tag {
name: string
value: number
}

export interface PeerStore extends EventEmitter<PeerStoreEvents> {
addressBook: AddressBook
keyBook: KeyBook
Expand All @@ -241,4 +251,8 @@ export interface PeerStore extends EventEmitter<PeerStoreEvents> {
delete: (peerId: PeerId) => Promise<void>
has: (peerId: PeerId) => Promise<boolean>
get: (peerId: PeerId) => Promise<Peer>

tagPeer: (peerId: PeerId, tag: string, options?: TagOptions) => Promise<void>
unTagPeer: (peerId: PeerId, tag: string) => Promise<void>
getTags: (peerId: PeerId) => Promise<Tag[]>
}

0 comments on commit 80dadd9

Please sign in to comment.