mnet_dht

package
v0.0.0-...-4adfca9 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const BEACON_INTERVAL = 5
View Source
const EDGE_REQUEST_RESPONSE = "edge_response"
View Source
const PEER_REQUEST_RESPONSE = "peer_response"

Variables

This section is empty.

Functions

This section is empty.

Types

type BeaconManager

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

func GetBeaconManager

func GetBeaconManager() *BeaconManager

returns the singleton to BeaconManager

func (*BeaconManager) CreateBaseRouteBeacon

func (bm *BeaconManager) CreateBaseRouteBeacon()

===== Base Route Beacon =====

Creates a new beacon for base route announcement and requests.

func (*BeaconManager) CreateEdgeRouteBeacon

func (bm *BeaconManager) CreateEdgeRouteBeacon(actionFunc func(map[string]string))

===== Edge Route Beacon =====

Creates a new beacon for edge route announcement and requests.

func (*BeaconManager) CreatePeerRouteBeacon

func (bm *BeaconManager) CreatePeerRouteBeacon(actionFunc func(map[string]string))

===== Peer Route Beacon =====

Creates a new beacon for peer route announcement and requests.

func (*BeaconManager) StartBaseRouteAnnouncement

func (bm *BeaconManager) StartBaseRouteAnnouncement(baseRouteBeaconKey *rsa.PublicKey)

Announce on the base route beacon that this node is a part of the base route

func (*BeaconManager) StartEdgeRouteAnnouncement

func (bm *BeaconManager) StartEdgeRouteAnnouncement(edgeRouteBeaconKey *rsa.PublicKey)

Announce on the edge route beacon that this node is a part of the edge route

func (*BeaconManager) StartEdgeRouteRequest

func (bm *BeaconManager) StartEdgeRouteRequest(baseRouteBeaconKey *rsa.PublicKey)

Start requesting for responses from peers on the base route

func (*BeaconManager) StartPeerRouteAnnouncement

func (bm *BeaconManager) StartPeerRouteAnnouncement()

Start announcing this node's PubKeyHash on the peer route

func (*BeaconManager) StartPeerRouteRequest

func (bm *BeaconManager) StartPeerRouteRequest(peerPubKeyHash string)

Start requesting for peerPubKeyHash on the peer route

func (*BeaconManager) StopBaseRouteAnnouncement

func (bm *BeaconManager) StopBaseRouteAnnouncement()

Stop announcing on the base route

func (*BeaconManager) StopEdgeRouteRequest

func (bm *BeaconManager) StopEdgeRouteRequest()

Stop requesting for responses from peers on the base route

func (*BeaconManager) StopPeerRouteAnnouncement

func (bm *BeaconManager) StopPeerRouteAnnouncement()

Stop announcing on the peer route

func (*BeaconManager) StopPeerRouteRequest

func (bm *BeaconManager) StopPeerRouteRequest(peerPubKeyHash string)

type ChanSet

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

func (*ChanSet) Add

func (set *ChanSet) Add(ch PeerChan) bool

func (*ChanSet) Remove

func (set *ChanSet) Remove(ch PeerChan)

type Config

type Config struct {
	DHTPort   int
	SeedNodes string
}

type MDHT

type MDHT struct {
	DHT *dht_lib.DHT

	//dynamic DHT router ip
	DiscoveredDHTRouterIP *map[string]int
	DiscoveredInfohash    map[string]int
	AllowedPubKey         *map[string]int

	PeerRouteActionHandlerMapping map[string]func(map[string]string)

	Log *mlog.Mlog
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMDHT

func NewMDHT(conf *Config) (*MDHT, error)

Returns a configured MDHT instance based on the provided config

func (*MDHT) AnnouncementBeacon

func (m *MDHT) AnnouncementBeacon(stop *chan bool, pubKey *rsa.PublicKey, initDelaySeconds int, delaySeconds int) error

Create a beacon to announce a pkh

func (*MDHT) RequestBeacon

func (m *MDHT) RequestBeacon(stop *chan bool, peerPubKeyHash string, action string, actionArgs []string, intervalBeacon int)

Create a request on the beacon for a specified pkh

func (*MDHT) Run

func (m *MDHT) Run() (err error)

Start the DHT instance

func (*MDHT) SelfAnnouncementBeacon

func (m *MDHT) SelfAnnouncementBeacon(stop *chan bool, initDelaySeconds int, delaySeconds int) error

Create a beacon to announce this node's pkh

type PeerChan

type PeerChan chan<- string

Jump to

Keyboard shortcuts

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