network

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIN_RELOAD_REGISTER_INTERVAL = 30
	MAX_RELOAD_REGISTER_INTERVAL = 300
)
View Source
const (
	MIN_RELOAD_SP_INTERVAL = 3
	MAX_RELOAD_SP_INTERVAL = 300 //5 min
)
View Source
const (
	SPLIST_INTERVAL_BASE = 60 // In second
	SPLIST_MAX_JITTER    = 10 // In second
	MAX_RETRY_TIMES      = 3
	ERROR_CODE_NO_SPLIST = -2
)
View Source
const (
	EVENT_SP_NO_PP_IN_STORE uint64 = iota
	EVENT_RCV_RSP_REGISTER_NEW_PP
	EVENT_RCV_STATUS_INACTIVE
	EVENT_RCV_STATUS_SUSPEND
	EVENT_RCV_RSP_ACTIVATED
	EVENT_RCV_STATE_OFFLINE
	EVENT_START_MINING
	EVENT_RCV_MINING_NOT_STARTED
	EVENT_MAINTANENCE_STOP
	EVENT_MAINTANENCE_START
	EVENT_CONN_RECONN
	EVENT_RCV_RSP_FIRST_NODE_STATUS
	EVENT_RCV_SUSPENDED_STATE
	EVENT_GET_SP_LIST
	NUMBER_EVENTS
)
View Source
const (
	STATE_INIT uint64 = iota
	STATE_GOT_SP_LIST
	STATE_NOT_CREATED
	STATE_NOT_ACTIVATED
	STATE_NOT_REGISTERED
	STATE_REGISTERING
	STATE_REGISTERED
	STATE_MAINTANENCE
	STATE_SUSPENDED
	STATE_OFFLINE
	NUMBER_STATE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CandidateSp added in v0.10.0

type CandidateSp struct {
	NetworkAddr        string
	SpResponseTimeCost int64
}

type Network

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

func GetPeer

func GetPeer(ctx context.Context) *Network

func (*Network) ChangeSp added in v0.12.0

func (p *Network) ChangeSp(ctx context.Context) func()

func (*Network) ClearPingTimeMap added in v0.10.0

func (p *Network) ClearPingTimeMap()

func (*Network) ClearSpCandidateList added in v0.10.0

func (p *Network) ClearSpCandidateList()

func (*Network) CloseAlternateSpConns added in v0.12.0

func (p *Network) CloseAlternateSpConns(ctx context.Context) func()

func (*Network) DeletePingTimeMap added in v0.10.0

func (p *Network) DeletePingTimeMap(key string)

func (*Network) GetPPStatusFromSP

func (p *Network) GetPPStatusFromSP(ctx context.Context)

GetPPStatusFromSP send ReqGetPPStatus to SP

func (*Network) GetSPList

func (p *Network) GetSPList(ctx context.Context) func()

GetSPList node get spList

func (*Network) GetSpCandidateList added in v0.10.0

func (p *Network) GetSpCandidateList() []CandidateSp

func (*Network) GetStateFromFsm added in v0.10.0

func (n *Network) GetStateFromFsm() utils.State

func (*Network) InitFsm added in v0.10.0

func (n *Network) InitFsm()

func (*Network) ListenOffline

func (p *Network) ListenOffline(ctx context.Context)

func (*Network) LoadPingTimeMap added in v0.10.0

func (p *Network) LoadPingTimeMap(key string) (int64, bool)

func (*Network) RegisterToSP

func (p *Network) RegisterToSP(ctx context.Context)

RegisterToSP send ReqRegister to SP

func (*Network) ReportNodeStatus

func (p *Network) ReportNodeStatus(ctx context.Context)

func (*Network) RunFsm added in v0.10.0

func (n *Network) RunFsm(ctx context.Context, eventId uint64)

func (*Network) ScheduleSpLatencyCheck added in v0.10.0

func (p *Network) ScheduleSpLatencyCheck(ctx context.Context)

func (*Network) SpLatencyCheck added in v0.10.0

func (p *Network) SpLatencyCheck(ctx context.Context) func()

func (*Network) StartGetSPList added in v0.10.0

func (p *Network) StartGetSPList(ctx context.Context) func()

func (*Network) StartMining

func (p *Network) StartMining(ctx context.Context)

StartMining send ReqMining to SP if needed

func (*Network) StartPP

func (p *Network) StartPP(ctx context.Context)

func (*Network) StartRegisterToSp

func (p *Network) StartRegisterToSp(ctx context.Context)

StartStatusReportToSP to start a timer scheduling reporting Node Status to SP

func (*Network) StartStatusReportToSP

func (p *Network) StartStatusReportToSP(ctx context.Context)

StartStatusReportToSP to start a timer scheduling reporting Node Status to SP

func (*Network) StorePingTimeMap added in v0.10.0

func (p *Network) StorePingTimeMap(server string, start int64)

func (*Network) UpdateSpCandidateList added in v0.10.0

func (p *Network) UpdateSpCandidateList(c CandidateSp)

Jump to

Keyboard shortcuts

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