archon_dht

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: GPL-3.0 Imports: 37 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AutoNATServiceDialTimeout   = 15 * time.Second
	AutoNATServiceResetInterval = 1 * time.Minute

	AutoNATServiceThrottle = 3
)
View Source
var SpFilenames = permLayer.SpFilenames

Functions

func GenerateRSAKey

func GenerateRSAKey(seed int64) (crypto.PrivKey, error)

Generate RSAKey generates a new RSA key based on config.Seed

func GetNodeID

func GetNodeID(seed int64) (peer.ID, error)

func GetRSAKey

func GetRSAKey(seed int64) (p crypto.PrivKey, e error)

GetRSAKey returns the key from the "rsa_key.priv" file. If needed creates a new key and file

func PollReportConnectionsToNetwork

func PollReportConnectionsToNetwork(host rhost.RoutedHost, config DHTConnectionConfig, interval time.Duration)

func StringToCid

func StringToCid(key string) (cid.Cid, error)

func StringsToCids

func StringsToCids(keys []string) ([]cid.Cid, error)

Types

type ArchonDHT

type ArchonDHT struct {
	PermissionLayerId permLayer.PermissionLayerID

	Config DHTConnectionConfig
	// contains filtered or unexported fields
}

func (*ArchonDHT) Connect

func (a *ArchonDHT) Connect(peer peer.AddrInfo) error

func (*ArchonDHT) FindPeer

func (a *ArchonDHT) FindPeer(peerId peer.ID) (peer.AddrInfo, error)

func (*ArchonDHT) GetUrlsOfNodesHoldingKeys

func (a *ArchonDHT) GetUrlsOfNodesHoldingKeys(keys []string, timeoutInSeconds time.Duration) (UrlArray, error)

each key is some pre-image of the cid mapping. depending on implementation, this can be an archonNamedUrl + <shardIdx>, archonHashUrl + <shardIdx>, etc

func (*ArchonDHT) Peers

func (a *ArchonDHT) Peers() peer.IDSlice

type ArchonDHTs

type ArchonDHTs struct {
	Layers PermissionLayer2ArchonDHT
}

func Init

func Init(configArr []DHTConnectionConfig, basePort int) (*ArchonDHTs, error)

Init is essentially the main entrypoint to archon-dht, see README for suggestions on populating and collating configArr and setting basePort For each config in configArr, initializes a dht layer corresponding to respective permissionLayer of config

func (*ArchonDHTs) AddLayer

func (a *ArchonDHTs) AddLayer(permissionLayerId permLayer.PermissionLayerID, rh *rhost.RoutedHost, d *dht.IpfsDHT, c DHTConnectionConfig)

Used to build up ArchonDHTs. See Init(...) in init.go

func (*ArchonDHTs) GetArchonSPProfilesForMarketplace

func (a *ArchonDHTs) GetArchonSPProfilesForMarketplace(permissionLayerID permLayer.PermissionLayerID) (c []RegisteredSp, e error)

The returned collection of registeredSps are to populate a local marketplace instance to optimally match an upload to a within a collection of storage providers.

func (*ArchonDHTs) GetUrls

func (a *ArchonDHTs) GetUrls(nodeIDs []string,
	permissionLayerID permLayer.PermissionLayerID,
	timeout time.Duration) (map[string]string,
	error)

func (*ArchonDHTs) GetUrlsOfNodesHoldingKeysFromAllLayers

func (a *ArchonDHTs) GetUrlsOfNodesHoldingKeysFromAllLayers(keys []string, timeoutInSeconds time.Duration) (PermissionLayer2UrlArray, error)

each key is some pre-image of the cid mapping. depending on implementation, this can be an archonNamedUrl + <shardIdx>, archonHashUrl + <shardIdx>, etc

func (*ArchonDHTs) Init

func (a *ArchonDHTs) Init()

func (*ArchonDHTs) RunTestTriggerServer

func (a *ArchonDHTs) RunTestTriggerServer()

func (ArchonDHTs) Stored

func (a ArchonDHTs) Stored(key string, versionData *permLayer.VersionData) error

Called by sp to broadcast to dht contentID:{url, versionData}, so that downloaders, given contentID, can regtrieve the (download)url. The versionData is input to a preference function on routing. i.e. archon's versioning system

type ArchonValidator

type ArchonValidator struct {
	PermissionLayer permLayer.PermissionLayer
}

Validator validates and orders by preference nodes, or keys:value pairs in the in the dht

func (ArchonValidator) Select

func (c ArchonValidator) Select(key string, values [][]byte) (int, error)

func (ArchonValidator) Validate

func (c ArchonValidator) Validate(key string, value []byte) error

type DHTConnectionConfig

type DHTConnectionConfig struct {
	Seed                  int64           // seed to initialize fresh dht rsa keyset and id
	Global                bool            // bootstrap to global set
	IAmBootstrap          bool            // declare if self is a bootstrap node
	OptInToNetworkLogging bool            // self-explanatory
	CountryCode           gountries.Codes // self-reported country code
	PermissionLayer       permLayer.PermissionLayer
	Url                   string // this should be copied from archonSP config
	//
	MyPartialMultiAddress string
	BootstrapPeers        []string
}

type IdOutput

type IdOutput struct {
	ID              string
	PublicKey       string
	Addresses       []string
	AgentVersion    string
	ProtocolVersion string
}

Borrowed from ipfs code to parse the results of the command `ipfs id`

type NodeIDAndUrl

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

type PermissionLayer2ArchonDHT

type PermissionLayer2ArchonDHT map[permLayer.PermissionLayerID]*ArchonDHT

type PermissionLayer2UrlArray

type PermissionLayer2UrlArray map[permLayer.PermissionLayerID]UrlArray

type ReportConnectionsLog

type ReportConnectionsLog struct {
	PermLayerID   permLayer.PermissionLayerID
	NodeId        peer.ID         `json: "nodeid`         // type will be specific to the id of the host
	ConnectionIds []peer.ID       `json: "connectionids"` // type will be specific to the ids of connections
	Time          time.Time       `json: "time"`
	CountryCode   gountries.Codes `json: countrycode`
}

type UrlArray

type UrlArray []string

type UrlsStruct

type UrlsStruct struct {
	Urls      string `json:urls`
	Signature []byte `json:signature`
	PublicKey []byte `json:public_key`
}

type UrlsVersionedStruct

type UrlsVersionedStruct struct {
	Urls       string                `json:download_urls`
	Versioning permLayer.VersionData `json:versioning`
	Signature  []byte                `json:signature`
	PublicKey  []byte                `json:public_key`
}

type WrappedLog

type WrappedLog struct {
	Log ReportConnectionsLog
}

Jump to

Keyboard shortcuts

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