@@ -56,16 +56,16 @@ func (p *IPNSPublisher) Publish(ctx context.Context, priv crypto.PrivKey, value
5656
5757// IpnsDsKey returns a datastore key given an IPNS identifier (peer
5858// ID). Defines the storage key for IPNS records in the local datastore.
59- func IpnsDsKey (id peer. ID ) ds.Key {
60- return ds .NewKey ("/ipns/" + base32 .RawStdEncoding .EncodeToString ([]byte (id )))
59+ func IpnsDsKey (name ipns. Name ) ds.Key {
60+ return ds .NewKey ("/ipns/" + base32 .RawStdEncoding .EncodeToString ([]byte (name . Peer () )))
6161}
6262
6363// ListPublished returns the latest IPNS records published by this node and
6464// their expiration times.
6565//
6666// This method will not search the routing system for records published by other
6767// nodes.
68- func (p * IPNSPublisher ) ListPublished (ctx context.Context ) (map [peer. ID ]* ipns.Record , error ) {
68+ func (p * IPNSPublisher ) ListPublished (ctx context.Context ) (map [ipns. Name ]* ipns.Record , error ) {
6969 query , err := p .ds .Query (ctx , dsquery.Query {
7070 Prefix : ipns .NamespacePrefix ,
7171 })
@@ -74,7 +74,7 @@ func (p *IPNSPublisher) ListPublished(ctx context.Context) (map[peer.ID]*ipns.Re
7474 }
7575 defer query .Close ()
7676
77- records := make (map [peer. ID ]* ipns.Record )
77+ records := make (map [ipns. Name ]* ipns.Record )
7878 for {
7979 select {
8080 case result , ok := <- query .Next ():
@@ -100,7 +100,7 @@ func (p *IPNSPublisher) ListPublished(ctx context.Context) (map[peer.ID]*ipns.Re
100100 log .Errorf ("ipns ds key invalid: %s" , result .Key )
101101 continue
102102 }
103- records [peer .ID (pid )] = rec
103+ records [ipns . NameFromPeer ( peer .ID (pid ) )] = rec
104104 case <- ctx .Done ():
105105 return nil , ctx .Err ()
106106 }
@@ -112,24 +112,24 @@ func (p *IPNSPublisher) ListPublished(ctx context.Context) (map[peer.ID]*ipns.Re
112112//
113113// If `checkRouting` is true and we have no existing record, this method will
114114// check the routing system for any existing records.
115- func (p * IPNSPublisher ) GetPublished (ctx context.Context , id peer. ID , checkRouting bool ) (* ipns.Record , error ) {
115+ func (p * IPNSPublisher ) GetPublished (ctx context.Context , name ipns. Name , checkRouting bool ) (* ipns.Record , error ) {
116116 ctx , cancel := context .WithTimeout (ctx , time .Second * 30 )
117117 defer cancel ()
118118
119- value , err := p .ds .Get (ctx , IpnsDsKey (id ))
119+ value , err := p .ds .Get (ctx , IpnsDsKey (name ))
120120 switch err {
121121 case nil :
122122 case ds .ErrNotFound :
123123 if ! checkRouting {
124124 return nil , nil
125125 }
126- routingKey := ipns . NameFromPeer ( id ) .RoutingKey ()
126+ routingKey := name .RoutingKey ()
127127 value , err = p .routing .GetValue (ctx , string (routingKey ))
128128 if err != nil {
129129 // Not found or other network issue. Can't really do
130130 // anything about this case.
131131 if err != routing .ErrNotFound {
132- log .Debugf ("error when determining the last published IPNS record for %s: %s" , id , err )
132+ log .Debugf ("error when determining the last published IPNS record for %s: %s" , name , err )
133133 }
134134
135135 return nil , nil
@@ -146,12 +146,13 @@ func (p *IPNSPublisher) updateRecord(ctx context.Context, k crypto.PrivKey, valu
146146 if err != nil {
147147 return nil , err
148148 }
149+ name := ipns .NameFromPeer (id )
149150
150151 p .mu .Lock ()
151152 defer p .mu .Unlock ()
152153
153154 // get previous records sequence number
154- rec , err := p .GetPublished (ctx , id , true )
155+ rec , err := p .GetPublished (ctx , name , true )
155156 if err != nil {
156157 return nil , err
157158 }
@@ -188,7 +189,7 @@ func (p *IPNSPublisher) updateRecord(ctx context.Context, k crypto.PrivKey, valu
188189 }
189190
190191 // Put the new record.
191- dsKey := IpnsDsKey (id )
192+ dsKey := IpnsDsKey (name )
192193 if err := p .ds .Put (ctx , dsKey , data ); err != nil {
193194 return nil , err
194195 }
0 commit comments