network

package
v0.11.7 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIN_RELOAD_REGISTER_INTERVAL = 60
	MAX_RELOAD_REGISTER_INTERVAL = 600
)
View Source
const (
	MIN_RELOAD_SP_INTERVAL = 3
	MAX_RELOAD_SP_INTERVAL = 900 //15 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
	NUMBER_STATE
)
View Source
const (
	MINIMAL_NUMBER_OF_PP_PEERS = 2
)

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) ChooseSpToConnectTo added in v0.10.0

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

func (*Network) ClearPingTimeMap added in v0.10.0

func (p *Network) ClearPingTimeMap(sp bool)

func (*Network) ClearSpCandidateList added in v0.10.0

func (p *Network) ClearSpCandidateList()

func (*Network) ConnectToGatewayPP

func (p *Network) ConnectToGatewayPP(ctx context.Context, pplist []*types.PeerInfo) bool

func (*Network) DeletePingTimeMap added in v0.10.0

func (p *Network) DeletePingTimeMap(key string, sp bool)

func (*Network) GetPPListFromSP

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

GetPPListFromSP node get ppList from sp

func (*Network) GetPPStatusFromSP

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

GetPPStatusFromSP send ReqGetPPStatus to SP

func (*Network) GetPPStatusInitPPList

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

GetPPStatusInitPPList P node get node status

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) InitPPList

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

func (*Network) InitPeer

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

func (*Network) LatencyOfNextPp

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

LatencyOfNextPp only when the Latency is 0 which means not measured, the measurement is started.

func (*Network) ListenOffline

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

func (*Network) LoadPingTimeMap added in v0.10.0

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

func (*Network) RegisterToSP

func (p *Network) RegisterToSP(ctx context.Context, toSP bool)

RegisterToSP send ReqRegister to SP

func (*Network) ReportNodeStatus

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

doReportNodeStatus

func (*Network) RunFsm added in v0.10.0

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

func (*Network) SchedulePpLatencyCheck added in v0.10.0

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

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) StartLatencyCheckToPp

func (p *Network) StartLatencyCheckToPp(ctx context.Context, NetworkAddr string) error

StartLatencyCheckToPp send pp latency check message to measure the latency

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, sp bool)

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