proto

package
v0.0.0-...-83a01c7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name              = "luckyshare"
	Version    uint   = 1
	Length     uint64 = 8
	MaxMsgSize        = 10 * 1024 * 1024
)

Constants

View Source
const (
	MsgGetStatus = iota
	MsgNewBlockID
	MsgNewBlock
	MsgNewTx
	MsgGetBlockByID
	MsgGetBlockIDByNumber
	MsgGetBlocksFromNumber // fetch blocks from given number (including given number)
	MsgGetTxs
)

Protocol messages of luckyshare

Variables

This section is empty.

Functions

func GetBlockByID

func GetBlockByID(ctx context.Context, rpc RPC, id luckyshare.Bytes32) (rlp.RawValue, error)

GetBlockByID query block from remote peer by given block ID. It may return nil block even no error.

func GetBlockIDByNumber

func GetBlockIDByNumber(ctx context.Context, rpc RPC, num uint32) (luckyshare.Bytes32, error)

GetBlockIDByNumber query block ID from remote peer by given number.

func GetBlocksFromNumber

func GetBlocksFromNumber(ctx context.Context, rpc RPC, num uint32) ([]rlp.RawValue, error)

GetBlocksFromNumber get a batch of blocks starts with num from remote peer.

func GetTxs

func GetTxs(ctx context.Context, rpc RPC) (tx.Transactions, error)

GetTxs get txs from remote peer.

func MsgName

func MsgName(msgCode uint64) string

MsgName convert msg code to string.

func NotifyNewBlock

func NotifyNewBlock(ctx context.Context, rpc RPC, block *block.Block) error

NotifyNewBlock notify new block to remote peer.

func NotifyNewBlockID

func NotifyNewBlockID(ctx context.Context, rpc RPC, id luckyshare.Bytes32) error

NotifyNewBlockID notify new block ID to remote peer.

func NotifyNewTx

func NotifyNewTx(ctx context.Context, rpc RPC, tx *tx.Transaction) error

NotifyNewTx notify new tx to remote peer.

Types

type RPC

type RPC interface {
	Notify(ctx context.Context, msgCode uint64, arg interface{}) error
	Call(ctx context.Context, msgCode uint64, arg interface{}, result interface{}) error
}

RPC defines RPC interface.

type Status

type Status struct {
	GenesisBlockID luckyshare.Bytes32
	SysTimestamp   uint64
	BestBlockID    luckyshare.Bytes32
	TotalScore     uint64
}

Status result of MsgGetStatus.

func GetStatus

func GetStatus(ctx context.Context, rpc RPC) (*Status, error)

GetStatus get status of remote peer.

Jump to

Keyboard shortcuts

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