From 95ce5df6dfebb6b4029d6aa7dce9006946fd9888 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 22 Jun 2022 10:17:35 +0100 Subject: [PATCH] feat: add peer tagging Allow tagging peers to better prioritise which connections to kill when hitting limits. Also for keeping "priority" connections alive. Refs: https://github.com/libp2p/js-libp2p/issues/369 --- packages/interface-peer-store/src/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/interface-peer-store/src/index.ts b/packages/interface-peer-store/src/index.ts index 059c01069..1328775c4 100644 --- a/packages/interface-peer-store/src/index.ts +++ b/packages/interface-peer-store/src/index.ts @@ -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 { addressBook: AddressBook keyBook: KeyBook @@ -241,4 +251,8 @@ export interface PeerStore extends EventEmitter { delete: (peerId: PeerId) => Promise has: (peerId: PeerId) => Promise get: (peerId: PeerId) => Promise + + tagPeer: (peerId: PeerId, tag: string, options?: TagOptions) => Promise + unTagPeer: (peerId: PeerId, tag: string) => Promise + getTags: (peerId: PeerId) => Promise }