diff --git a/cmd/dendrite-p2p-demo/libp2p.go b/cmd/dendrite-p2p-demo/libp2p.go deleted file mode 100644 index 77af754b9..000000000 --- a/cmd/dendrite-p2p-demo/libp2p.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "errors" - - pstore "github.com/libp2p/go-libp2p-core/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 -} diff --git a/cmd/dendrite-p2p-demo/p2pdendrite.go b/cmd/dendrite-p2p-demo/p2pdendrite.go index 314b0c4b7..a9db3b39c 100644 --- a/cmd/dendrite-p2p-demo/p2pdendrite.go +++ b/cmd/dendrite-p2p-demo/p2pdendrite.go @@ -18,6 +18,10 @@ import ( "context" "fmt" + "errors" + + pstore "github.com/libp2p/go-libp2p-core/peerstore" + record "github.com/libp2p/go-libp2p-record" "github.com/matrix-org/dendrite/common/basecomponent" "github.com/libp2p/go-libp2p" @@ -71,7 +75,7 @@ func NewP2PDendrite(cfg *config.Dendrite, componentName string) *P2PDendrite { if err != nil { return nil, err } - libp2pdht.Validator = LibP2PValidator{} + libp2pdht.Validator = libP2PValidator{} r = libp2pdht return }), @@ -104,3 +108,19 @@ func NewP2PDendrite(cfg *config.Dendrite, componentName string) *P2PDendrite { LibP2PPubsub: libp2ppubsub, } } + +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 +}