netsnapshot

package
v0.0.0-...-05b8940 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: ISC, ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func NewTaker

func NewTaker(store DataStore, cfg config.NetworkSnapshotOptions) *taker

func Snapshotinterval

func Snapshotinterval() int

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type CountryInfo

type CountryInfo struct {
	Country   string `json:"country"`
	Nodes     int64  `json:"nodes"`
	Timestamp int64  `json:"timestamp"`
}

type DataStore

type DataStore interface {
	LastSnapshotTime(ctx context.Context) (timestamp int64)
	DeleteSnapshot(ctx context.Context, timestamp int64)
	SaveSnapshot(ctx context.Context, snapShot SnapShot) error
	SaveHeartbeat(ctx context.Context, peer Heartbeat) error
	AttemptPeer(ctx context.Context, address string, now int64) error
	RecordNodeConnectionFailure(ctx context.Context, address string, maxAllowedFailure int) error
	SaveNode(ctx context.Context, peer NetworkPeer) error
	UpdateNode(ctx context.Context, peer NetworkPeer) error
	GetAvailableNodes(ctx context.Context) ([]net.IP, error)
	LastSnapshot(ctx context.Context) (*SnapShot, error)
	GetIPLocation(ctx context.Context, ip string) (string, int, error)
	NodeExists(ctx context.Context, address string) (bool, error)
}

type Heartbeat

type Heartbeat struct {
	Timestamp     int64  `json:"timestamp"`
	Address       string `json:"address"`
	LastSeen      int64  `json:"last_seen"`
	Latency       int    `json:"latency"`
	CurrentHeight int64  `json:"current_height"`
}

type IPInfo

type IPInfo struct {
	Type        string `json:"type"`
	CountryCode string `json:"country_code"`
	CountryName string `json:"country_name"`
	RegionCode  string `json:"region_code"`
	RegionName  string `json:"region_name"`
	City        string `json:"city"`
	Zip         string `json:"zip"`
}

type Manager

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

func NewManager

func NewManager(dataDir string, showDetailedLog bool) (*Manager, error)

func (*Manager) AddAddresses

func (m *Manager) AddAddresses(addrs []peerAddress) int

func (*Manager) Addresses

func (m *Manager) Addresses() []peerAddress

Addresses returns IPs that need to be tested again.

func (*Manager) Attempt

func (m *Manager) Attempt(ip net.IP)

func (*Manager) Good

func (m *Manager) Good(p *peer.Peer)

type NetworkPeer

type NetworkPeer struct {
	Timestamp       int64  `json:"timestamp"`
	Address         string `json:"address"`
	UserAgent       string `json:"user_agent"`
	StartingHeight  int64  `json:"starting_height"`
	CurrentHeight   int64  `json:"current_height"`
	ConnectionTime  int64  `json:"connection_time"`
	ProtocolVersion uint32 `json:"protocol_version"`
	LastSeen        int64  `json:"last_seen"`
	LastSuccess     int64  `json:"last_success"`
	IsDead          bool   `json:"is_dead"`
	Latency         int    `json:"latency"`
	Reachable       bool   `json:"reachable"`
	IPVersion       int    `json:"ip_version"`
	Services        string `json:"services"`
	LastAttempt     int64  `json:"last_attempt"`

	IPInfo
}

type Node

type Node struct {
	IP           net.IP
	Port         uint16
	Services     wire.ServiceFlag
	LastAttempt  time.Time
	AttemptCount int
	LastSuccess  time.Time
	LastSeen     time.Time
	Latency      int64

	ConnectionTime  int64
	ProtocolVersion uint32
	UserAgent       string
	StartingHeight  int64
	CurrentHeight   int64
	IPVersion       int
}

type NodeCount

type NodeCount struct {
	Timestamp int64 `json:"timestamp"`
	Count     int64 `json:"count"`
}

type SnapShot

type SnapShot struct {
	Timestamp           int64  `json:"timestamp"`
	Height              int64  `json:"height"`
	NodeCount           int    `json:"node_count"`
	ReachableNodeCount  int    `json:"reachable_node_count"`
	OldestNode          string `json:"oldest_node"`
	OldestNodeTimestamp int64  `json:"oldest_node_timestamp"`
	Latency             int    `json:"latency"`
}

type UserAgentInfo

type UserAgentInfo struct {
	UserAgent string `json:"user_agent"`
	Nodes     int64  `json:"nodes"`
	Timestamp int64  `json:"timestamp"`
}

Jump to

Keyboard shortcuts

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