mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-11 06:52:52 +08:00
validator functions and ipns completion
This commit is contained in:
@ -53,7 +53,7 @@ func (p *ipnsPublisher) Publish(k ci.PrivKey, value string) error {
|
|||||||
|
|
||||||
// Store associated public key
|
// Store associated public key
|
||||||
timectx, _ := context.WithDeadline(ctx, time.Now().Add(time.Second*4))
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ func (r *routingResolver) Resolve(name string) (string, error) {
|
|||||||
|
|
||||||
// name should be a public key retrievable from ipfs
|
// name should be a public key retrievable from ipfs
|
||||||
// /ipfs/<name>
|
// /ipfs/<name>
|
||||||
key := u.Key(hash)
|
key := u.Key("/pk/" + string(hash))
|
||||||
pkval, err := r.routing.GetValue(ctx, key)
|
pkval, err := r.routing.GetValue(ctx, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warning("RoutingResolve PubKey Get failed.")
|
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[1] = kb.NewRoutingTable(20, kb.ConvertPeerID(p.ID()), time.Millisecond*1000)
|
||||||
dht.routingTables[2] = kb.NewRoutingTable(20, kb.ConvertPeerID(p.ID()), time.Hour)
|
dht.routingTables[2] = kb.NewRoutingTable(20, kb.ConvertPeerID(p.ID()), time.Hour)
|
||||||
dht.birth = time.Now()
|
dht.birth = time.Now()
|
||||||
|
|
||||||
dht.Validators = make(map[string]ValidatorFunc)
|
dht.Validators = make(map[string]ValidatorFunc)
|
||||||
|
dht.Validators["ipns"] = ValidateIpnsRecord
|
||||||
|
dht.Validators["pk"] = ValidatePublicKeyRecord
|
||||||
|
|
||||||
if doPinging {
|
if doPinging {
|
||||||
dht.Children().Add(1)
|
dht.Children().Add(1)
|
||||||
|
@ -69,3 +69,13 @@ func (dht *IpfsDHT) verifyRecord(r *pb.Record) error {
|
|||||||
|
|
||||||
return fnc(u.Key(r.GetKey()), r.GetValue())
|
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
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user