core

package
v0.0.0-...-674c92d Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaulDaemonConfig = config.AkaiDaemonConfig{}
View Source
var DefaultDHTHostOpts = &config.CommonDHTHostOpts{
	ID:           0,
	IP:           "0.0.0.0",
	Port:         9020,
	DialTimeout:  10 * time.Second,
	HostType:     config.UnknownHostType,
	DHTMode:      config.DHTUknownType,
	AgentVersion: config.ComposeAkaiAgentVersion(),
	Meter:        otel.GetMeterProvider().Meter("akai_host"),
}
View Source
var DefaultDataSamplerConfig = &config.AkaiDataSamplerConfig{
	Network:         config.DefaultNetwork.String(),
	Workers:         1000,
	SamplingTimeout: 10 * time.Second,
	DBsyncInterval:  10 * time.Minute,
	Meter:           otel.GetMeterProvider().Meter("akai_data_sampler"),
}

Functions

func DHTHostConfigFromNetworkConfig

func DHTHostConfigFromNetworkConfig(hostCfg *config.CommonDHTHostOpts, netCfg *config.NetworkConfiguration)

func ListPeerIDsFromAddrsInfos

func ListPeerIDsFromAddrsInfos(addrs []peer.AddrInfo) []peer.ID

func ParseAminoDHTHostMode

func ParseAminoDHTHostMode(mode config.DHTHostType) kaddht.ModeOpt

func ResolveDNS

func ResolveDNS(
	ctx context.Context,
	_ DHTHost,
	task SamplingTask,
	timeout time.Duration,
) (models.GeneralVisit, error)
func ResolveDNSLink(ctx context.Context, domain string, timeout time.Duration) (string, error)

func ResolveIPNSRecord

func ResolveIPNSRecord(
	ctx context.Context,
	h DHTHost,
	task SamplingTask,
	timeout time.Duration,
) (models.GeneralVisit, error)

func SampleByFindPeerInfo

func SampleByFindPeerInfo(
	ctx context.Context,
	h DHTHost,
	task SamplingTask,
	timeout time.Duration,
) (models.GeneralVisit, error)

func SampleByFindPeers

func SampleByFindPeers(
	ctx context.Context,
	h DHTHost,
	task SamplingTask,
	timeout time.Duration,
) (models.GeneralVisit, error)

func SampleByFindProviders

func SampleByFindProviders(
	ctx context.Context,
	h DHTHost,
	task SamplingTask,
	timeout time.Duration,
) (models.GeneralVisit, error)

logical sampler functions

func SampleByFindValue

func SampleByFindValue(
	ctx context.Context,
	h DHTHost,
	task SamplingTask,
	timeout time.Duration,
) (models.GeneralVisit, error)

Types

type DHTHost

type DHTHost interface {
	IntenalID() int
	Host() host.Host
	FindClosestPeers(context.Context, string, time.Duration) (time.Duration, []peer.ID, error)
	FindProviders(context.Context, cid.Cid, time.Duration) (time.Duration, []peer.AddrInfo, error)
	FindPeers(context.Context, string, time.Duration) (time.Duration, []peer.AddrInfo, error)
	FindPeer(context.Context, peer.ID, time.Duration) (time.Duration, peer.AddrInfo, error)
	FindValue(context.Context, string, time.Duration) (time.Duration, []byte, error)
	FindQuorumValue(context.Context, string, time.Duration, int) (time.Duration, [][]byte, error)
	PutValue(context.Context, string, []byte, time.Duration) (time.Duration, error)
	ConnectAndIdentifyPeer(context.Context, peer.AddrInfo, int, time.Duration) (map[string]any, error)
}

func NewDHTHost

func NewDHTHost(ctx context.Context, networkConfig *config.NetworkConfiguration, commonCfg *config.CommonDHTHostOpts) (DHTHost, error)

type Daemon

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

func NewDaemon

func NewDaemon(
	cfg config.AkaiDaemonConfig,
	h DHTHost,
	dbServ db.Database,
	dataSampler *DataSampler,
	netScrapper NetworkScrapper,
) (*Daemon, error)

TODO: remove the API from the Daemon, and add it perhaps to the Network specifics

func (*Daemon) Start

func (d *Daemon) Start(ctx context.Context) error

type DataSampler

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

func NewDataSampler

func NewDataSampler(
	cfg *config.AkaiDataSamplerConfig,
	database db.Database,
	netScrapper NetworkScrapper,
	h DHTHost,
) (*DataSampler, error)

func (*DataSampler) Serve

func (ds *DataSampler) Serve(ctx context.Context) error

type NetworkScrapper

type NetworkScrapper interface {
	GetSamplingItemStream() chan []*models.SamplingItem
	SyncWithDatabase(context.Context) ([]*models.SamplingItem, error)
	GetQuorum() int
	Serve(context.Context) error
	Close(context.Context) error
}

NetworkScrapper is the main interface that each of the network should follow in order to provide new items to the daemon for periodic sampling

type SamplingTask

type SamplingTask struct {
	VisitRound int
	Item       *models.SamplingItem
	Quorum     int
}

TODO: in the future, this could be extended to make a "smarter" division of the tasks: - key-space filltering - host selection - or similars

Jump to

Keyboard shortcuts

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