fix(identify): make agentversion dynamic and add it to the peerstore (#724)

This commit is contained in:
Jacob Heun
2020-08-04 18:39:05 +02:00
committed by GitHub
parent a331b84f13
commit 726a746479
3 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,8 @@
'use strict'
const libp2pVersion = require('../../package.json').version
module.exports.PROTOCOL_VERSION = 'ipfs/0.1.0'
module.exports.AGENT_VERSION = 'js-libp2p/0.1.0'
module.exports.AGENT_VERSION = `js-libp2p/${libp2pVersion}`
module.exports.MULTICODEC_IDENTIFY = '/ipfs/id/1.0.0'
module.exports.MULTICODEC_IDENTIFY_PUSH = '/ipfs/id/push/1.0.0'

View File

@ -175,6 +175,7 @@ class IdentifyService {
// Update peers data in PeerStore
this.peerStore.addressBook.set(id, listenAddrs.map((addr) => multiaddr(addr)))
this.peerStore.protoBook.set(id, protocols)
this.peerStore.metadataBook.set(id, 'AgentVersion', Buffer.from(message.agentVersion))
// TODO: Track our observed address so that we can score it
log('received observed address of %s', observedAddr)