File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,16 @@ class PeerId {
17
17
assert ( privKey . public . bytes . equals ( pubKey . bytes ) , 'inconsistent arguments' )
18
18
}
19
19
20
- this . id = id
20
+ this . _id = id
21
+ this . _idB58String = ''
21
22
this . _privKey = privKey
22
23
this . _pubKey = pubKey
23
24
}
24
25
26
+ get id ( ) {
27
+ return this . _id
28
+ }
29
+
25
30
get privKey ( ) {
26
31
return this . _privKey
27
32
}
@@ -61,7 +66,7 @@ class PeerId {
61
66
// of go-ipfs for its config file
62
67
toJSON ( ) {
63
68
return {
64
- id : mh . toB58String ( this . id ) ,
69
+ id : this . toB58String ( ) ,
65
70
privKey : toB64Opt ( this . marshalPrivKey ( ) ) ,
66
71
pubKey : toB64Opt ( this . marshalPubKey ( ) )
67
72
}
@@ -77,7 +82,11 @@ class PeerId {
77
82
}
78
83
79
84
toB58String ( ) {
80
- return mh . toB58String ( this . id )
85
+ if ( ! this . _idB58String ) {
86
+ this . _idB58String = mh . toB58String ( this . id )
87
+ }
88
+
89
+ return this . _idB58String
81
90
}
82
91
}
83
92
You can’t perform that action at this time.
0 commit comments