Commit 1cf7a182 authored by Jeromy's avatar Jeromy Committed by Juan Batiz-Benet

validator functions and ipns completion

parent cb23d5b2
......@@ -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
}
......
......@@ -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.")
......
......@@ -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)
......
......@@ -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
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment