This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-17
lines changed Expand file tree Collapse file tree 1 file changed +14
-17
lines changed Original file line number Diff line number Diff line change 11'use strict'
22
33const promisify = require ( 'promisify-es6' )
4+ const mafmt = require ( 'mafmt' )
45
56module . exports = function id ( self ) {
67 return promisify ( ( opts , callback ) => {
78 if ( typeof opts === 'function' ) {
89 callback = opts
910 opts = { }
1011 }
11- if ( ! self . _peerInfo ) { // because of split second warmup
12- setTimeout ( ready , 100 )
13- } else {
14- ready ( )
15- }
1612
17- function ready ( ) {
18- callback ( null , {
19- id : self . _peerInfo . id . toB58String ( ) ,
20- publicKey : self . _peerInfo . id . pubKey . bytes . toString ( 'base64' ) ,
21- addresses : self . _peerInfo . multiaddrs . map ( ( ma ) => {
22- const addr = ma . toString ( ) + '/ipfs/' + self . _peerInfo . id . toB58String ( )
23- return addr
24- } ) . sort ( ) ,
25- agentVersion : 'js-ipfs' ,
26- protocolVersion : '9000'
27- } )
28- }
13+ setImmediate ( ( ) => callback ( null , {
14+ id : self . _peerInfo . id . toB58String ( ) ,
15+ publicKey : self . _peerInfo . id . pubKey . bytes . toString ( 'base64' ) ,
16+ addresses : self . _peerInfo . multiaddrs . map ( ( ma ) => {
17+ if ( mafmt . IPFS . matches ( ma ) ) {
18+ return ma . toString ( )
19+ } else {
20+ return ma . toString ( ) + '/ipfs/' + self . _peerInfo . id . toB58String ( )
21+ }
22+ } ) . sort ( ) ,
23+ agentVersion : 'js-ipfs' ,
24+ protocolVersion : '9000'
25+ } ) )
2926 } )
3027}
You can’t perform that action at this time.
0 commit comments