heartbeat

package
v0.0.0-...-4f0ab6e Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 19 Imported by: 0

README

Package of heartbeat

heartbeat package is used to manage the heartbeat message of miner by HeartBeatManager. HeartBeatManager is responsible for sending and receiving heartbeat messages, and it maintains a white list of legal miners, all of whom can participate in consensus vote round.

Rules

There are some rules for heartbeat:

  • The timestamp of each heartbeat cannot be the same
  • The signature of each heartbeat can be verified
  • The heartbeat must contains a proof of miner
  • The interval between sending heartbeats can't be too long
  • The timestamp in the heartbeat cannot differ too much from the local time.

And for a miner, the online 30min(Time can be changed) condition must be met

All time rules can be set by parameters, the parameters are in the params package(params/params.go):

  • ONLINE_TIME_S: The duration of a miner must be online

  • TIME_DEVIATION_S: The acceptable deviation of time for heartbeat

  • SEND_HEARTBEAT_INTERVAL_S: The interval to send heartbeat

White list

All the miners in the white list are considered legal. The miner who wants to enter the white list must abide by the following rules:

  • Make sure online is more than 30min
  • Send heartbeat frequently

For testnet

For testnet, the first batch of miners do not need to wait for a while, so we can adjust the time parameter by rpc.

The interface is SetHeartBeatTime, it need three parameters:

  • online to set the miner should online time
  • deviation to set the acceptable deviation of time for heartbeat
  • interval to set interval to send heartbeat

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewThreadHeartBeatManager

func NewThreadHeartBeatManager(pk, sk []byte, dPool idepositpool.DepositPool, metrics *metrics.Metrics) iheartbeat.HeartBeat

NewThreadHeartBeatManager returns the instance of ThreadHeartBeatManager. messageChan parameter is the channel for heartBeatManager to broadcast message.

Types

type Manager

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

Manager is used to manage nodes to send and receive heartbeat messages.

func (*Manager) Act

func (manager *Manager) Act(e *message.Event, callback func(m interface{}))

Act implements the actor interface.

type ThreadHeartBeatManager

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

ThreadHeartBeatManager is the wrapper of HearBeatManager. This implements the Actor pattern, it is concurrency safe.

func (*ThreadHeartBeatManager) CheckConfirmation

func (thbm *ThreadHeartBeatManager) CheckConfirmation(msg *wire.MsgBlockConfirmation) bool

CheckConfirmation is used to check whether the msg contains enough confirmations.

func (*ThreadHeartBeatManager) Has

func (thbm *ThreadHeartBeatManager) Has(pk []byte) bool

Has is used to determine whether the heartbeat information of a given miner has been received.

func (*ThreadHeartBeatManager) PerceivedCount

func (thbm *ThreadHeartBeatManager) PerceivedCount() int

PerceivedCount returns the counts of legal message of heartbeat.

func (*ThreadHeartBeatManager) Start

func (thbm *ThreadHeartBeatManager) Start()

Start is used to make heartBeatManager work, it will start to send heartbeat message.

func (*ThreadHeartBeatManager) Stop

func (thbm *ThreadHeartBeatManager) Stop()

Stop is used to stop sending heartbeat message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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