mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 05:52:20 +08:00
move util.Key into its own package under blocks
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
|
||||
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
||||
|
||||
key "github.com/ipfs/go-ipfs/blocks/key"
|
||||
dag "github.com/ipfs/go-ipfs/merkledag"
|
||||
pb "github.com/ipfs/go-ipfs/namesys/internal/pb"
|
||||
ci "github.com/ipfs/go-ipfs/p2p/crypto"
|
||||
@ -55,7 +56,7 @@ func (p *ipnsPublisher) Publish(ctx context.Context, k ci.PrivKey, value path.Pa
|
||||
}
|
||||
|
||||
nameb := u.Hash(pkbytes)
|
||||
namekey := u.Key("/pk/" + string(nameb))
|
||||
namekey := key.Key("/pk/" + string(nameb))
|
||||
|
||||
log.Debugf("Storing pubkey at: %s", namekey)
|
||||
// Store associated public key
|
||||
@ -65,7 +66,7 @@ func (p *ipnsPublisher) Publish(ctx context.Context, k ci.PrivKey, value path.Pa
|
||||
return err
|
||||
}
|
||||
|
||||
ipnskey := u.Key("/ipns/" + string(nameb))
|
||||
ipnskey := key.Key("/ipns/" + string(nameb))
|
||||
|
||||
log.Debugf("Storing ipns entry at: %s", ipnskey)
|
||||
// Store ipns entry at "/ipns/"+b58(h(pubkey))
|
||||
@ -110,7 +111,7 @@ var IpnsRecordValidator = &record.ValidChecker{
|
||||
|
||||
// ValidateIpnsRecord implements ValidatorFunc and verifies that the
|
||||
// given 'val' is an IpnsEntry and that that entry is valid.
|
||||
func ValidateIpnsRecord(k u.Key, val []byte) error {
|
||||
func ValidateIpnsRecord(k key.Key, val []byte) error {
|
||||
entry := new(pb.IpnsEntry)
|
||||
err := proto.Unmarshal(val, entry)
|
||||
if err != nil {
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
||||
key "github.com/ipfs/go-ipfs/blocks/key"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
mockrouting "github.com/ipfs/go-ipfs/routing/mock"
|
||||
u "github.com/ipfs/go-ipfs/util"
|
||||
@ -33,7 +34,7 @@ func TestRoutingResolve(t *testing.T) {
|
||||
}
|
||||
|
||||
pkhash := u.Hash(pubkb)
|
||||
res, err := resolver.Resolve(context.Background(), u.Key(pkhash).Pretty())
|
||||
res, err := resolver.Resolve(context.Background(), key.Key(pkhash).Pretty())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
|
||||
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
||||
|
||||
key "github.com/ipfs/go-ipfs/blocks/key"
|
||||
pb "github.com/ipfs/go-ipfs/namesys/internal/pb"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
routing "github.com/ipfs/go-ipfs/routing"
|
||||
@ -64,7 +65,7 @@ func (r *routingResolver) resolveOnce(ctx context.Context, name string) (path.Pa
|
||||
// /ipns/<name>
|
||||
h := []byte("/ipns/" + string(hash))
|
||||
|
||||
ipnsKey := u.Key(h)
|
||||
ipnsKey := key.Key(h)
|
||||
val, err := r.routing.GetValue(ctx, ipnsKey)
|
||||
if err != nil {
|
||||
log.Warning("RoutingResolve get failed.")
|
||||
@ -84,7 +85,7 @@ func (r *routingResolver) resolveOnce(ctx context.Context, name string) (path.Pa
|
||||
}
|
||||
|
||||
hsh, _ := pubkey.Hash()
|
||||
log.Debugf("pk hash = %s", u.Key(hsh))
|
||||
log.Debugf("pk hash = %s", key.Key(hsh))
|
||||
|
||||
// check sig with pk
|
||||
if ok, err := pubkey.Verify(ipnsEntryDataForSig(entry), entry.GetSignature()); err != nil || !ok {
|
||||
@ -101,6 +102,6 @@ func (r *routingResolver) resolveOnce(ctx context.Context, name string) (path.Pa
|
||||
} else {
|
||||
// Its an old style multihash record
|
||||
log.Warning("Detected old style multihash record")
|
||||
return path.FromKey(u.Key(valh)), nil
|
||||
return path.FromKey(key.Key(valh)), nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user