agent

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIBTPNotFound = fmt.Errorf("receipt from bitxhub failed")
)

agent is responsible for interacting with bitxhub

Functions

This section is empty.

Types

type Agent

type Agent interface {
	// Appchain will query if this appchain has registered to bitxhub.
	// If this appchain related to the pier has registered, bitxhub will return
	// some basic info about this chain. Otherwise, pier will get not exist appchain error.
	Appchain() (*rpcx.Appchain, error)

	// syncBlockHeaer tries to get an channel of Headers from bitxhub.
	// Note: only the header beyond the height of sync-header request moment will be sent to this channel
	SyncBlockHeader(ctx context.Context, ch chan *pb.BlockHeader) error

	// GetBlockHeader tries to get headers whose height is in the interval of [begin, end]
	// All these headers will be sent the channel.
	GetBlockHeader(ctx context.Context, begin, end uint64, ch chan *pb.BlockHeader) error

	// SyncInterchainTxWrapper tries to get an channel of interchain tx wrapper from bitxhub.
	// Note: only the interchain tx wrappers beyond the height of sync-header request moment will be sent to this channel
	SyncInterchainTxWrappers(ctx context.Context, ch chan *pb.InterchainTxWrappers) error

	// SyncUnionInterchainTxWrapper tries to get an channel of union interchain tx wrapper from bitxhub.
	// Note: only the union interchain tx wrappers beyond the height of sync-header request moment will be sent to this channel
	SyncUnionInterchainTxWrappers(ctx context.Context, txCh chan *pb.InterchainTxWrappers) error

	// GetInterchainTxWrapper tries to get txWrappers whose height is in the interval of [begin, end]
	// All these wrappers will be sent the channel.
	GetInterchainTxWrappers(ctx context.Context, begin, end uint64, ch chan *pb.InterchainTxWrappers) error

	// SendTransaction sends the wrapped interchain tx to bitxhub
	SendTransaction(tx *pb.Transaction) (*pb.Receipt, error)

	// InvokeContract invokes contract of bitxhub
	InvokeContract(vmType pb.TransactionData_VMType, address *types.Address, method string, opts *rpcx.TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)

	// SendIBTP sends wrapped ibtp to bitxhub internal VM to execute
	SendIBTP(ibtp *pb.IBTP) (*pb.Receipt, error)

	// GetIBTPByID queries interchain ibtp package record given an unique id of ibtp from bitxhub
	GetIBTPByID(id string) (*pb.IBTP, error)

	// GetChainMeta gets chain meta of relay chain
	GetChainMeta() (*pb.ChainMeta, error)

	GetInterchainMeta() (*pb.Interchain, error)

	GetAssetExchangeSigns(id string) ([]byte, error)

	//GetIBTPSigns gets ibtp signs from bitxhub cluster
	GetIBTPSigns(ibtp *pb.IBTP) ([]byte, error)

	//GetAppchains gets appchains from bitxhub node
	GetAppchains() ([]*rpcx.Appchain, error)

	//GetInterchainById gets interchain meta by appchain id
	GetInterchainById(from string) *pb.Interchain

	// GetPendingNonceByAccount get the latest pending nonce of the account
	GetPendingNonceByAccount(account string) (uint64, error)
}

type BxhAgent

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

BxhAgent represents the necessary data for interacting with bitxhub

func New

func New(client rpcx.Client, pierID types.Address, bitxhub repo.Relay) (*BxhAgent, error)

New create an instance of BxhAgent given the client of bitxhub and the appchain id and some configuration of bitxhub

func (*BxhAgent) Appchain

func (agent *BxhAgent) Appchain() (*rpcx.Appchain, error)

Appchain implements Agent

func (*BxhAgent) GetAppchains added in v1.4.0

func (agent *BxhAgent) GetAppchains() ([]*rpcx.Appchain, error)

func (*BxhAgent) GetAssetExchangeSigns added in v1.4.0

func (agent *BxhAgent) GetAssetExchangeSigns(id string) ([]byte, error)

func (*BxhAgent) GetBlockHeader

func (agent *BxhAgent) GetBlockHeader(ctx context.Context, begin, end uint64, ch chan *pb.BlockHeader) error

func (*BxhAgent) GetChainMeta

func (agent *BxhAgent) GetChainMeta() (*pb.ChainMeta, error)

GetChainMeta implements Agent

func (*BxhAgent) GetIBTPByID

func (agent *BxhAgent) GetIBTPByID(id string) (*pb.IBTP, error)

GetIBTPByID implements Agent

func (*BxhAgent) GetIBTPSigns added in v1.4.0

func (agent *BxhAgent) GetIBTPSigns(ibtp *pb.IBTP) ([]byte, error)

func (*BxhAgent) GetInterchainById added in v1.4.0

func (agent *BxhAgent) GetInterchainById(from string) *pb.Interchain

func (*BxhAgent) GetInterchainMeta

func (agent *BxhAgent) GetInterchainMeta() (*pb.Interchain, error)

func (*BxhAgent) GetInterchainTxWrappers added in v1.4.0

func (agent *BxhAgent) GetInterchainTxWrappers(ctx context.Context, begin, end uint64, ch chan *pb.InterchainTxWrappers) error

GetInterchainTxWrapper implements Agent

func (*BxhAgent) GetPendingNonceByAccount added in v1.4.0

func (agent *BxhAgent) GetPendingNonceByAccount(account string) (uint64, error)

func (*BxhAgent) GetReceipt

func (agent *BxhAgent) GetReceipt(hash string) (*pb.Receipt, error)

GetReceipt implements Agent

func (*BxhAgent) InvokeContract added in v1.4.0

func (agent *BxhAgent) InvokeContract(vmType pb.TransactionData_VMType, address *types.Address, method string, opts *rpcx.TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)

InvokeContract implements Agent

func (*BxhAgent) SendIBTP

func (agent *BxhAgent) SendIBTP(ibtp *pb.IBTP) (*pb.Receipt, error)

SendIBTP implements Agent

func (*BxhAgent) SendTransaction

func (agent *BxhAgent) SendTransaction(tx *pb.Transaction) (*pb.Receipt, error)

SendTransaction implements Agent

func (*BxhAgent) Stop

func (agent *BxhAgent) Stop() error

func (*BxhAgent) SyncBlockHeader

func (agent *BxhAgent) SyncBlockHeader(ctx context.Context, headerCh chan *pb.BlockHeader) error

func (*BxhAgent) SyncInterchainTxWrappers added in v1.4.0

func (agent *BxhAgent) SyncInterchainTxWrappers(ctx context.Context, txCh chan *pb.InterchainTxWrappers) error

func (*BxhAgent) SyncUnionInterchainTxWrappers added in v1.4.0

func (agent *BxhAgent) SyncUnionInterchainTxWrappers(ctx context.Context, txCh chan *pb.InterchainTxWrappers) error

type BxhClient added in v1.4.0

type BxhClient struct {
	rpcx.Appchain
	// contains filtered or unexported fields
}

BxhClient represents plugin client fo relaychain, by packing operations of relaychain to an appchain plugin-client, we can easily excute ibtp.Payload on relaychain just like what we used to do on an appchain.

func CreateClient added in v1.4.0

func CreateClient(agent Agent) *BxhClient

CreateClient creates plugin client from agent

func (*BxhClient) CommitCallback added in v1.4.0

func (client *BxhClient) CommitCallback(ibtp *pb.IBTP) error

CommitCallback .

func (*BxhClient) GetCallbackMeta added in v1.4.0

func (client *BxhClient) GetCallbackMeta() (map[string]uint64, error)

GetCallbackMeta gets an index map, which implicates the greatest index of executed callback txs for each receiving chain TODO

func (*BxhClient) GetIBTP added in v1.4.0

func (client *BxhClient) GetIBTP() chan *pb.IBTP

GetIBTP .

func (*BxhClient) GetInMessage added in v1.4.0

func (client *BxhClient) GetInMessage(from string, idx uint64) ([][]byte, error)

GetInMessage gets receipt by index and source chain_id TODO

func (*BxhClient) GetInMeta added in v1.4.0

func (client *BxhClient) GetInMeta() (map[string]uint64, error)

GetInMeta gets an index map, which implicates the greatest index of ingoing interchain txs for each source chain

func (*BxhClient) GetOutMessage added in v1.4.0

func (client *BxhClient) GetOutMessage(to string, idx uint64) (*pb.IBTP, error)

GetOutMessage .

func (*BxhClient) GetOutMeta added in v1.4.0

func (client *BxhClient) GetOutMeta() (map[string]uint64, error)

GetOutMeta .

func (*BxhClient) Initialize added in v1.4.0

func (client *BxhClient) Initialize(configPath string, pierID string, extra []byte) error

Initialize .

func (*BxhClient) Name added in v1.4.0

func (client *BxhClient) Name() string

Name .

func (*BxhClient) Start added in v1.4.0

func (client *BxhClient) Start() error

Start .

func (*BxhClient) Stop added in v1.4.0

func (client *BxhClient) Stop() error

Stop .

func (*BxhClient) SubmitIBTP added in v1.4.0

func (client *BxhClient) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error)

SubmitIBTP submits the inter-relaychain ibtp to relaychain to execute ibtp.Payload

func (*BxhClient) Type added in v1.4.0

func (client *BxhClient) Type() string

Type .

Directories

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

Jump to

Keyboard shortcuts

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