2019-08-26 13:45:36 +00:00
|
|
|
package discovery
|
|
|
|
|
|
|
|
import (
|
2019-10-18 04:47:41 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/address"
|
2019-08-26 13:45:36 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cbor.RegisterCborType(RetrievalPeer{})
|
|
|
|
}
|
|
|
|
|
|
|
|
type RetrievalPeer struct {
|
|
|
|
Address address.Address
|
|
|
|
ID peer.ID // optional
|
|
|
|
}
|
|
|
|
|
|
|
|
type PeerResolver interface {
|
|
|
|
GetPeers(data cid.Cid) ([]RetrievalPeer, error) // TODO: channel
|
|
|
|
}
|
|
|
|
|
|
|
|
func Multi(r PeerResolver) PeerResolver { // TODO: actually support multiple mechanisms
|
|
|
|
return r
|
|
|
|
}
|