mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-04 15:58:13 +08:00
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
package nilrouting
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
repo "github.com/ipfs/go-ipfs/repo"
|
|
|
|
routing "gx/ipfs/QmQKEgGgYCDyk8VNY6A65FpuE4YwbspvjXHco1rdb75PVc/go-libp2p-routing"
|
|
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
|
|
pstore "gx/ipfs/QmXXCcQ7CLg5a81Ui9TTR35QcR4y7ZyihxwfjqaHfUVcVo/go-libp2p-peerstore"
|
|
cid "gx/ipfs/QmXfiyr2RWEXpVDdaYnD2HNiBk6UBddsvEP4RPfXb6nGqY/go-cid"
|
|
p2phost "gx/ipfs/QmdML3R42PRSwnt46jSuEts9bHSqLctVYEjJqMR3UYV8ki/go-libp2p-host"
|
|
peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer"
|
|
)
|
|
|
|
var log = logging.Logger("mockrouter")
|
|
|
|
type nilclient struct {
|
|
}
|
|
|
|
func (c *nilclient) PutValue(_ context.Context, _ string, _ []byte) error {
|
|
return nil
|
|
}
|
|
|
|
func (c *nilclient) GetValue(_ context.Context, _ string) ([]byte, error) {
|
|
return nil, errors.New("Tried GetValue from nil routing.")
|
|
}
|
|
|
|
func (c *nilclient) GetValues(_ context.Context, _ string, _ int) ([]routing.RecvdVal, error) {
|
|
return nil, errors.New("Tried GetValues from nil routing.")
|
|
}
|
|
|
|
func (c *nilclient) FindPeer(_ context.Context, _ peer.ID) (pstore.PeerInfo, error) {
|
|
return pstore.PeerInfo{}, nil
|
|
}
|
|
|
|
func (c *nilclient) FindProvidersAsync(_ context.Context, _ *cid.Cid, _ int) <-chan pstore.PeerInfo {
|
|
out := make(chan pstore.PeerInfo)
|
|
defer close(out)
|
|
return out
|
|
}
|
|
|
|
func (c *nilclient) Provide(_ context.Context, _ *cid.Cid) error {
|
|
return nil
|
|
}
|
|
|
|
func (c *nilclient) Bootstrap(_ context.Context) error {
|
|
return nil
|
|
}
|
|
|
|
func ConstructNilRouting(_ context.Context, _ p2phost.Host, _ repo.Datastore) (routing.IpfsRouting, error) {
|
|
return &nilclient{}, nil
|
|
}
|
|
|
|
// ensure nilclient satisfies interface
|
|
var _ routing.IpfsRouting = &nilclient{}
|