@@ -32,7 +32,7 @@ class IpnsPublisher {
32
32
33
33
PeerId . createFromPrivKey ( privKey . bytes , ( err , peerId ) => {
34
34
if ( err ) {
35
- callback ( err )
35
+ return callback ( err )
36
36
}
37
37
38
38
this . _updateOrCreateRecord ( privKey , value , lifetime , peerId , ( err , record ) => {
@@ -67,17 +67,17 @@ class IpnsPublisher {
67
67
68
68
let keys
69
69
try {
70
- keys = ipns . getIdKeys ( peerId . id )
70
+ keys = ipns . getIdKeys ( peerId . toBytes ( ) )
71
71
} catch ( err ) {
72
72
log . error ( err )
73
73
return callback ( err )
74
74
}
75
75
76
76
series ( [
77
- ( cb ) => this . _publishEntry ( keys . ipnsKey , embedPublicKeyRecord || record , peerId , cb ) ,
77
+ ( cb ) => this . _publishEntry ( keys . routingKey , embedPublicKeyRecord || record , peerId , cb ) ,
78
78
// Publish the public key if a public key cannot be extracted from the ID
79
79
// We will be able to deprecate this part in the future, since the public keys will be only in the peerId
80
- ( cb ) => embedPublicKeyRecord ? this . _publishPublicKey ( keys . pkKey , publicKey , peerId , cb ) : cb ( )
80
+ ( cb ) => embedPublicKeyRecord ? this . _publishPublicKey ( keys . routingPubKey , publicKey , peerId , cb ) : cb ( )
81
81
] , ( err ) => {
82
82
if ( err ) {
83
83
log . error ( err )
@@ -108,13 +108,13 @@ class IpnsPublisher {
108
108
return callback ( err )
109
109
}
110
110
111
- // TODO Routing - this should be replaced by a put to the DHT
112
- this . _repo . datastore . put ( key , rec . serialize ( ) , ( err , res ) => {
111
+ // Add record to routing (buffer key)
112
+ this . _routing . put ( key . toBuffer ( ) , rec . serialize ( ) , ( err , res ) => {
113
113
if ( err ) {
114
114
const errMsg = `ipns record for ${ key . toString ( ) } could not be stored in the routing`
115
115
116
116
log . error ( errMsg )
117
- return callback ( errcode ( new Error ( errMsg ) , 'ERR_STORING_IN_DATASTORE ' ) )
117
+ return callback ( errcode ( new Error ( errMsg ) , 'ERR_PUTTING_TO_ROUTING ' ) )
118
118
}
119
119
120
120
log ( `ipns record for ${ key . toString ( ) } was stored in the routing` )
@@ -146,13 +146,13 @@ class IpnsPublisher {
146
146
return callback ( err )
147
147
}
148
148
149
- // TODO Routing - this should be replaced by a put to the DHT
150
- this . _repo . datastore . put ( key , rec . serialize ( ) , ( err , res ) => {
149
+ // Add public key to routing (buffer key)
150
+ this . _routing . put ( key . toBuffer ( ) , rec . serialize ( ) , ( err , res ) => {
151
151
if ( err ) {
152
152
const errMsg = `public key for ${ key . toString ( ) } could not be stored in the routing`
153
153
154
154
log . error ( errMsg )
155
- return callback ( errcode ( new Error ( errMsg ) , 'ERR_STORING_IN_DATASTORE ' ) )
155
+ return callback ( errcode ( new Error ( errMsg ) , 'ERR_PUTTING_TO_ROUTING ' ) )
156
156
}
157
157
158
158
log ( `public key for ${ key . toString ( ) } was stored in the routing` )
0 commit comments