rpcx

package
v0.0.0-...-f069fcf Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// error type which can be fixed by retrying
	ErrRecoverable = errors.New("recoverable error")

	// error type which tx format is invalid to send
	ErrReconstruct = errors.New("invalid tx format error")

	// set ibtp and normal nonce at the same time
	ErrIllegalNonceSet = fmt.Errorf("%w: can't set ibtp nonce and normal nonce at the same time", ErrReconstruct)

	// signature for tx is invalid
	ErrSignTx = fmt.Errorf("%w: sign for transaction invalid", ErrReconstruct)

	// network problem received from grpc
	ErrBrokenNetwork = fmt.Errorf("%w: grpc broker error", ErrRecoverable)
)

Functions

func Bool

func Bool(b bool) *pb.Arg

func Bytes

func Bytes(content []byte) *pb.Arg

func Int32

func Int32(i int32) *pb.Arg

func Int64

func Int64(i int64) *pb.Arg

func String

func String(content string) *pb.Arg

func Uint32

func Uint32(i uint32) *pb.Arg

func Uint64

func Uint64(i uint64) *pb.Arg

Types

type Client

type Client interface {
	internal.Launcher

	// Reset ecdsa key.
	SetPrivateKey(crypto.PrivateKey)

	// Send a readonly transaction to link33. If the transaction is writable,
	// this transaction will not be executed and error wil be returned.
	SendView(tx *pb.BxhTransaction) (*pb.Receipt, error)

	// Send a signed transaction to link33. If the signature is illegal,
	// the transaction hash will be obtained but the transaction receipt is illegal.
	SendTransaction(tx *pb.BxhTransaction, opts *TransactOpts) (string, error)

	// Send transaction to link33 and get the receipt.
	SendTransactionWithReceipt(tx *pb.BxhTransaction, opts *TransactOpts) (*pb.Receipt, error)

	// Get the receipt by transaction hash,
	// the status of the receipt is a sign of whether the transaction is successful.
	GetReceipt(hash string) (*pb.Receipt, error)

	// Get transaction from link33 by transaction hash.
	GetTransaction(hash string) (*pb.GetTransactionResponse, error)

	// Get the current blockchain situation of link33.
	GetChainMeta() (*pb.ChainMeta, error)

	// Get blocks of the specified block height range.
	GetBlocks(start uint64, end uint64) (*pb.GetBlocksResponse, error)

	// Obtain block information from link33.
	// The block header contains the basic information of the block,
	// and the block body contains all the transactions packaged.
	GetBlock(value string, blockType pb.GetBlockRequest_Type) (*pb.Block, error)

	// Get the status of the blockchain from link33, normal or abnormal.
	GetChainStatus() (*pb.Response, error)

	// Get the validators from link33.
	GetValidators() (*pb.Response, error)

	// Get the current network situation of link33.
	GetNetworkMeta() (*pb.Response, error)

	// Get account balance from link33 by address.
	GetAccountBalance(address string) (*pb.Response, error)

	// Get the missing block header from link33.
	GetBlockHeader(ctx context.Context, begin, end uint64, ch chan<- *pb.BlockHeader) error

	// Get the missing block header from link33.
	GetInterchainTxWrappers(ctx context.Context, pid string, begin, end uint64, ch chan<- *pb.InterchainTxWrappers) error

	// Subscribe to event notifications from link33.
	Subscribe(context.Context, pb.SubscriptionRequest_Type, []byte) (<-chan interface{}, error)

	// Deploy the contract, the contract address will be returned when the deployment is successful.
	DeployContract(contract []byte, opts *TransactOpts) (contractAddr *types.Address, err error)

	// GenerateContractTx generates signed transaction to invoke contract
	GenerateContractTx(vmType pb.TransactionData_VMType, address *types.Address, method string, args ...*pb.Arg) (*pb.BxhTransaction, error)

	// GenerateIBTPTx generates interchain tx with ibtp specified
	GenerateIBTPTx(ibtp *pb.IBTP) (*pb.BxhTransaction, error)

	// Call the contract according to the contract type, contract address,
	// contract method, and contract method parameters
	InvokeContract(vmType pb.TransactionData_VMType, address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)

	// Invoke the BVM contract, BVM is link33's blot contract.
	InvokeBVMContract(address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)

	// Invoke the XVM contract, XVM is WebAssembly contract.
	InvokeXVMContract(address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)

	// Get link33's signatures specified by id and type.
	GetMultiSigns(id string, typ pb.GetMultiSignsRequest_Type) (*pb.SignResponse, error)

	// GetPendingNonceByAccount returns the latest nonce of an account in the pending status,
	// and it should be the nonce for next transaction
	GetPendingNonceByAccount(account string) (uint64, error)

	HeartBeat(address string, index string) (*pb.Response, error)
}

func New

func New(opts ...Option) (Client, error)

type Interchain

type Interchain struct {
	ID                   string            `json:"id"`
	InterchainCounter    map[string]uint64 `json:"interchain_counter,omitempty"`
	ReceiptCounter       map[string]uint64 `json:"receipt_counter,omitempty"`
	SourceReceiptCounter map[string]uint64 `json:"source_receipt_counter,omitempty"`
}

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Printf(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})

	Debug(args ...interface{})
	Info(args ...interface{})
	Print(args ...interface{})
	Warning(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Panic(args ...interface{})

	Debugln(args ...interface{})
	Infoln(args ...interface{})
	Println(args ...interface{})
	Warningln(args ...interface{})
	Errorln(args ...interface{})
	Fatalln(args ...interface{})
	Panicln(args ...interface{})
}

The FieldLogger interface generalizes the Entry and logger types

type NodeInfo

type NodeInfo struct {
	Addr       string
	EnableTLS  bool
	CertPath   string
	CommonName string
}

type Option

type Option func(*config)

func WithLogger

func WithLogger(logger Logger) Option

func WithNodesInfo

func WithNodesInfo(nodesInfo ...*NodeInfo) Option

func WithPrivateKey

func WithPrivateKey(key crypto.PrivateKey) Option

func WithTimeoutLimit

func WithTimeoutLimit(limit time.Duration) Option

type SubscriptionType

type SubscriptionType int
const (
	SubscribeNewBlock SubscriptionType = iota
)

type TransactOpts

type TransactOpts struct {
	From  string
	Nonce uint64
}

Directories

Path Synopsis
Package mock_client is a generated GoMock package.
Package mock_client is a generated GoMock package.

Jump to

Keyboard shortcuts

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