Documentation
¶
Index ¶
- Constants
- Variables
- func Bool(b bool) *pb.Arg
- func Bytes(content []byte) *pb.Arg
- func CheckReceipt(receipt *pb.Receipt) bool
- func Float32(f float32) *pb.Arg
- func Float64(f float64) *pb.Arg
- func Int32(i int32) *pb.Arg
- func Int64(i int64) *pb.Arg
- func String(content string) *pb.Arg
- func Uint32(i uint32) *pb.Arg
- func Uint64(i uint64) *pb.Arg
- func WithAPIAddrs(addrs []string) func(*IPFSClient)
- type Account
- type ChainClient
- func (cli *ChainClient) CheckMasterPier(address string) (*pb.Response, error)
- func (cli *ChainClient) DeployContract(contract []byte, opts *TransactOpts) (contractAddr *types.Address, err error)
- func (cli *ChainClient) GenerateContractTx(vmType pb.TransactionData_VMType, address *types.Address, method string, ...) (*pb.BxhTransaction, error)
- func (cli *ChainClient) GenerateIBTPTx(ibtp *pb.IBTP) (*pb.BxhTransaction, error)
- func (cli *ChainClient) GetAccountBalance(address string) (*pb.Response, error)
- func (cli *ChainClient) GetBlock(value string, blockType pb.GetBlockRequest_Type, fullTx bool) (*pb.Block, error)
- func (cli *ChainClient) GetBlockHeader(ctx context.Context, begin, end uint64, ch chan<- *pb.BlockHeader) error
- func (cli *ChainClient) GetBlocks(start uint64, end uint64, fullTx bool) (*pb.GetBlocksResponse, error)
- func (cli *ChainClient) GetChainID() (uint64, error)
- func (cli *ChainClient) GetChainMeta() (*pb.ChainMeta, error)
- func (cli *ChainClient) GetChainStatus() (*pb.Response, error)
- func (cli *ChainClient) GetInterchainTxWrappers(ctx context.Context, pid string, begin, end uint64, ...) error
- func (cli *ChainClient) GetMultiSigns(content string, typ pb.GetSignsRequest_Type) (*pb.SignResponse, error)
- func (cli *ChainClient) GetNetworkMeta() (*pb.Response, error)
- func (cli *ChainClient) GetPendingNonceByAccount(account string) (uint64, error)
- func (cli *ChainClient) GetReceipt(hash string) (*pb.Receipt, error)
- func (cli *ChainClient) GetTPS(begin, end uint64) (uint64, error)
- func (cli *ChainClient) GetTransaction(hash string) (*pb.GetTransactionResponse, error)
- func (cli *ChainClient) GetTransactionByBlockHashAndIndex(blockHash string, index uint64) (*pb.GetTransactionResponse, error)
- func (cli *ChainClient) GetTransactionByBlockNumberAndIndex(blockNum uint64, index uint64) (*pb.GetTransactionResponse, error)
- func (cli *ChainClient) GetTssSigns(content string, typ pb.GetSignsRequest_Type, extra []byte) (*pb.SignResponse, error)
- func (cli *ChainClient) GetValidators() (*pb.Response, error)
- func (cli *ChainClient) HeartBeat(address string, index string) (*pb.Response, error)
- func (cli *ChainClient) IPFSGet(path string) (*pb.Response, error)
- func (cli *ChainClient) IPFSGetToLocal(path string, localfPath string) (*pb.Response, error)
- func (cli *ChainClient) IPFSPutFromLocal(localfPath string) (*pb.Response, error)
- func (cli *ChainClient) InvokeBVMContract(address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)
- func (cli *ChainClient) InvokeContract(vmType pb.TransactionData_VMType, address *types.Address, method string, ...) (*pb.Receipt, error)
- func (cli *ChainClient) InvokeXVMContract(address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)
- func (cli *ChainClient) SendRawTransaction(tx *pb.BxhTransaction) (string, error)
- func (cli *ChainClient) SendRawTransactionWithReceipt(tx *pb.BxhTransaction) (*pb.Receipt, error)
- func (cli *ChainClient) SendTransaction(tx *pb.BxhTransaction, opts *TransactOpts) (string, error)
- func (cli *ChainClient) SendTransactionWithReceipt(tx *pb.BxhTransaction, opts *TransactOpts) (*pb.Receipt, error)
- func (cli *ChainClient) SendTransactions(txs *pb.MultiTransaction) (*pb.MultiTransactionHash, error)
- func (cli *ChainClient) SendView(tx *pb.BxhTransaction) (*pb.Receipt, error)
- func (cli *ChainClient) SetCtxMetadata(ctx context.Context) (context.Context, error)
- func (cli *ChainClient) SetMasterPier(address string, index string, timeout int64) (*pb.Response, error)
- func (cli *ChainClient) SetPrivateKey(key crypto.PrivateKey)
- func (cli *ChainClient) Stop() error
- func (cli *ChainClient) Subscribe(ctx context.Context, typ pb.SubscriptionRequest_Type, extra []byte) (<-chan interface{}, error)
- func (cli *ChainClient) SubscribeAudit(ctx context.Context, typ pb.AuditSubscriptionRequest_Type, blockHeight uint64, ...) (<-chan interface{}, error)
- type Client
- type ConnectionPool
- type IPFSClient
- func (ipfsClient *IPFSClient) AddAPIShell(addr string)
- func (ipfsClient *IPFSClient) Get(path string) ([]byte, error)
- func (ipfsClient *IPFSClient) GetToLocal(path string, localfPath string) error
- func (ipfsClient *IPFSClient) PutFromLocal(localfPath string) ([]byte, error)
- func (ipfsClient *IPFSClient) RmAPIAddr(addr string)
- type IPFSResponse
- type Interchain
- type Logger
- type NodeInfo
- type Option
- type SubscriptionType
- type TransactOpts
Constants ¶
const ( GetBlocksTimeout = 10 * time.Second GetBlockTimeout = 10 * time.Second )
const ( GetTransactionTimeout = 10 * time.Second SendTransactionTimeout = 10 * time.Second SendMultiSignsTimeout = 10 * time.Second GetReceiptTimeout = 2 * time.Second GetAccountBalanceTimeout = 2 * time.Second GetTPSTimeout = 2 * time.Second GetChainIDTimeout = 2 * time.Second CheckPierTimeout = 100 * time.Second ACCOUNT_KEY = "account" )
const (
GetInfoTimeout = 2 * time.Second
)
Variables ¶
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 CheckReceipt ¶
func WithAPIAddrs ¶
func WithAPIAddrs(addrs []string) func(*IPFSClient)
WithAPIAddrs returns ipfs client e.g []string{"http://localhost:5001"}
Types ¶
type ChainClient ¶
type ChainClient struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...Option) (*ChainClient, error)
func NewWithNoGlobalPool ¶ added in v1.28.0
func NewWithNoGlobalPool(opts ...Option) (*ChainClient, error)
func (*ChainClient) CheckMasterPier ¶
func (cli *ChainClient) CheckMasterPier(address string) (*pb.Response, error)
func (*ChainClient) DeployContract ¶
func (cli *ChainClient) DeployContract(contract []byte, opts *TransactOpts) (contractAddr *types.Address, err error)
DeployContract let client deploy the wasm contract into BitXHub.
func (*ChainClient) GenerateContractTx ¶
func (cli *ChainClient) GenerateContractTx(vmType pb.TransactionData_VMType, address *types.Address, method string, args ...*pb.Arg) (*pb.BxhTransaction, error)
func (*ChainClient) GenerateIBTPTx ¶
func (cli *ChainClient) GenerateIBTPTx(ibtp *pb.IBTP) (*pb.BxhTransaction, error)
func (*ChainClient) GetAccountBalance ¶
func (cli *ChainClient) GetAccountBalance(address string) (*pb.Response, error)
func (*ChainClient) GetBlock ¶
func (cli *ChainClient) GetBlock(value string, blockType pb.GetBlockRequest_Type, fullTx bool) (*pb.Block, error)
func (*ChainClient) GetBlockHeader ¶
func (cli *ChainClient) GetBlockHeader(ctx context.Context, begin, end uint64, ch chan<- *pb.BlockHeader) error
func (*ChainClient) GetBlocks ¶
func (cli *ChainClient) GetBlocks(start uint64, end uint64, fullTx bool) (*pb.GetBlocksResponse, error)
func (*ChainClient) GetChainID ¶ added in v1.28.0
func (cli *ChainClient) GetChainID() (uint64, error)
func (*ChainClient) GetChainMeta ¶
func (cli *ChainClient) GetChainMeta() (*pb.ChainMeta, error)
func (*ChainClient) GetChainStatus ¶
func (cli *ChainClient) GetChainStatus() (*pb.Response, error)
func (*ChainClient) GetInterchainTxWrappers ¶
func (cli *ChainClient) GetInterchainTxWrappers(ctx context.Context, pid string, begin, end uint64, ch chan<- *pb.InterchainTxWrappers) error
func (*ChainClient) GetMultiSigns ¶
func (cli *ChainClient) GetMultiSigns(content string, typ pb.GetSignsRequest_Type) (*pb.SignResponse, error)
func (*ChainClient) GetNetworkMeta ¶
func (cli *ChainClient) GetNetworkMeta() (*pb.Response, error)
func (*ChainClient) GetPendingNonceByAccount ¶
func (cli *ChainClient) GetPendingNonceByAccount(account string) (uint64, error)
func (*ChainClient) GetReceipt ¶
func (cli *ChainClient) GetReceipt(hash string) (*pb.Receipt, error)
GetReceipts get receipts by tx hashes
func (*ChainClient) GetTransaction ¶
func (cli *ChainClient) GetTransaction(hash string) (*pb.GetTransactionResponse, error)
func (*ChainClient) GetTransactionByBlockHashAndIndex ¶ added in v1.28.0
func (cli *ChainClient) GetTransactionByBlockHashAndIndex(blockHash string, index uint64) (*pb.GetTransactionResponse, error)
func (*ChainClient) GetTransactionByBlockNumberAndIndex ¶ added in v1.28.0
func (cli *ChainClient) GetTransactionByBlockNumberAndIndex(blockNum uint64, index uint64) (*pb.GetTransactionResponse, error)
func (*ChainClient) GetTssSigns ¶ added in v1.28.0
func (cli *ChainClient) GetTssSigns(content string, typ pb.GetSignsRequest_Type, extra []byte) (*pb.SignResponse, error)
func (*ChainClient) GetValidators ¶
func (cli *ChainClient) GetValidators() (*pb.Response, error)
func (*ChainClient) IPFSGet ¶
func (cli *ChainClient) IPFSGet(path string) (*pb.Response, error)
IPFSGet gets from ipfs args@path e.g. /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme
func (*ChainClient) IPFSGetToLocal ¶
IPFSGetToLocal gets from ipfs and saves to local file path args@path e.g. /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme args@localPath e.g. /tmp/readme
func (*ChainClient) IPFSPutFromLocal ¶
func (cli *ChainClient) IPFSPutFromLocal(localfPath string) (*pb.Response, error)
IPFSPutFromLocal puts local file to ipfs args@localPath e.g. /tmp/eg.json returns cid of file stored on ipfs
func (*ChainClient) InvokeBVMContract ¶
func (cli *ChainClient) InvokeBVMContract(address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)
func (*ChainClient) InvokeContract ¶
func (cli *ChainClient) InvokeContract(vmType pb.TransactionData_VMType, address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)
InvokeContract let client invoke the wasm contract with specific method.
func (*ChainClient) InvokeXVMContract ¶
func (cli *ChainClient) InvokeXVMContract(address *types.Address, method string, opts *TransactOpts, args ...*pb.Arg) (*pb.Receipt, error)
func (*ChainClient) SendRawTransaction ¶ added in v1.28.0
func (cli *ChainClient) SendRawTransaction(tx *pb.BxhTransaction) (string, error)
SendRawTransaction send signed transaction
func (*ChainClient) SendRawTransactionWithReceipt ¶ added in v1.28.0
func (cli *ChainClient) SendRawTransactionWithReceipt(tx *pb.BxhTransaction) (*pb.Receipt, error)
SendRawTransactionWithReceipt send signed transaction with receipt
func (*ChainClient) SendTransaction ¶
func (cli *ChainClient) SendTransaction(tx *pb.BxhTransaction, opts *TransactOpts) (string, error)
func (*ChainClient) SendTransactionWithReceipt ¶
func (cli *ChainClient) SendTransactionWithReceipt(tx *pb.BxhTransaction, opts *TransactOpts) (*pb.Receipt, error)
func (*ChainClient) SendTransactions ¶ added in v1.28.0
func (cli *ChainClient) SendTransactions(txs *pb.MultiTransaction) (*pb.MultiTransactionHash, error)
func (*ChainClient) SendView ¶
func (cli *ChainClient) SendView(tx *pb.BxhTransaction) (*pb.Receipt, error)
func (*ChainClient) SetCtxMetadata ¶ added in v1.28.0
func (*ChainClient) SetMasterPier ¶
func (*ChainClient) SetPrivateKey ¶
func (cli *ChainClient) SetPrivateKey(key crypto.PrivateKey)
func (*ChainClient) Stop ¶
func (cli *ChainClient) Stop() error
func (*ChainClient) Subscribe ¶
func (cli *ChainClient) Subscribe(ctx context.Context, typ pb.SubscriptionRequest_Type, extra []byte) (<-chan interface{}, error)
func (*ChainClient) SubscribeAudit ¶ added in v1.28.0
func (cli *ChainClient) SubscribeAudit(ctx context.Context, typ pb.AuditSubscriptionRequest_Type, blockHeight uint64, extra []byte) (<-chan interface{}, error)
type Client ¶
type Client interface {
//Close all connections between BitXHub and the client.
Stop() error
//Reset ecdsa key.
SetPrivateKey(crypto.PrivateKey)
//Send a readonly transaction to BitXHub. 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 BitXHub. 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)
SendTransactions(txs *pb.MultiTransaction) (*pb.MultiTransactionHash, error)
SendRawTransaction(tx *pb.BxhTransaction) (string, error)
//Send transaction to BitXHub and get the receipt.
SendTransactionWithReceipt(tx *pb.BxhTransaction, opts *TransactOpts) (*pb.Receipt, error)
SendRawTransactionWithReceipt(tx *pb.BxhTransaction) (*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 BitXHub by transaction hash.
GetTransaction(hash string) (*pb.GetTransactionResponse, error)
GetTransactionByBlockHashAndIndex(blockHash string, index uint64) (*pb.GetTransactionResponse, error)
GetTransactionByBlockNumberAndIndex(blockNum uint64, index uint64) (*pb.GetTransactionResponse, error)
//Get the current blockchain situation of BitXHub.
GetChainMeta() (*pb.ChainMeta, error)
//Get blocks of the specified block height range.
GetBlocks(start uint64, end uint64, fullTx bool) (*pb.GetBlocksResponse, error)
//Obtain block information from BitXHub.
//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, fullTx bool) (*pb.Block, error)
//Get the status of the blockchain from BitXHub, normal or abnormal.
GetChainStatus() (*pb.Response, error)
//Get the validators from BitXHub.
GetValidators() (*pb.Response, error)
//Get the current network situation of BitXHub.
GetNetworkMeta() (*pb.Response, error)
//Get account balance from BitXHub by address.
GetAccountBalance(address string) (*pb.Response, error)
//Get the missing block header from BitXHub.
GetBlockHeader(ctx context.Context, begin, end uint64, ch chan<- *pb.BlockHeader) error
//Get the missing block header from BitXHub.
GetInterchainTxWrappers(ctx context.Context, pid string, begin, end uint64, ch chan<- *pb.InterchainTxWrappers) error
//Subscribe to event notifications from BitXHub.
Subscribe(context.Context, pb.SubscriptionRequest_Type, []byte) (<-chan interface{}, error)
//SubscribeAudit to event notifications from BitXHub with permission.
SubscribeAudit(context.Context, pb.AuditSubscriptionRequest_Type, uint64, []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 BitXHub'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 BitXHub's signatures specified by id and type.
GetMultiSigns(id string, typ pb.GetSignsRequest_Type) (*pb.SignResponse, error)
// Get BitXHub's tss signatures specified by id and type.
GetTssSigns(id string, typ pb.GetSignsRequest_Type, extra []byte) (*pb.SignResponse, error)
// Get BitXHub TPS during block [begin, end]
GetTPS(begin, end uint64) (uint64, 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)
// IPFSPutFromLocal puts local file to ipfs network
IPFSPutFromLocal(localfPath string) (*pb.Response, error)
// IPFSGet gets from ipfs network
IPFSGet(path string) (*pb.Response, error)
// IPFSGetToLocal gets from ipfs and saves to local file path
IPFSGetToLocal(path string, localfPath string) (*pb.Response, error)
//Check whethe there is a master pier connect to the BitXHub.
CheckMasterPier(address string) (*pb.Response, error)
//Set the master pier connect to the BitXHub.
SetMasterPier(address string, index string, timeout int64) (*pb.Response, error)
//Update the master pier status
HeartBeat(address string, index string) (*pb.Response, error)
// GetChainID get BitXHub Chain ID
GetChainID() (uint64, error)
}
type ConnectionPool ¶
type ConnectionPool struct {
// contains filtered or unexported fields
}
func (*ConnectionPool) Close ¶
func (pool *ConnectionPool) Close() error
type IPFSClient ¶
type IPFSClient struct {
// contains filtered or unexported fields
}
IPFSClient .
func NewIPFSClient ¶
func NewIPFSClient(options ...func(*IPFSClient)) (*IPFSClient, error)
NewIPFSClient .
func (*IPFSClient) AddAPIShell ¶
func (ipfsClient *IPFSClient) AddAPIShell(addr string)
AddAPIShell add ipfs api address
func (*IPFSClient) Get ¶
func (ipfsClient *IPFSClient) Get(path string) ([]byte, error)
Get gets from ipfs args@path e.g. /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme returns content of file
func (*IPFSClient) GetToLocal ¶
func (ipfsClient *IPFSClient) GetToLocal(path string, localfPath string) error
GetToLocal gets from ipfs and saves to local file path args@path e.g. /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme args@localPath e.g. /tmp/readme
func (*IPFSClient) PutFromLocal ¶
func (ipfsClient *IPFSClient) PutFromLocal(localfPath string) ([]byte, error)
PutFromLocal puts local file to ipfs args@localPath e.g. /tmp/eg.json returns cid of file stored on ipfs
func (*IPFSClient) RmAPIAddr ¶
func (ipfsClient *IPFSClient) RmAPIAddr(addr string)
RmAPIAddr rm ipfs api address
type IPFSResponse ¶
type IPFSResponse struct {
Name string `json:"Name"`
Hash string `json:"Hash"`
Size string `json:"Size"`
}
IPFSResponse describes ipfs add response
type Interchain ¶
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 Option ¶
type Option func(*config)
func WithIPFSInfo ¶
func WithLogger ¶
func WithNodesInfo ¶
func WithPoolSize ¶ added in v1.28.0
func WithPrivateKey ¶
func WithPrivateKey(key crypto.PrivateKey) Option
func WithTimeoutLimit ¶
type SubscriptionType ¶
type SubscriptionType int
const (
SubscribeNewBlock SubscriptionType = iota
)
type TransactOpts ¶
type TransactOpts struct {
From string
Nonce uint64
PrivKey crypto.PrivateKey
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock_client is a generated GoMock package.
|
Package mock_client is a generated GoMock package. |