benchmark

package
v0.0.0-...-8442bd4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
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"
)
View Source
const (
	NoUserAgentDefined = "Not Defined"
)

Variables

View Source
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{}),
}
View Source
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 DurationToFloat64Millis(d time.Duration) float64

func ParseConError

func ParseConError(err error) string

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 NewCsvExporter

func NewCsvExporter(file string, columns []string) (*CSV, error)

func NewCsvImporter

func NewCsvImporter(file string) (*CSV, error)

func (*CSV) Close

func (c *CSV) Close() error

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) Close

func (h *DHTHost) Close()

func (*DHTHost) FindProvidersOfCID

func (h *DHTHost) FindProvidersOfCID(
	ctx context.Context,
	contentID cid.Cid) (time.Duration, []peer.AddrInfo, error)

func (*DHTHost) FindXXProvidersOfCID

func (h *DHTHost) FindXXProvidersOfCID(
	ctx context.Context,
	contentID cid.Cid,
	targetProviders int) (time.Duration, []peer.AddrInfo, *kaddht.LookupMetrics, error)

func (*DHTHost) GenRandomCID

func (h *DHTHost) GenRandomCID() (cid.Cid, error)

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) GetHostID

func (h *DHTHost) GetHostID() int

func (*DHTHost) GetLatencyToPeer

func (h *DHTHost) GetLatencyToPeer(p peer.ID) time.Duration

func (*DHTHost) GetMAddrsOfPeer

func (h *DHTHost) GetMAddrsOfPeer(p peer.ID) []ma.Multiaddr

func (*DHTHost) GetMsgNotifier

func (h *DHTHost) GetMsgNotifier() *MsgNotifier

func (*DHTHost) GetUserAgentOfPeer

func (h *DHTHost) GetUserAgentOfPeer(p peer.ID) (useragent string)

func (*DHTHost) ID

func (h *DHTHost) ID() peer.ID

func (*DHTHost) Init

func (h *DHTHost) Init() error

Init makes sure that all the components of the DHT host are successfully initialized

func (*DHTHost) ProvideCid

func (h *DHTHost) ProvideCid(ctx context.Context, contentID cid.Cid) (time.Duration, *kaddht.LookupMetrics, error)

type DHTHostOptions

type DHTHostOptions struct {
	ID               int
	IP               string
	Port             string
	ProvOp           ProvideOption
	WithNotifier     bool
	K                int
	BlacklistingUA   string
	BlacklistedPeers map[peer.ID]struct{}
}

type DHTLookupService

type DHTLookupService struct {
	// contains filtered or unexported fields
}

func NewLookupService

func NewLookupService(ctx context.Context, jobNumber, cidNumber int, exportPath string) (*DHTLookupService, error)

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

func NewLookupJob(jobId int) *LookupJob

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 (j *LookupJob) AddPingTimes(startTime, finishTime time.Time)

func (*LookupJob) AddProvideTimes

func (j *LookupJob) AddProvideTimes(startTime, finishTime time.Time)

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

func (ms *MessageSender) SendMessage(ctx context.Context, p peer.ID, pmes *pb.Message) error

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

func (*MessageSender) SendRequest

func (ms *MessageSender) SendRequest(ctx context.Context, p peer.ID, pmes *pb.Message) (*pb.Message, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL