From 59df4438f349e2412aa69590bff30e4bc810cafb Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 13 Feb 2020 11:01:00 +0000 Subject: [PATCH] docs: custom-libp2p example print peer id in swarm addresses on startup (#2775) Since https://github.com/libp2p/js-libp2p/pull/558 js-libp2p now requires peer ids to be part of dialled multiaddrs. Previously a user was able to copy/paste swarm addresses printed as part of the daemon starting up but now they can't because the peer id is not included in the console output. This PR prints the node's peer id as part of the swarm address to let people continue doing this and fixes the custom-libp2p example. --- custom-libp2p/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/custom-libp2p/index.js b/custom-libp2p/index.js index 1b5d2387..fb77a393 100644 --- a/custom-libp2p/index.js +++ b/custom-libp2p/index.js @@ -32,6 +32,7 @@ const libp2pBundle = (opts) => { const bootstrapList = opts.config.Bootstrap // Build and return our libp2p node + // n.b. for full configuration options, see https://github.com/libp2p/js-libp2p/blob/master/doc/CONFIGURATION.md return new Libp2p({ peerInfo, peerBook, @@ -91,6 +92,17 @@ const libp2pBundle = (opts) => { pubsub: { enabled: true } + }, + metrics: { + enabled: true, + computeThrottleMaxQueueSize: 1000, // How many messages a stat will queue before processing + computeThrottleTimeout: 2000, // Time in milliseconds a stat will wait, after the last item was added, before processing + movingAverageIntervals: [ // The moving averages that will be computed + 60 * 1000, // 1 minute + 5 * 60 * 1000, // 5 minutes + 15 * 60 * 1000 // 15 minutes + ], + maxOldPeersRetention: 50 // How many disconnected peers we will retain stats for } }) }