diff --git a/namesys/publisher.go b/namesys/publisher.go index 636e3fb49e158046d3a3453348716ba470eb4483..365855b1bf9b60a58b56f134c44ff27336e77d11 100644 --- a/namesys/publisher.go +++ b/namesys/publisher.go @@ -53,7 +53,7 @@ func (p *ipnsPublisher) Publish(k ci.PrivKey, value string) error { // Store associated public key timectx, _ := context.WithDeadline(ctx, time.Now().Add(time.Second*4)) - err = p.routing.PutValue(timectx, u.Key(nameb), pkbytes) + err = p.routing.PutValue(timectx, u.Key("/pk/"+string(nameb)), pkbytes) if err != nil { return err } diff --git a/namesys/routing.go b/namesys/routing.go index 5f877bdc3fc17eb5aefc6746196c7c3bc74c70a7..85eca331aff83a7aeeb2e76583ceb6a293b6bb56 100644 --- a/namesys/routing.go +++ b/namesys/routing.go @@ -63,7 +63,7 @@ func (r *routingResolver) Resolve(name string) (string, error) { // name should be a public key retrievable from ipfs // /ipfs/<name> - key := u.Key(hash) + key := u.Key("/pk/" + string(hash)) pkval, err := r.routing.GetValue(ctx, key) if err != nil { log.Warning("RoutingResolve PubKey Get failed.") diff --git a/routing/dht/dht.go b/routing/dht/dht.go index 5d4caaa84773cd323dc78da7c3a88d304d0729bd..66638718440ae61c616c17877a70863300e2ebe5 100644 --- a/routing/dht/dht.go +++ b/routing/dht/dht.go @@ -84,7 +84,10 @@ func NewDHT(ctx context.Context, p peer.Peer, ps peer.Peerstore, dialer inet.Dia dht.routingTables[1] = kb.NewRoutingTable(20, kb.ConvertPeerID(p.ID()), time.Millisecond*1000) dht.routingTables[2] = kb.NewRoutingTable(20, kb.ConvertPeerID(p.ID()), time.Hour) dht.birth = time.Now() + dht.Validators = make(map[string]ValidatorFunc) + dht.Validators["ipns"] = ValidateIpnsRecord + dht.Validators["pk"] = ValidatePublicKeyRecord if doPinging { dht.Children().Add(1) diff --git a/routing/dht/records.go b/routing/dht/records.go index 692f04d4f2d33eb8d4295f76ef8851ab7a9a7225..763b48f6857bea5300ef09c3a8bbcc4b246b11b8 100644 --- a/routing/dht/records.go +++ b/routing/dht/records.go @@ -69,3 +69,13 @@ func (dht *IpfsDHT) verifyRecord(r *pb.Record) error { return fnc(u.Key(r.GetKey()), r.GetValue()) } + +func ValidateIpnsRecord(k u.Key, val []byte) error { + // TODO: + return nil +} + +func ValidatePublicKeyRecord(k u.Key, val []byte) error { + // TODO: + return nil +}