block

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePayload

func DecodePayload[T interface{}](payloadBytes []byte) (T, error)

func DecodePocket

func DecodePocket(pocketBytes []byte) (transporter.Pocket[[]byte], error)

Types

type Block

type Block struct {
	IBlock
	Name types.BlockName
	// contains filtered or unexported fields
}

func NewBlock

func NewBlock(bn *BlockNode, name types.BlockName) Block

func (*Block) Actions

func (b *Block) Actions() map[types.ActionName]BlockAction

func (*Block) ActionsNames

func (b *Block) ActionsNames() []types.ActionName

func (*Block) AddAction

func (b *Block) AddAction(name types.ActionName, action BlockAction)

func (*Block) BlockNode

func (b *Block) BlockNode() *BlockNode

func (*Block) GetName

func (b *Block) GetName() types.BlockName

type BlockAction

type BlockAction func(payload transporter.PayloadMessage) (*transporter.PayloadMessage, error)

type BlockNode

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

func GetBlockNode added in v0.1.5

func GetBlockNode() *BlockNode

func NewBlockNode

func NewBlockNode(options *BlockNodeOptions) *BlockNode

NewBlockNode creates new BlockNode struct

func (*BlockNode) AddBlock

func (bn *BlockNode) AddBlock(blocks ...IBlock) error

AddBlock adds new Block struct to BlockNode blocks map

func (*BlockNode) Blocks

func (bn *BlockNode) Blocks() map[types.BlockName][]types.ActionName

func (*BlockNode) Database

func (bn *BlockNode) Database() *db.Database

func (*BlockNode) GetName

func (bn *BlockNode) GetName() string

func (*BlockNode) NodeID

func (bn *BlockNode) NodeID() types.NodeID

func (*BlockNode) ProcessPocketDiscovery

func (bn *BlockNode) ProcessPocketDiscovery(pocket transporter.Pocket[transporter.PayloadDiscovery])

func (*BlockNode) Receive

func (bn *BlockNode) Receive(payload []byte)

func (*BlockNode) ReceiveResponse

func (bn *BlockNode) ReceiveResponse(payload []byte)

func (*BlockNode) Send

func (bn *BlockNode) Send(payload *transporter.PayloadMessage, targetAction *types.TargetAction) (*transporter.PayloadMessage, error)

func (*BlockNode) Start

func (bn *BlockNode) Start() error

Start will start BlockNode

func (*BlockNode) Stop

func (bn *BlockNode) Stop() error

func (*BlockNode) Version

func (bn *BlockNode) Version() uint

func (*BlockNode) VersionName

func (bn *BlockNode) VersionName() types.NodeVersionName

type BlockNodeOptions

type BlockNodeOptions struct {
	Name    string
	Version uint
}

type IBlock

type IBlock interface {
	GetName() types.BlockName
	Actions() map[types.ActionName]BlockAction
	ActionsNames() []types.ActionName
	AddAction(name types.ActionName, action BlockAction)
}

type SentHash

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

Jump to

Keyboard shortcuts

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