Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Add peer protection capability #14

Merged
merged 3 commits into from
Mar 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

inet "github.com/libp2p/go-libp2p-net"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
)

// ConnManager tracks connections to peers, and allows consumers to associate metadata
Expand All @@ -31,6 +31,20 @@ type ConnManager interface {
// Notifee returns an implementation that can be called back to inform of
// opened and closed connections.
Notifee() inet.Notifiee

// Protect protects a peer from having its connection(s) pruned.
//
// Tagging allows different parts of the system to manage protections without interfering with one another.
//
// Calls to Protect() with the same tag are idempotent. They are not refcounted, so after multiple calls
// to Protect() with the same tag, a single Unprotect() call bearing the same tag will revoke the protection.
Protect(id peer.ID, tag string)

// Unprotect removes a protection that may have been placed on a peer, under the specified tag.
//
// The return value indicates whether the peer continues to be protected after this call, by way of a different tag.
// See notes on Protect() for more info.
Unprotect(id peer.ID, tag string) (protected bool)
}

// TagInfo stores metadata associated with a peer.
Expand Down