dendrite/common/basecomponent/libp2p.go
Hilmar Gústafsson 49278740e3 Add libp2p-go
2020-04-08 17:16:32 +02:00

25 lines
481 B
Go

package basecomponent
import (
"errors"
pstore "github.com/libp2p/go-libp2p-peerstore"
record "github.com/libp2p/go-libp2p-record"
)
type LibP2PValidator struct {
KeyBook pstore.KeyBook
}
func (v LibP2PValidator) Validate(key string, value []byte) error {
ns, _, err := record.SplitKey(key)
if err != nil || ns != "matrix" {
return errors.New("not Matrix path")
}
return nil
}
func (v LibP2PValidator) Select(k string, vals [][]byte) (int, error) {
return 0, nil
}