peermessage

package
v0.0.0-...-6ee0886 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOverflowLength = errors.New("Overflow string length")
)

peermessage errors

Functions

This section is empty.

Types

type ConnectInfo

type ConnectInfo struct {
	Address        string
	Hash           string
	PingTime       time.Duration
	PingScoreBoard *ScoreBoardMap
}

ConnectInfo is a structure of connection information that includes ping time and score board.

func NewConnectInfo

func NewConnectInfo(addr string, hash string, t time.Duration) ConnectInfo

NewConnectInfo is creator of ConnectInfo

func (*ConnectInfo) ReadFrom

func (ci *ConnectInfo) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (*ConnectInfo) Score

func (ci *ConnectInfo) Score() (score int64)

Score is calculated and returned based on the ping time.

func (*ConnectInfo) WriteTo

func (ci *ConnectInfo) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type ScoreBoardMap

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

ScoreBoardMap is the structure that stores the ping time of each peer.

func (*ScoreBoardMap) Delete

func (n *ScoreBoardMap) Delete(key string)

Delete deletes the value for a key.

func (*ScoreBoardMap) Len

func (n *ScoreBoardMap) Len() int

Len returns the length of this map.

func (*ScoreBoardMap) Load

func (n *ScoreBoardMap) Load(key string) (time.Duration, bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*ScoreBoardMap) Range

func (n *ScoreBoardMap) Range(f func(string, time.Duration) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (*ScoreBoardMap) Store

func (n *ScoreBoardMap) Store(key string, value time.Duration)

Store sets the value for a key.

Jump to

Keyboard shortcuts

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