protect method

  1. @override
void protect(
  1. PeerId peerId,
  2. String tag
)
override

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.

Implementation

@override
void protect(PeerId peerId, String tag) {
  final protections = _protections[peerId] ?? <String>{};
  protections.add(tag);
  _protections[peerId] = protections;
}