chain_client

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitChainClient

func InitChainClient() error

InitChainClient 初始化链客户端

@return error

func InitChainClientMock

func InitChainClientMock() error

InitChainClientMock 初始化链客户端

@return error

Types

type BCOSBlock

type BCOSBlock struct {
	Transactions     []string `json:"transactions"`
	Number           string   `json:"number"`
	Hash             string   `json:"hash"`
	ParentHash       string   `json:"parentHash"`
	TransactionsRoot string   `json:"transactionsRoot"`
	ReceiptsRoot     string   `json:"receiptsRoot"`
	DbHash           string   `json:"dbHash"`
	StateRoot        string   `json:"stateRoot"`
	Timestamp        string   `json:"timestamp"`
}

BCOSBlock bcos的区块结构

func (*BCOSBlock) TransactionHashs

func (b *BCOSBlock) TransactionHashs() []string

TransactionHashs 获取交易哈希

@receiver b
@return []string

type BCOSConfigTemplate

type BCOSConfigTemplate struct {
	CaText       string
	CaFilePath   string
	KeyText      []byte
	KeyFilePath  string
	CertFilePath string
	CertText     []byte
	AccountText  []byte
	GroupID      int
	Address      string
	Http         bool
	ChainID      int64
	SMCrypto     bool
}

BCOSConfigTemplate bcos配置结构体

func NewBCOSConfigTemplate

func NewBCOSConfigTemplate(chainID int64, groupIDStr, address string, isSMCrypto bool) (*BCOSConfigTemplate, error)

NewBCOSConfigTemplate 新建bcos的配置结构

@param chainID
@param groupIDStr
@param address
@param isSMCrypto
@return *BCOSConfigTemplate
@return error

func (*BCOSConfigTemplate) SetAccount

func (t *BCOSConfigTemplate) SetAccount(accountText []byte) error

SetAccount 设置account

@receiver t
@param accountText
@return error

func (*BCOSConfigTemplate) SetCa

func (t *BCOSConfigTemplate) SetCa(caText string) error

SetCa 设置ca

@receiver t
@param caText
@return error

func (*BCOSConfigTemplate) SetCert

func (t *BCOSConfigTemplate) SetCert(certText []byte) error

SetCert 设置cert

@receiver t
@param certText
@return error

func (*BCOSConfigTemplate) SetKey

func (t *BCOSConfigTemplate) SetKey(keyText []byte) error

SetKey 设置key

@receiver t
@param keyText
@return error

func (*BCOSConfigTemplate) ToConfig

func (t *BCOSConfigTemplate) ToConfig() (*conf.Config, error)

ToConfig 生成bcos config

@receiver t
@return *conf.Config
@return error

type BCOSEvent

type BCOSEvent struct {
	Topic        string
	ContractName string
	Data         []string
}

BCOSEvent bcos的event

type ChainClient

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

ChainClient 链客户端结构体

func (*ChainClient) CheckChain

func (c *ChainClient) CheckChain() bool

CheckChain 检查链的连通性

@receiver c
@return bool

func (*ChainClient) GetTxProve

func (c *ChainClient) GetTxProve(tx *bcostypes.TransactionDetail, chainRid string) string

GetTxProve 获取交易证明

@receiver c
@param tx 交易
@param chainRid 链资源id
@return string 交易证明

func (*ChainClient) InvokeContract

func (c *ChainClient) InvokeContract(chainRid, contractName, method, abiStr string, args string,
	needTx bool, paramType []tcipcommon.EventDataType) ([]string, *bcostypes.TransactionDetail, error)

InvokeContract 调用合约

@receiver c
@param chainRid 链资源id
@param contractName 合约名称
@param method 调用方法
@param abiStr abi
@param args 参数
@param needTx 是否需要交易
@param paramType 参数类型
@return []string 返回参数
@return *bcostypes.TransactionDetail 交易
@return error 错误信息

func (*ChainClient) TxProve

func (c *ChainClient) TxProve(txProve string) bool

TxProve 交易认证

@receiver c
@param txProve
@return bool

type ChainClientItfc

type ChainClientItfc interface {
	// InvokeContract 调用合约
	InvokeContract(chainRid, contractName, method, abiStr string, args string,
		needTx bool, paramType []tcipcommon.EventDataType) ([]string, *bcostypes.TransactionDetail, error)
	// GetTxProve 获取交易凭证
	GetTxProve(tx *bcostypes.TransactionDetail, chainRid string) string
	// TxProve 交易验证
	TxProve(txProve string) bool
	// CheckChain 验证了链的连通性
	CheckChain() bool
}

ChainClientItfc 链客户端接口

var ChainClientV1 ChainClientItfc

ChainClientV1 连交互模块对象

type ChainClientMock

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

ChainClientMock 链客户端结构体Mock

func (*ChainClientMock) CheckChain

func (c *ChainClientMock) CheckChain() bool

CheckChain 检查链

@receiver c
@return bool

func (*ChainClientMock) GetTxProve

func (c *ChainClientMock) GetTxProve(tx *bcostypes.TransactionDetail, chainId string) string

GetTxProve 获取交易证明

@receiver c
@param tx
@param chainId
@return string

func (*ChainClientMock) InvokeContract

func (c *ChainClientMock) InvokeContract(hainId, contractName, method, abiStr string, args string,
	needTx bool, paramType []tcipcommon.EventDataType) ([]string, *bcostypes.TransactionDetail, error)

InvokeContract 调用合约

@receiver c
@param hainId
@param contractName
@param method
@param abiStr
@param args
@param needTx
@param paramType
@return []string
@return *bcostypes.TransactionDetail
@return error

func (*ChainClientMock) TxProve

func (c *ChainClientMock) TxProve(txProve string) bool

TxProve 交易认证

@receiver c
@param txProve
@return bool

Jump to

Keyboard shortcuts

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