peer

package
v0.0.0-...-7359776 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Unlicense Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeReliability

func ComputeReliability(interactions []float64) float64

func SharePeerDataUpdate

func SharePeerDataUpdate(data *PeerData)

func ShareReport

func ShareReport(data *ReportStruct)

Types

type Peer

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

func NewPeer

func NewPeer(cfg *utils.Config) *Peer

func (*Peer) Close

func (p *Peer) Close()

func (*Peer) PeerInit

func (p *Peer) PeerInit() error

func (*Peer) PeerShutdown

func (p *Peer) PeerShutdown()

func (*Peer) SendMessageToPeerId

func (p *Peer) SendMessageToPeerId(message string, peerId string)

send a string message to a peer identified by peerId (or to all peers) If the given peerid doesn't exist, doesn't reply etc, it is skipped message: the string to send peerid: the peerid of the peer. Or * to broadcast to multiple peers

type PeerData

type PeerData struct {
	PeerID                string
	LastUsedIP            string
	Version               string
	Reliability           float64
	LastInteraction       time.Time
	LastGoodPing          time.Time
	LastMultiAddress      string
	BasicInteractions     []float64
	BasicInteractionTimes []time.Time
}

func (*PeerData) AddBasicInteraction

func (pd *PeerData) AddBasicInteraction(rating float64)

func (*PeerData) CanHePingMe

func (pd *PeerData) CanHePingMe() bool

func (*PeerData) SetMultiaddr

func (pd *PeerData) SetMultiaddr(multiAddress string)

func (*PeerData) SetVersion

func (pd *PeerData) SetVersion(value string) bool

func (*PeerData) ShouldIDeactivatePeer

func (pd *PeerData) ShouldIDeactivatePeer() bool

func (*PeerData) ShouldIPingPeer

func (pd *PeerData) ShouldIPingPeer() bool

type PeerStore

type PeerStore struct {
	Store       peerstore.Peerstore
	SaveFile    string
	AllPeers    map[string]*PeerData
	ActivePeers map[string]*PeerData
}

func (*PeerStore) ActivatePeer

func (ps *PeerStore) ActivatePeer(peerId string) (peerData *PeerData, isNew bool)

func (*PeerStore) CreateNewPeer

func (ps *PeerStore) CreateNewPeer(peerId string) *PeerData

func (*PeerStore) DeactivatePeer

func (ps *PeerStore) DeactivatePeer(peerId string)

func (*PeerStore) IsActivePeer

func (ps *PeerStore) IsActivePeer(peerId string) *PeerData

func (*PeerStore) IsKnown

func (ps *PeerStore) IsKnown(peerId string) *PeerData

func (*PeerStore) ReadFromFile

func (ps *PeerStore) ReadFromFile(privateKey crypto.PrivKey)

func (*PeerStore) SaveToFile

func (ps *PeerStore) SaveToFile(key crypto.PrivKey) error

type PeerUpdateStruct

type PeerUpdateStruct struct {
	PeerID      string  `json:"peerid"`
	Ip          string  `json:"ip,omitempty"`
	Reliability float64 `json:"reliability,omitempty"`
	Timestamp   int64   `json:"timestamp"`
}

type ReportMessage

type ReportMessage struct {
	MessageType     string       `json:"message_type"`
	MessageContents ReportStruct `json:"message_contents"`
}

type ReportStruct

type ReportStruct struct {
	Reporter  string `json:"reporter"`
	ReportTme int64  `json:"report_time"`
	Message   string `json:"message"`
}

type UpdateMessage

type UpdateMessage struct {
	MessageType     string           `json:"message_type"`
	MessageContents PeerUpdateStruct `json:"message_contents"`
}

Jump to

Keyboard shortcuts

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