chainbridge

package
v0.0.0-...-6cb4d45 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoData is the error returned when attempting to convert data from a command response with no data
	// Use this to test if requested appchain state is undefined
	ErrNoData = errors.New("ChainBridge: no data")

	// command response errors returned by the appchain
	Err_nodes_alreadyRegistered = "Node already registered"
)
View Source
var (
	Cmd_nodes_getNode               = "nodes getNode %s"
	Cmd_nodes_register              = "nodes register %s %d %d"
	Cmd_pki_getDocucment            = "pki getDocument %d"
	Cmd_pki_getGenesisEpoch         = "pki getGenesisEpoch"
	Cmd_pki_getMixDescriptor        = "pki getMixDescriptor %d %s"
	Cmd_pki_getMixDescriptorByIndex = "pki getMixDescriptorByIndex %d %d"
	Cmd_pki_getMixDescriptorCounter = "pki getMixDescriptorCounter %d"
	Cmd_pki_setDocument             = "pki setDocument %d"
	Cmd_pki_setMixDescriptor        = "pki setMixDescriptor %d %s"
)

appchain-agent commands; cuz compile errors are better than runtime errors

Functions

func Bool2int

func Bool2int(b bool) int

Types

type ChainBridge

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

func NewChainBridge

func NewChainBridge(socketFileOrCommandName string, commandArgs ...string) *ChainBridge

Initialize a ChainBridge instance. Accepts either: - a socket path or - a command with its arguments to launch the process.

func (*ChainBridge) Command

func (c *ChainBridge) Command(command string, payload []byte) (CommandResponse, error)

func (*ChainBridge) DataUnmarshal

func (c *ChainBridge) DataUnmarshal(response CommandResponse, v interface{}) error

func (*ChainBridge) GetDataBool

func (c *ChainBridge) GetDataBool(response CommandResponse) (bool, error)

func (*ChainBridge) GetDataBytes

func (c *ChainBridge) GetDataBytes(response CommandResponse) ([]byte, error)

func (*ChainBridge) GetDataUInt

func (c *ChainBridge) GetDataUInt(response CommandResponse) (uint64, error)

func (*ChainBridge) SetErrorHandler

func (c *ChainBridge) SetErrorHandler(handler func(error))

Set a custom error handler to be called when an error occurs.

func (*ChainBridge) SetLogHandler

func (c *ChainBridge) SetLogHandler(handler func(string))

Set a custom log handler to be called for non-error logs.

func (*ChainBridge) Start

func (c *ChainBridge) Start() error

Start the ChainBridge either by: - connecting to the existing socket path or - executing the provided command, then connecting to the socket path printed in its stdout.

func (*ChainBridge) Stop

func (c *ChainBridge) Stop() error

type CommandRequest

type CommandRequest struct {
	Command string `cbor:"command"`
	Payload []byte `cbor:"payload,omitempty"`
	ID      int    `cbor:"id,omitempty"`
}

type CommandResponse

type CommandResponse struct {
	Status string      `cbor:"status"`
	Data   interface{} `cbor:"data,omitempty"`
	Error  string      `cbor:"error,omitempty"`
	ID     int         `cbor:"id,omitempty"`
	TX     string      `cbor:"tx,omitempty"`
}

type Node

type Node struct {
	Administrator string `cbor:"administrator"`
	Identifier    string `cbor:"identifier"`
	IsGatewayNode bool   `cbor:"isGatewayNode"`
	IsServiceNode bool   `cbor:"isServiceNode"`
	IdentityKey   []byte `cbor:"identityKey"`
}

Jump to

Keyboard shortcuts

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