@@ -19,6 +19,7 @@ import (
19
19
const (
20
20
persistentCacheDbPrefix = "/ipns/persistentcache/"
21
21
pubkeyCacheDbPrefix = "/pubkey/"
22
+ ipnsCacheDbPrefix = "/ipns/"
22
23
)
23
24
24
25
// Resolve an IPNS record. This is a multi-step process.
@@ -74,7 +75,7 @@ func resolve(n *core.IpfsNode, p peer.ID, timeout time.Duration, quorum uint) (i
74
75
75
76
// TODO [cp]: we should load the record count from our config and set it here. We'll need a
76
77
// migration for this.
77
- pth , err := n .Namesys .Resolve (cctx , "/ipns/" + p .Pretty (), nameopts .DhtRecordCount (quorum ))
78
+ pth , err := n .Namesys .Resolve (cctx , string ( obIPNSCacheKey ( p .Pretty ()) ), nameopts .DhtRecordCount (quorum ))
78
79
if err != nil {
79
80
return pth , err
80
81
}
@@ -85,7 +86,7 @@ func ResolveAltRoot(n *core.IpfsNode, p peer.ID, altRoot string, timeout time.Du
85
86
cctx , cancel := context .WithTimeout (context .Background (), timeout )
86
87
defer cancel ()
87
88
88
- pth , err := n .Namesys .Resolve (cctx , "/ipns/" + p .Pretty ()+ ":" + altRoot )
89
+ pth , err := n .Namesys .Resolve (cctx , obIPNSCacheKey ( p .Pretty ()+ ":" + altRoot ) )
89
90
if err != nil {
90
91
return "" , err
91
92
}
@@ -98,7 +99,7 @@ func ResolveAltRoot(n *core.IpfsNode, p peer.ID, altRoot string, timeout time.Du
98
99
// under /ipns/persistentcache/<peerID> which returns only the value (the path)
99
100
// inside the protobuf record.
100
101
func getFromDatastore (datastore ds.Datastore , p peer.ID ) (ipath.Path , error ) {
101
- ival , err := datastore .Get (ipnsRecordCacheKey (p ))
102
+ ival , err := datastore .Get (nativeIPNSRecordCacheKey (p ))
102
103
if err != nil {
103
104
pth , err := datastore .Get (persistentCacheKey (p ))
104
105
if err != nil {
@@ -142,6 +143,12 @@ func persistentCacheKey(id peer.ID) ds.Key {
142
143
return ds .NewKey (persistentCacheDbPrefix + base32 .RawStdEncoding .EncodeToString ([]byte (id )))
143
144
}
144
145
145
- func ipnsRecordCacheKey (id peer.ID ) ds.Key {
146
+ // nativeIPNSRecordCacheKey applies native IPFS key: "/ipns/" + encoded(id)
147
+ func nativeIPNSRecordCacheKey (id peer.ID ) ds.Key {
146
148
return namesys .IpnsDsKey (id )
147
149
}
150
+
151
+ // obIPNSCacheKey applies custom IPNS prefix key: "/ipns/" + id
152
+ func obIPNSCacheKey (id string ) string {
153
+ return ipnsCacheDbPrefix + id
154
+ }
0 commit comments