protocol

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package network contains the implementation of network protocol handler for fractal.

Index

Constants

View Source
const (
	// Protocol messages belonging to ftl1
	StatusMsg = 0x00

	// for block propagation
	NewBlockMsg = 0x01

	//
	GetBlocksMsg = 0x02
	BlocksMsg    = 0x03

	// for tx propagation
	TxMsg = 0x04

	// for tx package propagation
	TxPackageHashMsg = 0x05
	GetTxPackageMsg  = 0x06
	TxPackageMsg     = 0x07

	// for state sync
	GetNodeDataMsg = 0x08
	NodeDataMsg    = 0x09

	// for hash list (cp2fp, fastsync, peersync)
	SyncHashListReqMsg = 0x0a
	SyncHashListResMsg = 0x0b

	// for pre blocks sync
	SyncPreBlocksForStateReqMsg = 0x0c
	SyncPreBlocksForStateRspMsg = 0x0d

	// for post blocks sync
	SyncPostBlocksForStateReqMsg = 0x0e
	SyncPostBlocksForStateRspMsg = 0x0f

	// for block sync (cp2fp, fastsync, peersync)
	GetPkgsForBlockSyncMsg   = 0x10
	PkgsForBlockSyncMsg      = 0x11
	GetBlocksForBlockSyncMsg = 0x12
	BlocksForBlockSyncMsg    = 0x13
)

ftl protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
	ErrInvalidRepSyncBlockMsg
)
View Source
const ProtocolMaxMsgSize = 512 * 1024 * 1024 // Maximum cap on the size of a protocol message

Variables

View Source
var ProtocolLengths = []uint64{20}

ProtocolLengths are the number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "ftl"

ProtocolName is the official short name of the protocol used during capability negotiation.

View Source
var ProtocolVersions = []uint{ftl2}

ProtocolVersions are the upported versions of the ftl protocol (first is primary).

Functions

This section is empty.

Types

type ErrCode

type ErrCode int

func (ErrCode) String

func (e ErrCode) String() string

type FetchBlockRsp

type FetchBlockRsp struct {
	Blocks     []*types.Block
	TxPackages []*types.TxPackage
	RoundTo    uint64
	Finished   bool
}

type GetBlocksData

type GetBlocksData struct {
	OriginHash common.Hash // block from which to retrieve Blocks
	Depth      uint64
	Reverse    bool
	RoundFrom  uint64 // block from which to retrieve Blocks
	RoundTo    uint64 // block to which to retrieve Blocks
}

getBlocksData represents a block query.

type HashElem

type HashElem struct {
	Height uint64
	Hash   common.Hash
	Round  uint64
}

func (HashElem) CompareTo

func (h HashElem) CompareTo(h1 HashElem) int

func (HashElem) String

func (h HashElem) String() string

type HashElems

type HashElems []*HashElem

type IntervalHashReq

type IntervalHashReq struct {
	HashEFrom HashElem
	HashETo   HashElem
}

type NewBlockData

type NewBlockData struct {
	Block  *types.Block
	Height uint64
}

newBlockData is the network packet for the block propagation message.

type StatusData

type StatusData struct {
	ProtocolVersion   uint32
	NetworkId         uint64
	Round             uint64
	Height            uint64
	CurrentFullHash   common.Hash
	CurrentSimpleHash common.Hash
	GenesisHash       common.Hash
}

statusData is the network packet for the status message.

type SyncBlocksReq

type SyncBlocksReq struct {
	Stage     SyncStage
	RoundFrom uint64 // block from which to retrieve Blocks
	RoundTo   uint64 // block to which to retrieve Blocks
}

type SyncBlocksRsp

type SyncBlocksRsp struct {
	Stage     SyncStage
	Blocks    types.Blocks
	RoundFrom uint64 // block from which to retrieve Blocks
	RoundTo   uint64 // block to which to retrieve Blocks
}

type SyncHashListReq

type SyncHashListReq struct {
	Stage      SyncStage
	Type       SyncHashType
	HashFrom   common.Hash
	HeightFrom uint64
	HashTo     common.Hash
	HeightTo   uint64
}

type SyncHashListRsp

type SyncHashListRsp struct {
	Stage  SyncStage
	Type   SyncHashType
	Hashes HashElems
}

type SyncHashType

type SyncHashType byte
const (
	SyncHashTypeBegin SyncHashType = iota
	SyncHashTypeLong
	SyncHashTypeShort
	SyncHashTypeEnd
)

func (SyncHashType) String

func (s SyncHashType) String() string

type SyncPkgsReq

type SyncPkgsReq struct {
	Stage     SyncStage
	PkgHashes []common.Hash
}

type SyncPkgsRsp

type SyncPkgsRsp struct {
	Stage SyncStage
	Pkgs  types.TxPackages
}

type SyncStage

type SyncStage byte
const (
	SyncStageBegin SyncStage = iota
	SyncStageCP2FP
	SyncStageFastSync
	SyncStagePeerSync
	SyncStageEnd
)

func (SyncStage) String

func (s SyncStage) String() string

Jump to

Keyboard shortcuts

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