1187 lines
100 KiB
HTML
1187 lines
100 KiB
HTML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<!-- This file is generated by Nim. -->
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<!-- Favicon -->
|
|
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
|
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
|
|
|
<!-- Google fonts -->
|
|
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
|
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
|
|
|
<!-- CSS -->
|
|
<title>libp2p/protocols/pubsub/pubsub</title>
|
|
<link rel="stylesheet" type="text/css" href="../../../nimdoc.out.css">
|
|
|
|
<script type="text/javascript" src="../../../dochack.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
function main() {
|
|
var pragmaDots = document.getElementsByClassName("pragmadots");
|
|
for (var i = 0; i < pragmaDots.length; i++) {
|
|
pragmaDots[i].onclick = function(event) {
|
|
// Hide tease
|
|
event.target.parentNode.style.display = "none";
|
|
// Show actual
|
|
event.target.parentNode.nextElementSibling.style.display = "inline";
|
|
}
|
|
}
|
|
|
|
function switchTheme(e) {
|
|
if (e.target.checked) {
|
|
document.documentElement.setAttribute('data-theme', 'dark');
|
|
localStorage.setItem('theme', 'dark');
|
|
} else {
|
|
document.documentElement.setAttribute('data-theme', 'light');
|
|
localStorage.setItem('theme', 'light');
|
|
}
|
|
}
|
|
|
|
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
|
|
if (toggleSwitch !== null) {
|
|
toggleSwitch.addEventListener('change', switchTheme, false);
|
|
}
|
|
|
|
var currentTheme = localStorage.getItem('theme');
|
|
if (!currentTheme && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
currentTheme = 'dark';
|
|
}
|
|
if (currentTheme) {
|
|
document.documentElement.setAttribute('data-theme', currentTheme);
|
|
|
|
if (currentTheme === 'dark' && toggleSwitch !== null) {
|
|
toggleSwitch.checked = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
window.addEventListener('DOMContentLoaded', main);
|
|
</script>
|
|
|
|
</head>
|
|
<body>
|
|
<div class="document" id="documentId">
|
|
<div class="container">
|
|
<h1 class="title">libp2p/protocols/pubsub/pubsub</h1>
|
|
<div class="row">
|
|
<div class="three columns">
|
|
<div class="theme-switch-wrapper">
|
|
<label class="theme-switch" for="checkbox">
|
|
<input type="checkbox" id="checkbox" />
|
|
<div class="slider round"></div>
|
|
</label>
|
|
<em>Dark Mode</em>
|
|
</div>
|
|
<div id="global-links">
|
|
<ul class="simple">
|
|
<li>
|
|
<a href="../../../theindex.html">Index</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchInputDiv">
|
|
Search: <input type="text" id="searchInput"
|
|
onkeyup="search()" />
|
|
</div>
|
|
<div>
|
|
Group by:
|
|
<select onchange="groupBy(this.value)">
|
|
<option value="section">Section</option>
|
|
<option value="type">Type</option>
|
|
</select>
|
|
</div>
|
|
<script type="text/javascript">
|
|
function main2() {
|
|
// Create the slider
|
|
var firstSlider = document.getElementsByClassName("theme-switch-wrapper")[0];
|
|
var newSlider = document.createRange().createContextualFragment(`
|
|
<div class="theme-switch-wrapper">
|
|
<label class="theme-switch" for="internalcheckbox">
|
|
<input type="checkbox" id="internalcheckbox">
|
|
<div class="slider round"></div>
|
|
</label>
|
|
<em>Internal</em>
|
|
</div>
|
|
`);
|
|
|
|
var sliderInst = firstSlider.after(newSlider);
|
|
|
|
// Restore slider state from storage
|
|
var currentMode = localStorage.getItem('privateMode');
|
|
if (currentMode == "private") {
|
|
document.getElementById("internalcheckbox").checked = true;
|
|
} else {
|
|
hidePrivateProcs();
|
|
}
|
|
|
|
document.getElementById("internalcheckbox").onclick = togglePrivateProcs;
|
|
}
|
|
|
|
function hidePrivateProcs() {
|
|
var toHide = document.getElementsByClassName("tohide");
|
|
for (var i = 0; i < toHide.length; i++) {
|
|
var pragmas = toHide[i].querySelectorAll("span.Identifier");
|
|
var public = false;
|
|
for (var z = 0; z < pragmas.length; z++) {
|
|
if (pragmas[z].innerText == "public") {
|
|
public = true;
|
|
break;
|
|
}
|
|
}
|
|
if (public == false) {
|
|
toHide[i].style.display = "none";
|
|
toHide[i].classList.add("hidden");
|
|
links = document.querySelectorAll("a[href='#" + encodeURIComponent(toHide[i].id) + "']");
|
|
for (var y = 0; y < links.length; y++) {
|
|
links[y].parentNode.style.display = "none";
|
|
links[y].parentNode.classList.add("hidden");
|
|
}
|
|
}
|
|
}
|
|
|
|
// TOC
|
|
var nestedSections = document.getElementsByClassName("nested-toc-section");
|
|
for (var i = 0; i < nestedSections.length; i++) {
|
|
if (nestedSections[i].querySelectorAll("li:not(.hidden)").length == 0) {
|
|
nestedSections[i].style.display = "none";
|
|
nestedSections[i].classList.add("hidden");
|
|
}
|
|
}
|
|
|
|
var sections = document.getElementsByClassName("simple-toc-section");
|
|
for (var i = 0; i < sections.length; i++) {
|
|
if (sections[i].querySelectorAll(".nested-toc-section:not(.hidden)").length == 0) {
|
|
sections[i].parentNode.style.display = "none";
|
|
sections[i].parentNode.classList.add("hidden");
|
|
}
|
|
|
|
}
|
|
|
|
// Sections
|
|
var sections = document.getElementsByClassName("section");
|
|
for (var i = 0; i < sections.length; i++) {
|
|
if (sections[i].querySelectorAll(".item > div").length == 0) continue;
|
|
if (sections[i].querySelectorAll(".item > div:not(.hidden)").length == 0) {
|
|
sections[i].style.display = "none";
|
|
sections[i].classList.add("hidden");
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
function showPrivateProcs() {
|
|
var toHide = Array.from(document.getElementsByClassName("hidden"));
|
|
for (var i = 0; i < toHide.length; i++) {
|
|
toHide[i].style.display = "";
|
|
toHide[i].classList.remove("hidden");
|
|
}
|
|
}
|
|
|
|
function togglePrivateProcs() {
|
|
if (document.getElementById("internalcheckbox").checked) {
|
|
localStorage.setItem('privateMode', 'private');
|
|
showPrivateProcs();
|
|
} else {
|
|
localStorage.setItem('privateMode', 'public');
|
|
hidePrivateProcs();
|
|
}
|
|
}
|
|
window.addEventListener("DOMContentLoaded", main2);
|
|
</script>
|
|
<ul class="simple simple-toc" id="toc-list">
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
|
<ul class="simple simple-toc-section">
|
|
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
|
|
<ul class="simple simple-toc-section">
|
|
<li><a class="reference" href="#InitializationError"
|
|
title="InitializationError = object of LPError">InitializationError</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_broadcast_graft"
|
|
title="libp2p_pubsub_broadcast_graft = IgnoredCollector">libp2p_pubsub_broadcast_graft</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_broadcast_ihave"
|
|
title="libp2p_pubsub_broadcast_ihave = IgnoredCollector">libp2p_pubsub_broadcast_ihave</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_broadcast_iwant"
|
|
title="libp2p_pubsub_broadcast_iwant = IgnoredCollector">libp2p_pubsub_broadcast_iwant</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_broadcast_messages"
|
|
title="libp2p_pubsub_broadcast_messages = IgnoredCollector">libp2p_pubsub_broadcast_messages</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_broadcast_prune"
|
|
title="libp2p_pubsub_broadcast_prune = IgnoredCollector">libp2p_pubsub_broadcast_prune</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_broadcast_subscriptions"
|
|
title="libp2p_pubsub_broadcast_subscriptions = IgnoredCollector">libp2p_pubsub_broadcast_subscriptions</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_broadcast_unsubscriptions"
|
|
title="libp2p_pubsub_broadcast_unsubscriptions = IgnoredCollector">libp2p_pubsub_broadcast_unsubscriptions</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_messages_published"
|
|
title="libp2p_pubsub_messages_published = IgnoredCollector">libp2p_pubsub_messages_published</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_messages_rebroadcasted"
|
|
title="libp2p_pubsub_messages_rebroadcasted = IgnoredCollector">libp2p_pubsub_messages_rebroadcasted</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_received_graft"
|
|
title="libp2p_pubsub_received_graft = IgnoredCollector">libp2p_pubsub_received_graft</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_received_ihave"
|
|
title="libp2p_pubsub_received_ihave = IgnoredCollector">libp2p_pubsub_received_ihave</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_received_iwant"
|
|
title="libp2p_pubsub_received_iwant = IgnoredCollector">libp2p_pubsub_received_iwant</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_received_messages"
|
|
title="libp2p_pubsub_received_messages = IgnoredCollector">libp2p_pubsub_received_messages</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_received_prune"
|
|
title="libp2p_pubsub_received_prune = IgnoredCollector">libp2p_pubsub_received_prune</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_received_subscriptions"
|
|
title="libp2p_pubsub_received_subscriptions = IgnoredCollector">libp2p_pubsub_received_subscriptions</a></li>
|
|
<li><a class="reference" href="#libp2p_pubsub_received_unsubscriptions"
|
|
title="libp2p_pubsub_received_unsubscriptions = IgnoredCollector">libp2p_pubsub_received_unsubscriptions</a></li>
|
|
<li><a class="reference" href="#MsgIdProvider"
|
|
title="MsgIdProvider {.public.} = proc (m: Message): Result[MessageId, ValidationResult] {.
|
|
noSideEffect, raises: [], gcsafe.}">MsgIdProvider</a></li>
|
|
<li><a class="reference" href="#PubSub"
|
|
title="PubSub {.public.} = ref object of LPProtocol
|
|
switch*: Switch
|
|
peerInfo*: PeerInfo
|
|
topics*: Table[string, seq[TopicHandler]]
|
|
peers*: Table[PeerId, PubSubPeer]
|
|
triggerSelf*: bool ## trigger own local handler on publish
|
|
verifySignature*: bool ## enable signature verification
|
|
sign*: bool ## enable message signing
|
|
validators*: Table[string, HashSet[ValidatorHandler]]
|
|
observers: ref seq[PubSubObserver]
|
|
msgIdProvider*: MsgIdProvider ## Turn message into message id (not nil)
|
|
msgSeqno*: uint64
|
|
anonymize*: bool ## if we omit fromPeer and seqno from RPC messages we send
|
|
subscriptionValidator*: SubscriptionValidator
|
|
topicsHigh*: int ## the maximum number of topics a peer is allowed to subscribe to
|
|
maxMessageSize*: int ## \
|
|
## the maximum raw message size we'll globally allow
|
|
## for finer tuning, check message size on topic validator
|
|
##
|
|
## sending a big message to a peer with a lower size limit can
|
|
## lead to issues, from descoring to connection drops
|
|
##
|
|
## defaults to 1mB
|
|
rng*: ref HmacDrbgContext
|
|
knownTopics*: HashSet[string]">PubSub</a></li>
|
|
<li><a class="reference" href="#SubscriptionValidator"
|
|
title="SubscriptionValidator {.public.} = proc (topic: string): bool {.raises: [],
|
|
gcsafe.}">SubscriptionValidator</a></li>
|
|
<li><a class="reference" href="#TopicHandler"
|
|
title="TopicHandler {.public.} = proc (topic: string; data: seq[byte]): Future[void] {.
|
|
gcsafe, raises: [].}">TopicHandler</a></li>
|
|
<li><a class="reference" href="#TopicPair"
|
|
title="TopicPair = tuple[topic: string, handler: TopicHandler]">TopicPair</a></li>
|
|
<li><a class="reference" href="#ValidatorHandler"
|
|
title="ValidatorHandler {.public.} = proc (topic: string; message: Message): Future[
|
|
ValidationResult] {.gcsafe, raises: [].}">ValidatorHandler</a></li>
|
|
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#10" id="60">Consts</a>
|
|
<ul class="simple simple-toc-section">
|
|
<li><a class="reference" href="#KnownLibP2PTopics"
|
|
title="KnownLibP2PTopics = """>KnownLibP2PTopics</a></li>
|
|
<li><a class="reference" href="#KnownLibP2PTopicsSeq"
|
|
title="KnownLibP2PTopicsSeq = [""]">KnownLibP2PTopicsSeq</a></li>
|
|
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
|
|
<ul class="simple simple-toc-section">
|
|
<ul class="simple nested-toc-section">addObserver
|
|
<li><a class="reference" href="#addObserver%2CPubSub%2CPubSubObserver"
|
|
title="addObserver(p: PubSub; observer: PubSubObserver)">addObserver(p: PubSub; observer: PubSubObserver)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">broadcast
|
|
<li><a class="reference" href="#broadcast%2CPubSub%2Cauto%2CRPCMsg%2Cbool"
|
|
title="broadcast(p: PubSub; sendPeers: auto; msg: RPCMsg; isHighPriority: bool)">broadcast(p: PubSub; sendPeers: auto; msg: RPCMsg; isHighPriority: bool)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">handleData
|
|
<li><a class="reference" href="#handleData%2CPubSub%2Cstring%2Cseq%5Bbyte%5D"
|
|
title="handleData(p: PubSub; topic: string; data: seq[byte]): Future[void]">handleData(p: PubSub; topic: string; data: seq[byte]): Future[void]</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">init
|
|
<li><a class="reference" href="#init%2Ctypedesc%5BPubSub%5D%2CSwitch%2Cbool%2Cbool%2Cbool%2Cbool%2CMsgIdProvider%2CSubscriptionValidator%2Cint%2Cref.HmacDrbgContext%2CPubParams"
|
|
title="init[PubParams: object | bool](P: typedesc[PubSub]; switch: Switch;
|
|
triggerSelf: bool = false;
|
|
anonymize: bool = false;
|
|
verifySignature: bool = true; sign: bool = true;
|
|
msgIdProvider: MsgIdProvider = defaultMsgIdProvider; subscriptionValidator: SubscriptionValidator = nil;
|
|
maxMessageSize: int = 1024 * 1024;
|
|
rng: ref HmacDrbgContext = newRng();
|
|
parameters: PubParams = false): P:type">init[PubParams: object | bool](P: typedesc[PubSub]; switch: Switch;
|
|
triggerSelf: bool = false;
|
|
anonymize: bool = false;
|
|
verifySignature: bool = true; sign: bool = true;
|
|
msgIdProvider: MsgIdProvider = defaultMsgIdProvider; subscriptionValidator: SubscriptionValidator = nil;
|
|
maxMessageSize: int = 1024 * 1024;
|
|
rng: ref HmacDrbgContext = newRng();
|
|
parameters: PubParams = false): P:type</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">removeObserver
|
|
<li><a class="reference" href="#removeObserver%2CPubSub%2CPubSubObserver"
|
|
title="removeObserver(p: PubSub; observer: PubSubObserver)">removeObserver(p: PubSub; observer: PubSubObserver)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">send
|
|
<li><a class="reference" href="#send%2CPubSub%2CPubSubPeer%2CRPCMsg%2Cbool"
|
|
title="send(p: PubSub; peer: PubSubPeer; msg: RPCMsg; isHighPriority: bool)">send(p: PubSub; peer: PubSubPeer; msg: RPCMsg; isHighPriority: bool)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">sendSubs
|
|
<li><a class="reference" href="#sendSubs%2CPubSub%2CPubSubPeer%2CopenArray%5Bstring%5D%2Cbool"
|
|
title="sendSubs(p: PubSub; peer: PubSubPeer; topics: openArray[string]; subscribe: bool)">sendSubs(p: PubSub; peer: PubSubPeer; topics: openArray[string]; subscribe: bool)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">subscribe
|
|
<li><a class="reference" href="#subscribe%2CPubSub%2Cstring%2CTopicHandler"
|
|
title="subscribe(p: PubSub; topic: string; handler: TopicHandler)">subscribe(p: PubSub; topic: string; handler: TopicHandler)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">unsubscribe
|
|
<li><a class="reference" href="#unsubscribe%2CPubSub%2Cstring%2CTopicHandler"
|
|
title="unsubscribe(p: PubSub; topic: string; handler: TopicHandler)">unsubscribe(p: PubSub; topic: string; handler: TopicHandler)</a></li>
|
|
<li><a class="reference" href="#unsubscribe%2CPubSub%2CopenArray%5BTopicPair%5D"
|
|
title="unsubscribe(p: PubSub; topics: openArray[TopicPair])">unsubscribe(p: PubSub; topics: openArray[TopicPair])</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">unsubscribeAll
|
|
<li><a class="reference" href="#unsubscribeAll%2CPubSub%2Cstring"
|
|
title="unsubscribeAll(p: PubSub; topic: string)">unsubscribeAll(p: PubSub; topic: string)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">updateMetrics
|
|
<li><a class="reference" href="#updateMetrics%2CPubSub%2CRPCMsg"
|
|
title="updateMetrics(p: PubSub; rpcMsg: RPCMsg)">updateMetrics(p: PubSub; rpcMsg: RPCMsg)</a></li>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#14" id="64">Methods</a>
|
|
<ul class="simple simple-toc-section">
|
|
<ul class="simple nested-toc-section">addValidator
|
|
<li><a class="reference" href="#addValidator.e%2CPubSub%2Cvarargs%5Bstring%5D%2CValidatorHandler"
|
|
title="addValidator(p: PubSub; topic: varargs[string]; hook: ValidatorHandler)">addValidator(p: PubSub; topic: varargs[string]; hook: ValidatorHandler)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">getOrCreatePeer
|
|
<li><a class="reference" href="#getOrCreatePeer.e%2CPubSub%2CPeerId%2Cseq%5Bstring%5D"
|
|
title="getOrCreatePeer(p: PubSub; peerId: PeerId; protos: seq[string]): PubSubPeer">getOrCreatePeer(p: PubSub; peerId: PeerId; protos: seq[string]): PubSubPeer</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">handleConn
|
|
<li><a class="reference" href="#handleConn.e%2CPubSub%2CConnection%2Cstring"
|
|
title="handleConn(p: PubSub; conn: Connection; proto: string): Future[void]">handleConn(p: PubSub; conn: Connection; proto: string): Future[void]</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">initPubSub
|
|
<li><a class="reference" href="#initPubSub.e%2CPubSub"
|
|
title="initPubSub(p: PubSub)">initPubSub(p: PubSub)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">onPubSubPeerEvent
|
|
<li><a class="reference" href="#onPubSubPeerEvent.e%2CPubSub%2CPubSubPeer%2CPubSubPeerEvent"
|
|
title="onPubSubPeerEvent(p: PubSub; peer: PubSubPeer; event: PubSubPeerEvent)">onPubSubPeerEvent(p: PubSub; peer: PubSubPeer; event: PubSubPeerEvent)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">onTopicSubscription
|
|
<li><a class="reference" href="#onTopicSubscription.e%2CPubSub%2Cstring%2Cbool"
|
|
title="onTopicSubscription(p: PubSub; topic: string; subscribed: bool)">onTopicSubscription(p: PubSub; topic: string; subscribed: bool)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">publish
|
|
<li><a class="reference" href="#publish.e%2CPubSub%2Cstring%2Cseq%5Bbyte%5D"
|
|
title="publish(p: PubSub; topic: string; data: seq[byte]): Future[int]">publish(p: PubSub; topic: string; data: seq[byte]): Future[int]</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">removeValidator
|
|
<li><a class="reference" href="#removeValidator.e%2CPubSub%2Cvarargs%5Bstring%5D%2CValidatorHandler"
|
|
title="removeValidator(p: PubSub; topic: varargs[string]; hook: ValidatorHandler)">removeValidator(p: PubSub; topic: varargs[string]; hook: ValidatorHandler)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">rpcHandler
|
|
<li><a class="reference" href="#rpcHandler.e%2CPubSub%2CPubSubPeer%2Cseq%5Bbyte%5D"
|
|
title="rpcHandler(p: PubSub; peer: PubSubPeer; data: seq[byte]): Future[void]">rpcHandler(p: PubSub; peer: PubSubPeer; data: seq[byte]): Future[void]</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">subscribePeer
|
|
<li><a class="reference" href="#subscribePeer.e%2CPubSub%2CPeerId"
|
|
title="subscribePeer(p: PubSub; peer: PeerId)">subscribePeer(p: PubSub; peer: PeerId)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">unsubscribePeer
|
|
<li><a class="reference" href="#unsubscribePeer.e%2CPubSub%2CPeerId"
|
|
title="unsubscribePeer(p: PubSub; peerId: PeerId)">unsubscribePeer(p: PubSub; peerId: PeerId)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">validate
|
|
<li><a class="reference" href="#validate.e%2CPubSub%2CMessage"
|
|
title="validate(p: PubSub; message: Message): Future[ValidationResult]">validate(p: PubSub; message: Message): Future[ValidationResult]</a></li>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#19" id="69">Exports</a>
|
|
<ul class="simple simple-toc-section">
|
|
|
|
</ul>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L1"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
<div class="nine columns" id="content">
|
|
<div id="tocRoot"></div>
|
|
|
|
<p class="module-desc"><p>Base interface for pubsub protocols</p>
|
|
<p>You can <a class="reference external" href="#subscribe%2CPubSub%2Cstring%2CTopicHandler">subscribe</a> to a topic, <a class="reference external" href="#publish.e%2CPubSub%2Cstring%2Cseq%5Bbyte%5D">publish</a> something on it, and eventually <a class="reference external" href="#unsubscribe%2CPubSub%2Cstring%2CTopicHandler">unsubscribe</a> from it.</p>
|
|
</p>
|
|
<div class="section" id="6">
|
|
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
|
<dl class="item">
|
|
<a class="reference external" href="errors.html">errors</a>, <a class="reference external" href="pubsubpeer.html">pubsubpeer</a>, <a class="reference external" href="rpc/message.html">rpc/message</a>, <a class="reference external" href="rpc/messages.html">rpc/messages</a>, <a class="reference external" href="rpc/protobuf.html">rpc/protobuf</a>, <a class="reference external" href="../../switch.html">../../switch</a>, <a class="reference external" href="../protocol.html">../protocol</a>, <a class="reference external" href="../../crypto/crypto.html">../../crypto/crypto</a>, <a class="reference external" href="../../stream/connection.html">../../stream/connection</a>, <a class="reference external" href="../../peerid.html">../../peerid</a>, <a class="reference external" href="../../peerinfo.html">../../peerinfo</a>, <a class="reference external" href="../../errors.html">../../errors</a>, <a class="reference external" href="../../utility.html">../../utility</a>
|
|
</dl></div>
|
|
<div class="section" id="7">
|
|
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
|
<dl class="item">
|
|
<div id="InitializationError" class="tohide">
|
|
<dt><pre><a href="pubsub.html#InitializationError"><span class="Identifier">InitializationError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="../../errors.html#LPError"><span class="Identifier">LPError</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L84"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L84" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_broadcast_graft" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_broadcast_graft"><span class="Identifier">libp2p_pubsub_broadcast_graft</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_broadcast_ihave" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_broadcast_ihave"><span class="Identifier">libp2p_pubsub_broadcast_ihave</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_broadcast_iwant" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_broadcast_iwant"><span class="Identifier">libp2p_pubsub_broadcast_iwant</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_broadcast_messages" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_broadcast_messages"><span class="Identifier">libp2p_pubsub_broadcast_messages</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_broadcast_prune" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_broadcast_prune"><span class="Identifier">libp2p_pubsub_broadcast_prune</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_broadcast_subscriptions" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_broadcast_subscriptions"><span class="Identifier">libp2p_pubsub_broadcast_subscriptions</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_broadcast_unsubscriptions" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_broadcast_unsubscriptions"><span class="Identifier">libp2p_pubsub_broadcast_unsubscriptions</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_messages_published" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_messages_published"><span class="Identifier">libp2p_pubsub_messages_published</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_messages_rebroadcasted" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_messages_rebroadcasted"><span class="Identifier">libp2p_pubsub_messages_rebroadcasted</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_received_graft" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_received_graft"><span class="Identifier">libp2p_pubsub_received_graft</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_received_ihave" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_received_ihave"><span class="Identifier">libp2p_pubsub_received_ihave</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_received_iwant" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_received_iwant"><span class="Identifier">libp2p_pubsub_received_iwant</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_received_messages" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_received_messages"><span class="Identifier">libp2p_pubsub_received_messages</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_received_prune" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_received_prune"><span class="Identifier">libp2p_pubsub_received_prune</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_received_subscriptions" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_received_subscriptions"><span class="Identifier">libp2p_pubsub_received_subscriptions</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="libp2p_pubsub_received_unsubscriptions" class="tohide">
|
|
<dt><pre><a href="pubsub.html#libp2p_pubsub_received_unsubscriptions"><span class="Identifier">libp2p_pubsub_received_unsubscriptions</span></a> <span class="Other">=</span> <span class="Identifier">IgnoredCollector</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/nimbledeps/pkgs/metrics-#6142e433fc8ea9b73379770a788017ac528d46ff/metrics.nim#L578" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="MsgIdProvider" class="tohide">
|
|
<dt><pre><a href="pubsub.html#MsgIdProvider"><span class="Identifier">MsgIdProvider</span></a> {.<span class="Identifier">public</span>.} <span class="Other">=</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">m</span><span class="Other">:</span> <a href="rpc/messages.html#Message"><span class="Identifier">Message</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Result</span><span class="Other">[</span><a href="rpc/messages.html#MessageId"><span class="Identifier">MessageId</span></a><span class="Other">,</span> <a href="errors.html#ValidationResult"><span class="Identifier">ValidationResult</span></a><span class="Other">]</span> {.
|
|
<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L94"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L94" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="PubSub" class="tohide">
|
|
<dt><pre><a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a> {.<span class="Identifier">public</span>.} <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="../protocol.html#LPProtocol"><span class="Identifier">LPProtocol</span></a>
|
|
<span class="Identifier">switch</span><span class="Operator">*</span><span class="Other">:</span> <a href="../../transports/transport.html#Switch"><span class="Identifier">Switch</span></a>
|
|
<span class="Identifier">peerInfo</span><span class="Operator">*</span><span class="Other">:</span> <a href="../../peerinfo.html#PeerInfo"><span class="Identifier">PeerInfo</span></a>
|
|
<span class="Identifier">topics</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">Table</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">,</span> <span class="Identifier">seq</span><span class="Other">[</span><a href="pubsub.html#TopicHandler"><span class="Identifier">TopicHandler</span></a><span class="Other">]</span><span class="Other">]</span>
|
|
<span class="Identifier">peers</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">Table</span><span class="Other">[</span><a href="../../peerid.html#PeerId"><span class="Identifier">PeerId</span></a><span class="Other">,</span> <a href="pubsubpeer.html#PubSubPeer"><span class="Identifier">PubSubPeer</span></a><span class="Other">]</span>
|
|
<span class="Identifier">triggerSelf</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Comment">## trigger own local handler on publish</span>
|
|
<span class="Identifier">verifySignature</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Comment">## enable signature verification</span>
|
|
<span class="Identifier">sign</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Comment">## enable message signing</span>
|
|
<span class="Identifier">validators</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">Table</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">,</span> <span class="Identifier">HashSet</span><span class="Other">[</span><a href="pubsub.html#ValidatorHandler"><span class="Identifier">ValidatorHandler</span></a><span class="Other">]</span><span class="Other">]</span>
|
|
<span class="Identifier">observers</span><span class="Other">:</span> <span class="Keyword">ref</span> <span class="Identifier">seq</span><span class="Other">[</span><a href="pubsubpeer.html#PubSubObserver"><span class="Identifier">PubSubObserver</span></a><span class="Other">]</span>
|
|
<span class="Identifier">msgIdProvider</span><span class="Operator">*</span><span class="Other">:</span> <a href="pubsub.html#MsgIdProvider"><span class="Identifier">MsgIdProvider</span></a> <span class="Comment">## Turn message into message id (not nil)</span>
|
|
<span class="Identifier">msgSeqno</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">uint64</span>
|
|
<span class="Identifier">anonymize</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Comment">## if we omit fromPeer and seqno from RPC messages we send</span>
|
|
<span class="Identifier">subscriptionValidator</span><span class="Operator">*</span><span class="Other">:</span> <a href="pubsub.html#SubscriptionValidator"><span class="Identifier">SubscriptionValidator</span></a>
|
|
<span class="Identifier">topicsHigh</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span> <span class="Comment">## the maximum number of topics a peer is allowed to subscribe to</span>
|
|
<span class="Identifier">maxMessageSize</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span> <span class="Comment">## \</span>
|
|
<span class="Comment">## the maximum raw message size we'll globally allow</span>
|
|
<span class="Comment">## for finer tuning, check message size on topic validator</span>
|
|
<span class="Comment">## </span>
|
|
<span class="Comment">## sending a big message to a peer with a lower size limit can</span>
|
|
<span class="Comment">## lead to issues, from descoring to connection drops</span>
|
|
<span class="Comment">## </span>
|
|
<span class="Comment">## defaults to 1mB</span>
|
|
<span class="Identifier">rng</span><span class="Operator">*</span><span class="Other">:</span> <span class="Keyword">ref</span> <span class="Identifier">HmacDrbgContext</span>
|
|
<span class="Identifier">knownTopics</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">HashSet</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span>
|
|
</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L103"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L103" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="SubscriptionValidator" class="tohide">
|
|
<dt><pre><a href="pubsub.html#SubscriptionValidator"><span class="Identifier">SubscriptionValidator</span></a> {.<span class="Identifier">public</span>.} <span class="Other">=</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">gcsafe</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Every time a peer send us a subscription (even to an unknown topic), we have to store it, which may be an attack vector. This callback can be used to reject topic we're not interested in
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L97"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L97" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="TopicHandler" class="tohide">
|
|
<dt><pre><a href="pubsub.html#TopicHandler"><span class="Identifier">TopicHandler</span></a> {.<span class="Identifier">public</span>.} <span class="Other">=</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L86"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L86" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="TopicPair" class="tohide">
|
|
<dt><pre><a href="pubsub.html#TopicPair"><span class="Identifier">TopicPair</span></a> <span class="Other">=</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">,</span> <span class="Identifier">handler</span><span class="Other">:</span> <a href="pubsub.html#TopicHandler"><span class="Identifier">TopicHandler</span></a><span class="Other">]</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L92"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L92" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="ValidatorHandler" class="tohide">
|
|
<dt><pre><a href="pubsub.html#ValidatorHandler"><span class="Identifier">ValidatorHandler</span></a> {.<span class="Identifier">public</span>.} <span class="Other">=</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">message</span><span class="Other">:</span> <a href="rpc/messages.html#Message"><span class="Identifier">Message</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span>
|
|
<a href="errors.html#ValidationResult"><span class="Identifier">ValidationResult</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L89"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L89" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</dl></div>
|
|
<div class="section" id="10">
|
|
<h1><a class="toc-backref" href="#10">Consts</a></h1>
|
|
<dl class="item">
|
|
<div id="KnownLibP2PTopics" class="tohide">
|
|
<dt><pre><a href="pubsub.html#KnownLibP2PTopics"><span class="Identifier">KnownLibP2PTopics</span></a> <span class="Other">=</span> <span class="StringLit">""</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L47"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L47" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="KnownLibP2PTopicsSeq" class="tohide">
|
|
<dt><pre><a href="pubsub.html#KnownLibP2PTopicsSeq"><span class="Identifier">KnownLibP2PTopicsSeq</span></a> <span class="Other">=</span> <span class="Other">[</span><span class="StringLit">""</span><span class="Other">]</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L48"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L48" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</dl></div>
|
|
<div class="section" id="12">
|
|
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
|
<dl class="item">
|
|
<div id="addObserver,PubSub,PubSubObserver" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#addObserver%2CPubSub%2CPubSubObserver"><span class="Identifier">addObserver</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">observer</span><span class="Other">:</span> <a href="pubsubpeer.html#PubSubObserver"><span class="Identifier">PubSubObserver</span></a><span class="Other">)</span> {.<span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L618"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L618" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="broadcast,PubSub,auto,RPCMsg,bool" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#broadcast%2CPubSub%2Cauto%2CRPCMsg%2Cbool"><span class="Identifier">broadcast</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">sendPeers</span><span class="Other">:</span> <span class="Identifier">auto</span><span class="Other">;</span> <span class="Identifier">msg</span><span class="Other">:</span> <a href="rpc/messages.html#RPCMsg"><span class="Identifier">RPCMsg</span></a><span class="Other">;</span> <span class="Identifier">isHighPriority</span><span class="Other">:</span> <span class="Identifier">bool</span><span class="Other">)</span> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>This procedure attempts to send a <tt class="docutils literal"><span class="pre"><span class="Identifier">msg</span></span></tt> (of type <tt class="docutils literal"><span class="pre"><span class="Identifier">RPCMsg</span></span></tt>) to a specified group of peers in the PubSub network.</p>
|
|
<p>Parameters:</p>
|
|
<ul class="simple"><li><tt class="docutils literal"><span class="pre"><span class="Identifier">p</span></span></tt>: The <tt class="docutils literal"><span class="pre"><span class="Identifier">PubSub</span></span></tt> instance.</li>
|
|
<li><tt class="docutils literal"><span class="pre"><span class="Identifier">sendPeers</span></span></tt>: An iterable of <tt class="docutils literal"><span class="pre"><span class="Identifier">PubSubPeer</span></span></tt> instances representing the peers to whom the message should be sent.</li>
|
|
<li><tt class="docutils literal"><span class="pre"><span class="Identifier">msg</span></span></tt>: The <tt class="docutils literal"><span class="pre"><span class="Identifier">RPCMsg</span></span></tt> instance that contains the message to be broadcast.</li>
|
|
<li><tt class="docutils literal"><span class="pre"><span class="Identifier">isHighPriority</span></span></tt>: A boolean indicating whether the message should be treated as high priority.</li>
|
|
</ul>
|
|
<p>High priority messages are sent immediately, while low priority messages are queued and sent only after all high priority messages have been sent.</p>
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L155"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L155" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="handleData,PubSub,string,seq[byte]" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#handleData%2CPubSub%2Cstring%2Cseq%5Bbyte%5D"><span class="Identifier">handleData</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L326"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L326" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="init,typedesc[PubSub],Switch,bool,bool,bool,bool,MsgIdProvider,SubscriptionValidator,int,ref.HmacDrbgContext,PubParams" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#init%2Ctypedesc%5BPubSub%5D%2CSwitch%2Cbool%2Cbool%2Cbool%2Cbool%2CMsgIdProvider%2CSubscriptionValidator%2Cint%2Cref.HmacDrbgContext%2CPubParams"><span class="Identifier">init</span></a><span class="Other">[</span><span class="Identifier">PubParams</span><span class="Other">:</span> <span class="Keyword">object</span> <span class="Operator">|</span> <span class="Identifier">bool</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">P</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">switch</span><span class="Other">:</span> <a href="../../transports/transport.html#Switch"><span class="Identifier">Switch</span></a><span class="Other">;</span>
|
|
<span class="Identifier">triggerSelf</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">;</span>
|
|
<span class="Identifier">anonymize</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">;</span>
|
|
<span class="Identifier">verifySignature</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span>
|
|
<span class="Identifier">sign</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span> <span class="Identifier">msgIdProvider</span><span class="Other">:</span> <a href="pubsub.html#MsgIdProvider"><span class="Identifier">MsgIdProvider</span></a> <span class="Other">=</span> <span class="Identifier">defaultMsgIdProvider</span><span class="Other">;</span>
|
|
<span class="Identifier">subscriptionValidator</span><span class="Other">:</span> <a href="pubsub.html#SubscriptionValidator"><span class="Identifier">SubscriptionValidator</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">;</span>
|
|
<span class="Identifier">maxMessageSize</span><span class="Other">:</span> <span class="Identifier">int</span> <span class="Other">=</span> <span class="DecNumber">1024</span> <span class="Operator">*</span> <span class="DecNumber">1024</span><span class="Other">;</span>
|
|
<span class="Identifier">rng</span><span class="Other">:</span> <span class="Keyword">ref</span> <span class="Identifier">HmacDrbgContext</span> <span class="Other">=</span> <span class="Identifier">newRng</span><span class="Other">(</span><span class="Other">)</span><span class="Other">;</span>
|
|
<span class="Identifier">parameters</span><span class="Other">:</span> <span class="Identifier">PubParams</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">P:type</span> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="pubsub.html#InitializationError"><span class="Identifier">InitializationError</span></a><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L563"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L563" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="removeObserver,PubSub,PubSubObserver" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#removeObserver%2CPubSub%2CPubSubObserver"><span class="Identifier">removeObserver</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">observer</span><span class="Other">:</span> <a href="pubsubpeer.html#PubSubObserver"><span class="Identifier">PubSubObserver</span></a><span class="Other">)</span> {.<span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L620"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L620" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="send,PubSub,PubSubPeer,RPCMsg,bool" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#send%2CPubSub%2CPubSubPeer%2CRPCMsg%2Cbool"><span class="Identifier">send</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">peer</span><span class="Other">:</span> <a href="pubsubpeer.html#PubSubPeer"><span class="Identifier">PubSubPeer</span></a><span class="Other">;</span> <span class="Identifier">msg</span><span class="Other">:</span> <a href="rpc/messages.html#RPCMsg"><span class="Identifier">RPCMsg</span></a><span class="Other">;</span> <span class="Identifier">isHighPriority</span><span class="Other">:</span> <span class="Identifier">bool</span><span class="Other">)</span> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>This procedure attempts to send a <tt class="docutils literal"><span class="pre"><span class="Identifier">msg</span></span></tt> (of type <tt class="docutils literal"><span class="pre"><span class="Identifier">RPCMsg</span></span></tt>) to the specified remote peer in the PubSub network.</p>
|
|
<p>Parameters:</p>
|
|
<ul class="simple"><li><tt class="docutils literal"><span class="pre"><span class="Identifier">p</span></span></tt>: The <tt class="docutils literal"><span class="pre"><span class="Identifier">PubSub</span></span></tt> instance.</li>
|
|
<li><tt class="docutils literal"><span class="pre"><span class="Identifier">peer</span></span></tt>: An instance of <tt class="docutils literal"><span class="pre"><span class="Identifier">PubSubPeer</span></span></tt> representing the peer to whom the message should be sent.</li>
|
|
<li><tt class="docutils literal"><span class="pre"><span class="Identifier">msg</span></span></tt>: The <tt class="docutils literal"><span class="pre"><span class="Identifier">RPCMsg</span></span></tt> instance that contains the message to be sent.</li>
|
|
<li><tt class="docutils literal"><span class="pre"><span class="Identifier">isHighPriority</span></span></tt>: A boolean indicating whether the message should be treated as high priority.</li>
|
|
</ul>
|
|
<p>High priority messages are sent immediately, while low priority messages are queued and sent only after all high priority messages have been sent.</p>
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L141"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L141" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="sendSubs,PubSub,PubSubPeer,openArray[string],bool" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#sendSubs%2CPubSub%2CPubSubPeer%2CopenArray%5Bstring%5D%2Cbool"><span class="Identifier">sendSubs</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">peer</span><span class="Other">:</span> <a href="pubsubpeer.html#PubSubPeer"><span class="Identifier">PubSubPeer</span></a><span class="Other">;</span> <span class="Identifier">topics</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span>
|
|
<span class="Identifier">subscribe</span><span class="Other">:</span> <span class="Identifier">bool</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
send subscriptions to remote peer
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L221"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L221" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="subscribe,PubSub,string,TopicHandler" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#subscribe%2CPubSub%2Cstring%2CTopicHandler"><span class="Identifier">subscribe</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">handler</span><span class="Other">:</span> <a href="pubsub.html#TopicHandler"><span class="Identifier">TopicHandler</span></a><span class="Other">)</span> {.<span class="Identifier">public</span><span class="Other">,</span>
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>subscribe to a topic</p>
|
|
<p><tt class="docutils literal"><span class="pre">topic</span></tt> - a string topic to subscribe to</p>
|
|
<dl class="docutils"><dt><tt class="docutils literal"><span class="pre">handler</span></tt> - user provided proc that</dt>
|
|
<dd>will be triggered on every received message</dd>
|
|
</dl>
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L464"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L464" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="unsubscribe,PubSub,string,TopicHandler" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#unsubscribe%2CPubSub%2Cstring%2CTopicHandler"><span class="Identifier">unsubscribe</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">handler</span><span class="Other">:</span> <a href="pubsub.html#TopicHandler"><span class="Identifier">TopicHandler</span></a><span class="Other">)</span> {.<span class="Identifier">public</span><span class="Other">,</span>
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
unsubscribe from a <tt class="docutils literal"><span class="pre">topic</span></tt> string
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L433"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L433" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="unsubscribe,PubSub,openArray[TopicPair]" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#unsubscribe%2CPubSub%2CopenArray%5BTopicPair%5D"><span class="Identifier">unsubscribe</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">topics</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><a href="pubsub.html#TopicPair"><span class="Identifier">TopicPair</span></a><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
unsubscribe from a list of <tt class="docutils literal"><span class="pre">topic</span></tt> handlers
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L448"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L448" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="unsubscribeAll,PubSub,string" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#unsubscribeAll%2CPubSub%2Cstring"><span class="Identifier">unsubscribeAll</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
unsubscribe every <tt class="docutils literal"><span class="pre"><span class="Identifier">handler</span></span></tt> from <tt class="docutils literal"><span class="pre"><span class="Identifier">topic</span></span></tt>
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L453"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L453" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="updateMetrics,PubSub,RPCMsg" class="tohide">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#updateMetrics%2CPubSub%2CRPCMsg"><span class="Identifier">updateMetrics</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">rpcMsg</span><span class="Other">:</span> <a href="rpc/messages.html#RPCMsg"><span class="Identifier">RPCMsg</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L240"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L240" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</dl></div>
|
|
<div class="section" id="14">
|
|
<h1><a class="toc-backref" href="#14">Methods</a></h1>
|
|
<dl class="item">
|
|
<div id="addValidator.e,PubSub,varargs[string],ValidatorHandler" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#addValidator.e%2CPubSub%2Cvarargs%5Bstring%5D%2CValidatorHandler"><span class="Identifier">addValidator</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">varargs</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">hook</span><span class="Other">:</span> <a href="pubsub.html#ValidatorHandler"><span class="Identifier">ValidatorHandler</span></a><span class="Other">)</span> {.
|
|
<span class="Identifier">base</span><span class="Other">,</span> <span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Add a validator to a <tt class="docutils literal"><span class="pre"><span class="Identifier">topic</span></span></tt>. Each new message received in this will be sent to <tt class="docutils literal"><span class="pre"><span class="Identifier">hook</span></span></tt>. <tt class="docutils literal"><span class="pre"><span class="Identifier">hook</span></span></tt> can return either <tt class="docutils literal"><span class="pre"><span class="Identifier">Accept</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">Ignore</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">Reject</span></span></tt> (which can descore the peer)
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L513"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L513" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="getOrCreatePeer.e,PubSub,PeerId,seq[string]" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#getOrCreatePeer.e%2CPubSub%2CPeerId%2Cseq%5Bstring%5D"><span class="Identifier">getOrCreatePeer</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">peerId</span><span class="Other">:</span> <a href="../../peerid.html#PeerId"><span class="Identifier">PeerId</span></a><span class="Other">;</span> <span class="Identifier">protos</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="pubsubpeer.html#PubSubPeer"><span class="Identifier">PubSubPeer</span></a> {.
|
|
<span class="Identifier">base</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L298"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L298" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="handleConn.e,PubSub,Connection,string" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#handleConn.e%2CPubSub%2CConnection%2Cstring"><span class="Identifier">handleConn</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">conn</span><span class="Other">:</span> <a href="../../stream/connection.html#Connection"><span class="Identifier">Connection</span></a><span class="Other">;</span> <span class="Identifier">proto</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span> {.
|
|
<span class="Identifier">base</span><span class="Other">,</span> <span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>handle incoming connections</p>
|
|
<p>this proc will:</p>
|
|
<ol class="simple"><li>register a new PubSubPeer for the connection</li>
|
|
<li>register a handler with the peer; this handler gets called on every rpc message that the peer receives</li>
|
|
<li>ask the peer to subscribe us to every topic that we're interested in</li>
|
|
</ol>
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L363"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L363" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="initPubSub.e,PubSub" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#initPubSub.e%2CPubSub"><span class="Identifier">initPubSub</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">)</span> {.<span class="Identifier">base</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="pubsub.html#InitializationError"><span class="Identifier">InitializationError</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
perform pubsub initialization
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L506"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L506" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="onPubSubPeerEvent.e,PubSub,PubSubPeer,PubSubPeerEvent" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#onPubSubPeerEvent.e%2CPubSub%2CPubSubPeer%2CPubSubPeerEvent"><span class="Identifier">onPubSubPeerEvent</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">peer</span><span class="Other">:</span> <a href="pubsubpeer.html#PubSubPeer"><span class="Identifier">PubSubPeer</span></a><span class="Other">;</span> <span class="Identifier">event</span><span class="Other">:</span> <a href="pubsubpeer.html#PubSubPeerEvent"><span class="Identifier">PubSubPeerEvent</span></a><span class="Other">)</span> {.
|
|
<span class="Identifier">base</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L289"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L289" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="onTopicSubscription.e,PubSub,string,bool" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#onTopicSubscription.e%2CPubSub%2Cstring%2Cbool"><span class="Identifier">onTopicSubscription</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">subscribed</span><span class="Other">:</span> <span class="Identifier">bool</span><span class="Other">)</span> {.<span class="Identifier">base</span><span class="Other">,</span>
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L416"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L416" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="publish.e,PubSub,string,seq[byte]" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#publish.e%2CPubSub%2Cstring%2Cseq%5Bbyte%5D"><span class="Identifier">publish</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">int</span><span class="Other">]</span> {.<span class="Identifier">base</span><span class="Other">,</span>
|
|
<span class="Identifier">public</span><span class="Other">(</span><span class="Other">)</span><span class="Other">,</span> <span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>publish to a <tt class="docutils literal"><span class="pre">topic</span></tt></p>
|
|
<p>The return value is the number of neighbours that we attempted to send the message to, excluding self. Note that this is an optimistic number of attempts - the number of peers that actually receive the message might be lower.</p>
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L494"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L494" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="removeValidator.e,PubSub,varargs[string],ValidatorHandler" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#removeValidator.e%2CPubSub%2Cvarargs%5Bstring%5D%2CValidatorHandler"><span class="Identifier">removeValidator</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">topic</span><span class="Other">:</span> <span class="Identifier">varargs</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">hook</span><span class="Other">:</span> <a href="pubsub.html#ValidatorHandler"><span class="Identifier">ValidatorHandler</span></a><span class="Other">)</span> {.
|
|
<span class="Identifier">base</span><span class="Other">,</span> <span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L523"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L523" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="rpcHandler.e,PubSub,PubSubPeer,seq[byte]" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#rpcHandler.e%2CPubSub%2CPubSubPeer%2Cseq%5Bbyte%5D"><span class="Identifier">rpcHandler</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">peer</span><span class="Other">:</span> <a href="pubsubpeer.html#PubSubPeer"><span class="Identifier">PubSubPeer</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span> {.
|
|
<span class="Identifier">base</span><span class="Other">,</span> <span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Handler that must be overridden by concrete implementation
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L283"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L283" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="subscribePeer.e,PubSub,PeerId" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#subscribePeer.e%2CPubSub%2CPeerId"><span class="Identifier">subscribePeer</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">peer</span><span class="Other">:</span> <a href="../../peerid.html#PeerId"><span class="Identifier">PeerId</span></a><span class="Other">)</span> {.<span class="Identifier">base</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
subscribe to remote peer to receive/send pubsub messages
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L392"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L392" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="unsubscribePeer.e,PubSub,PeerId" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#unsubscribePeer.e%2CPubSub%2CPeerId"><span class="Identifier">unsubscribePeer</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">peerId</span><span class="Other">:</span> <a href="../../peerid.html#PeerId"><span class="Identifier">PeerId</span></a><span class="Other">)</span> {.<span class="Identifier">base</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
handle peer disconnects
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L132"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L132" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="validate.e,PubSub,Message" class="tohide">
|
|
<dt><pre><span class="Keyword">method</span> <a href="#validate.e%2CPubSub%2CMessage"><span class="Identifier">validate</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="pubsub.html#PubSub"><span class="Identifier">PubSub</span></a><span class="Other">;</span> <span class="Identifier">message</span><span class="Other">:</span> <a href="rpc/messages.html#Message"><span class="Identifier">Message</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><a href="errors.html#ValidationResult"><span class="Identifier">ValidationResult</span></a><span class="Other">]</span> {.<span class="Identifier">base</span><span class="Other">,</span>
|
|
<span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a
|
|
href="https://github.com/status-im/nim-libp2p/tree/fix-sendMsgSlow/libp2p/protocols/pubsub/pubsub.nim#L532"
|
|
class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protocols/pubsub/pubsub.nim#L532" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</dl></div>
|
|
<div class="section" id="19">
|
|
<h1><a class="toc-backref" href="#19">Exports</a></h1>
|
|
<dl class="item">
|
|
<a href="pubsubpeer.html#PubSubPeer"><span class="Identifier">PubSubPeer</span></a>, <a href="pubsubpeer.html#PubSubObserver"><span class="Identifier">PubSubObserver</span></a>, <a href="../protocol.html#init.e,LPProtocol"><span class="Identifier">init</span></a>, <a href="../protocol.html#maxIncomingStreams=,LPProtocol,int"><span class="Identifier">maxIncomingStreams=</span></a>, <a href="../protocol.html#codec=,LPProtocol,string"><span class="Identifier">codec=</span></a>, <a href="../protocol.html#DefaultMaxIncomingStreams"><span class="Identifier">DefaultMaxIncomingStreams</span></a>, <a href="../protocol.html#codec,LPProtocol"><span class="Identifier">codec</span></a>, <a href="../protocol.html#maxIncomingStreams,LPProtocol"><span class="Identifier">maxIncomingStreams</span></a>, <a href="../protocol.html#start.e,LPProtocol"><span class="Identifier">start</span></a>, <a href="../protocol.html#LPProtoHandler"><span class="Identifier">LPProtoHandler</span></a>, <a href="../protocol.html#new,typeLPProtocol,seq[string],LPProtoHandler"><span class="Identifier">new</span></a>, <a href="../protocol.html#LPProtocol"><span class="Identifier">LPProtocol</span></a>, <a href="../protocol.html#stop.e,LPProtocol"><span class="Identifier">stop</span></a>, <a href="errors.html#ValidationResult"><span class="Identifier">ValidationResult</span></a>
|
|
</dl></div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="twelve-columns footer">
|
|
<span class="nim-sprite"></span>
|
|
<br/>
|
|
<small style="color: var(--hint);">Made with Nim. Generated: 2024-03-20 10:06:32 UTC</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|