@@ -32,7 +32,7 @@ class IpnsPublisher {
3232
3333 PeerId . createFromPrivKey ( privKey . bytes , ( err , peerId ) => {
3434 if ( err ) {
35- callback ( err )
35+ return callback ( err )
3636 }
3737
3838 this . _updateOrCreateRecord ( privKey , value , lifetime , peerId , ( err , record ) => {
@@ -67,17 +67,17 @@ class IpnsPublisher {
6767
6868 let keys
6969 try {
70- keys = ipns . getIdKeys ( peerId . id )
70+ keys = ipns . getIdKeys ( peerId . toBytes ( ) )
7171 } catch ( err ) {
7272 log . error ( err )
7373 return callback ( err )
7474 }
7575
7676 series ( [
77- ( cb ) => this . _publishEntry ( keys . ipnsKey , embedPublicKeyRecord || record , peerId , cb ) ,
77+ ( cb ) => this . _publishEntry ( keys . routingKey , embedPublicKeyRecord || record , peerId , cb ) ,
7878 // Publish the public key if a public key cannot be extracted from the ID
7979 // 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 ( )
8181 ] , ( err ) => {
8282 if ( err ) {
8383 log . error ( err )
@@ -108,13 +108,13 @@ class IpnsPublisher {
108108 return callback ( err )
109109 }
110110
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 ) => {
113113 if ( err ) {
114114 const errMsg = `ipns record for ${ key . toString ( ) } could not be stored in the routing`
115115
116116 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 ' ) )
118118 }
119119
120120 log ( `ipns record for ${ key . toString ( ) } was stored in the routing` )
@@ -146,13 +146,13 @@ class IpnsPublisher {
146146 return callback ( err )
147147 }
148148
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 ) => {
151151 if ( err ) {
152152 const errMsg = `public key for ${ key . toString ( ) } could not be stored in the routing`
153153
154154 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 ' ) )
156156 }
157157
158158 log ( `public key for ${ key . toString ( ) } was stored in the routing` )
0 commit comments