@cryptotaxi247 / kubo / commits / 1cf7a1824

validator functions and ipns completion

Jeromy committed Nov 10, 2014 at 15:48 UTC 1cf7a1824a3aa8c8224365b2678d3845f236588c
4 files changed +15 -2
namesys/publisher.go
+1 -1
@@ -53,7 +53,7 @@ func (p *ipnsPublisher) Publish(k ci.PrivKey, value string) error {
53
54 // Store associated public key
55 timectx, _ := context.WithDeadline(ctx, time.Now().Add(time.Second*4))
56 - err = p.routing.PutValue(timectx, u.Key(nameb), pkbytes)
56 + err = p.routing.PutValue(timectx, u.Key("/pk/"+string(nameb)), pkbytes)
57 if err != nil {
58 return err
59 }
namesys/routing.go
+1 -1
@@ -63,7 +63,7 @@ func (r *routingResolver) Resolve(name string) (string, error) {
63
64 // name should be a public key retrievable from ipfs
65 // /ipfs/<name>
66 - key := u.Key(hash)
66 + key := u.Key("/pk/" + string(hash))
67 pkval, err := r.routing.GetValue(ctx, key)
68 if err != nil {
69 log.Warning("RoutingResolve PubKey Get failed.")
routing/dht/dht.go
+3
@@ -84,7 +84,10 @@ func NewDHT(ctx context.Context, p peer.Peer, ps peer.Peerstore, dialer inet.Dia
84 dht.routingTables[1] = kb.NewRoutingTable(20, kb.ConvertPeerID(p.ID()), time.Millisecond*1000)
85 dht.routingTables[2] = kb.NewRoutingTable(20, kb.ConvertPeerID(p.ID()), time.Hour)
86 dht.birth = time.Now()
87 +
88 dht.Validators = make(map[string]ValidatorFunc)
89 + dht.Validators["ipns"] = ValidateIpnsRecord
90 + dht.Validators["pk"] = ValidatePublicKeyRecord
91
92 if doPinging {
93 dht.Children().Add(1)
routing/dht/records.go
+10
@@ -69,3 +69,13 @@ func (dht *IpfsDHT) verifyRecord(r *pb.Record) error {
69
70 return fnc(u.Key(r.GetKey()), r.GetValue())
71 }
72 +
73 +func ValidateIpnsRecord(k u.Key, val []byte) error {
74 + // TODO:
75 + return nil
76 +}
77 +
78 +func ValidatePublicKeyRecord(k u.Key, val []byte) error {
79 + // TODO:
80 + return nil
81 +}