sting

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

View Source
const (
	MessageTypeMilestoneRequest   message.Type = 3
	MessageTypeTransaction        message.Type = 4
	MessageTypeTransactionRequest message.Type = 5
	MessageTypeHeartbeat          message.Type = 6
)
View Source
const (
	// The amount of bytes used for the requested transaction hash.
	RequestedTransactionHashMsgBytesLength = 49

	// The amount of bytes used for the requested milestone index.
	RequestedMilestoneIndexMsgBytesLength = 4

	// The amount of bytes used for a milestone index within a heartbeat packet.
	HeartbeatMilestoneIndexBytesLength = 4

	// The index to use to request the latest milestone via a milestone request message.
	LatestMilestoneRequestIndex = 0
)
View Source
const FeatureSet = 1 << 2

FeatureSet denotes the version bit for Chrysalis-Pt1 support.

View Source
const FeatureSetName = "Chrysalis-Pt1"

FeatureSetName is the name of the feature set.

Variables

View Source
var (
	// TransactionMessageFormat defines a transaction message's format.
	TransactionMessageDefinition = &message.Definition{
		ID:             MessageTypeTransaction,
		MaxBytesLength: consts.NonSigTxPartBytesLength + consts.SigDataMaxBytesLength,
		VariableLength: true,
	}

	// The requested transaction hash gossipping packet.
	// Contains only a hash of a requested transaction payload.
	TransactionRequestMessageDefinition = &message.Definition{
		ID:             MessageTypeTransactionRequest,
		MaxBytesLength: RequestedTransactionHashMsgBytesLength,
		VariableLength: false,
	}

	// The heartbeat packet containing the current latest solid, pruned and latest milestone index,
	// number of connected neighbors and number of synced neighbors.
	HeartbeatMessageDefinition = &message.Definition{
		ID:             MessageTypeHeartbeat,
		MaxBytesLength: HeartbeatMilestoneIndexBytesLength*3 + 2,
		VariableLength: false,
	}

	// The requested milestone index packet.
	MilestoneRequestMessageDefinition = &message.Definition{
		ID:             MessageTypeMilestoneRequest,
		MaxBytesLength: RequestedMilestoneIndexMsgBytesLength,
		VariableLength: false,
	}
)
View Source
var (
	// ErrInvalidSourceLength is returned when an invalid source byte slice for extraction of certain data is passed.
	ErrInvalidSourceLength = errors.New("invalid source byte slice")
)

Functions

func ExtractRequestedMilestoneIndex

func ExtractRequestedMilestoneIndex(source []byte) (milestone.Index, error)

ExtractRequestedMilestoneIndex extracts the requested milestone index from the given source.

func HeartbeatCaller

func HeartbeatCaller(handler interface{}, params ...interface{})

func NewHeartbeatMessage

func NewHeartbeatMessage(solidMilestoneIndex milestone.Index, prunedMilestoneIndex milestone.Index, latestMilestoneIndex milestone.Index, connectedNeighbors uint8, syncedNeighbors uint8) ([]byte, error)

NewHeartbeatMessage creates a new heartbeat message.

func NewMilestoneRequestMessage

func NewMilestoneRequestMessage(requestedMilestoneIndex milestone.Index) ([]byte, error)

NewMilestoneRequestMessage creates a new milestone request message.

func NewTransactionMessage

func NewTransactionMessage(txData []byte) ([]byte, error)

NewTransactionMessage creates a new transaction message.

func NewTransactionRequestMessage

func NewTransactionRequestMessage(requestedHash hornet.Hash) ([]byte, error)

NewTransactionRequestMessage creates a transaction request message.

Types

type Heartbeat

type Heartbeat struct {
	SolidMilestoneIndex  milestone.Index `json:"solid_milestone_index"`
	PrunedMilestoneIndex milestone.Index `json:"pruned_milestone_index"`
	LatestMilestoneIndex milestone.Index `json:"latest_milestone_index"`
	ConnectedNeighbors   int             `json:"connected_neighbors"`
	SyncedNeighbors      int             `json:"synced_neighbors"`
}

Heartbeat contains information about a nodes current solid and pruned milestone index.

func ParseHeartbeat

func ParseHeartbeat(data []byte) *Heartbeat

/ ParseHeartbeat parses the given message into a heartbeat.

Jump to

Keyboard shortcuts

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