Documentation ¶
Index ¶
- Constants
- Variables
- func DurationToFloat64Millis(d time.Duration) float64
- func ParseConError(err error) string
- func StringRowComposer(rawRow []interface{}) []string
- type CSV
- type CidMetrics
- type DHTHost
- func (h *DHTHost) Close()
- func (h *DHTHost) FindProvidersOfCID(ctx context.Context, contentID cid.Cid) (time.Duration, []peer.AddrInfo, error)
- func (h *DHTHost) FindXXProvidersOfCID(ctx context.Context, contentID cid.Cid, targetProviders int) (time.Duration, []peer.AddrInfo, *kaddht.LookupMetrics, error)
- func (h *DHTHost) GenRandomCID() (cid.Cid, error)
- func (h *DHTHost) GetClosestPeersToCid(ctx context.Context, cid *cid.Cid) (time.Duration, []peer.ID, *kaddht.LookupMetrics, error)
- func (h *DHTHost) GetHostID() int
- func (h *DHTHost) GetLatencyToPeer(p peer.ID) time.Duration
- func (h *DHTHost) GetMAddrsOfPeer(p peer.ID) []ma.Multiaddr
- func (h *DHTHost) GetMsgNotifier() *MsgNotifier
- func (h *DHTHost) GetUserAgentOfPeer(p peer.ID) (useragent string)
- func (h *DHTHost) ID() peer.ID
- func (h *DHTHost) Init() error
- func (h *DHTHost) ProvideCid(ctx context.Context, contentID cid.Cid) (time.Duration, *kaddht.LookupMetrics, error)
- type DHTHostOptions
- type DHTLookupService
- type LookupJob
- type MessageSender
- func (ms *MessageSender) GetMsgNotifier() *MsgNotifier
- func (ms *MessageSender) Init(h host.Host, protocols []protocol.ID) pb.MessageSender
- func (ms *MessageSender) SendMessage(ctx context.Context, p peer.ID, pmes *pb.Message) error
- func (ms *MessageSender) SendRequest(ctx context.Context, p peer.ID, pmes *pb.Message) (*pb.Message, error)
- type MsgNotification
- type MsgNotifier
- type ProvideOption
- type RowComposer
Constants ¶
const ( StandardDHTProvide ProvideOption = "std-dht-provide" OpDHTProvide ProvideOption = "op-provide" DefaultUserAgent string = "cid-hoarder" PingGraceTime = 5 * time.Second MaxDialAttempts = 1 DialTimeout = 60 * time.Second K int = 20 )
const ( // list errors NoConnError = "none" ResourceLimitError = "resource_limit" DialErrorRoutingNotFound = "routing_not_found" DialErrorNoRecentNetworkActivity = "no_recent_network_activity" DialErrorStreamErrorCode0 = "canceled_stream_err_code_0" DialErrorMsgSenderInvalidated = "msg_sender_invalidated" DialBlacklistedPeer = "hydra_booster_peer" DialErrorIoTimeout = "io_timeout" DialErrorConnectionRefused = "connection_refused" DialErrorBackOff = "backoff" DialErrorProtocolNotSupported = "protocol_not_supported" DialErrorPeerIDMismatch = "peer_id_mismatch" DialErrorNoRouteToHost = "no_route_to_host" DialErrorNetworkUnreachable = "network_unreachable" DialErrorNoGoodAddresses = "no_good_addresses" DialErrorNoAddress = "no_addresses" DialErrorMaddrReset = "maddr_reset" DialErrorContextDeadlineExceeded = "context_deadline_exceeded" DialErrorNoPublicIP = "no_public_ip" DialErrorMaxDialAttemptsExceeded = "max_dial_attempts_exceeded" DialErrorUnknown = "unknown" DialErrorStreamReset = "stream_reset" DialErrorHostIsDown = "host_is_down" DialErrorTooManyOpenFiles = "too_many_open_files" DialErrorNegotiateSecurityProtocolNoTrailingNewLine = "negotiate_security_protocol_no_trailing_new_line" )
const (
NoUserAgentDefined = "Not Defined"
)
Variables ¶
var DefaultDHTcliOptions = DHTHostOptions{ ID: 0, IP: "0.0.0.0", Port: "9050", ProvOp: StandardDHTProvide, WithNotifier: false, K: K, BlacklistingUA: "", BlacklistedPeers: make(map[peer.ID]struct{}), }
var KnownErrors = map[string]string{ DialBlacklistedPeer: net.ErrBlacklistedPeer.Error(), ResourceLimitError: "resource limit exceeded", DialErrorRoutingNotFound: "routing: not found", DialErrorNoRecentNetworkActivity: "no recent network activity", DialErrorStreamErrorCode0: "canceled with error code 0", DialErrorMsgSenderInvalidated: "message sender has been invalidated", DialErrorIoTimeout: "i/o timeout", DialErrorConnectionRefused: "connection refused", DialErrorBackOff: "backoff", DialErrorProtocolNotSupported: "protocol not supported", DialErrorPeerIDMismatch: "peer id mismatch", DialErrorNoRouteToHost: "no route to host", DialErrorNetworkUnreachable: "network is unreachable", DialErrorNoGoodAddresses: "no good addresses", DialErrorNoAddress: "no addresses", DialErrorContextDeadlineExceeded: "context deadline exceeded", DialErrorNoPublicIP: "no public IP address", DialErrorMaxDialAttemptsExceeded: "max dial attempts exceeded", DialErrorHostIsDown: "host is down", DialErrorStreamReset: "stream reset", DialErrorTooManyOpenFiles: "too many open files", DialErrorNegotiateSecurityProtocolNoTrailingNewLine: "failed to negotiate security protocol: message did not have trailing newline", }
Functions ¶
func DurationToFloat64Millis ¶
func ParseConError ¶
func StringRowComposer ¶
func StringRowComposer(rawRow []interface{}) []string
Basic String Row Composer
Types ¶
type CSV ¶
type CSV struct {
// contains filtered or unexported fields
}
for now only supports list of enr so far
func NewCsvImporter ¶
func (*CSV) Export ¶
func (c *CSV) Export(rows [][]interface{}, rowComposer RowComposer) error
type CidMetrics ¶
type CidMetrics struct {
// contains filtered or unexported fields
}
func NewCidMetrics ¶
func NewCidMetrics(job, id int, c cid.Cid, provider peer.ID) *CidMetrics
func (*CidMetrics) AddPing ¶
func (m *CidMetrics) AddPing(t time.Time, d time.Duration, r bool, lkm *kaddht.LookupMetrics)
func (*CidMetrics) AddProvide ¶
func (m *CidMetrics) AddProvide(t time.Time, d time.Duration, lkm *kaddht.LookupMetrics)
func (*CidMetrics) ValidProvider ¶
func (m *CidMetrics) ValidProvider(r peer.ID) bool
ValidProvider returns whether the retreived provider of the CID matches the publisher of the CID
type DHTHost ¶
type DHTHost struct {
// contains filtered or unexported fields
}
DHT Host is the main operational instance to communicate with the IPFS DHT
func NewDHTHost ¶
func NewDHTHost(ctx context.Context, opts DHTHostOptions) (*DHTHost, error)
func (*DHTHost) FindProvidersOfCID ¶
func (*DHTHost) FindXXProvidersOfCID ¶
func (*DHTHost) GenRandomCID ¶
func (*DHTHost) GetClosestPeersToCid ¶
func (h *DHTHost) GetClosestPeersToCid(ctx context.Context, cid *cid.Cid) (time.Duration, []peer.ID, *kaddht.LookupMetrics, error)
dht pinger related methods
func (*DHTHost) GetMsgNotifier ¶
func (h *DHTHost) GetMsgNotifier() *MsgNotifier
func (*DHTHost) GetUserAgentOfPeer ¶
func (*DHTHost) Init ¶
Init makes sure that all the components of the DHT host are successfully initialized
func (*DHTHost) ProvideCid ¶
type DHTHostOptions ¶
type DHTLookupService ¶
type DHTLookupService struct {
// contains filtered or unexported fields
}
func NewLookupService ¶
func (*DHTLookupService) Close ¶
func (s *DHTLookupService) Close()
Close finishes the routines making sure to keep the relevant data
func (*DHTLookupService) ExportMetrics ¶
func (s *DHTLookupService) ExportMetrics(outputPath string) error
func (*DHTLookupService) Run ¶
func (s *DHTLookupService) Run() error
type LookupJob ¶
type LookupJob struct { // indv cid info Cids map[string]*CidMetrics // contains filtered or unexported fields }
LookupJob compiles all the data about the publication and ping of multiple CIDs concurrently
func NewLookupJob ¶
NewLookupJob creates a new empty instance for aggregating the data of the study
func (*LookupJob) AddCidMetrics ¶
func (j *LookupJob) AddCidMetrics(m *CidMetrics) (exists bool)
func (*LookupJob) AddPingTimes ¶
func (*LookupJob) AddProvideTimes ¶
type MessageSender ¶
type MessageSender struct {
// contains filtered or unexported fields
}
MessageSender handles sending wire protocol messages to a given peer
func NewCustomMessageSender ¶
func NewCustomMessageSender(blacklistedUA string, withMsgNot bool) *MessageSender
func (*MessageSender) GetMsgNotifier ¶
func (ms *MessageSender) GetMsgNotifier() *MsgNotifier
func (*MessageSender) Init ¶
func (ms *MessageSender) Init(h host.Host, protocols []protocol.ID) pb.MessageSender
func (*MessageSender) SendMessage ¶
SendMessage is a custom wrapper on top of the pb.MessageSender that sends a given msg to a peer and notifies throught the given notification channel of the sent msg status
type MsgNotification ¶
type MsgNotification struct { RemotePeer peer.ID QueryTime time.Time QueryDuration time.Duration Msg pb.Message Resp pb.Message Error error }
MsgNotification is the basic notification struct received and send by the dht messenger
type MsgNotifier ¶
type MsgNotifier struct {
// contains filtered or unexported fields
}
MsgNotifier represents the communication channel or the debugging channel for the Hoarder to identify the messages sent over the DHT messenger
func NewMsgNotifier ¶
func NewMsgNotifier() *MsgNotifier
func (*MsgNotifier) Close ¶
func (n *MsgNotifier) Close()
func (*MsgNotifier) GetNotifierChan ¶
func (n *MsgNotifier) GetNotifierChan() chan *MsgNotification
func (*MsgNotifier) Notify ¶
func (n *MsgNotifier) Notify(msgStatus *MsgNotification)
type ProvideOption ¶
type ProvideOption string
func GetProvOpFromConf ¶
func GetProvOpFromConf(strOp string) ProvideOption
type RowComposer ¶
type RowComposer func([]interface{}) []string