fix(*): fix some bugs when invoking eth tx
This commit is contained in:
parent
49cab14fa4
commit
6042c690c5
|
@ -15,9 +15,7 @@ import (
|
||||||
const (
|
const (
|
||||||
Web3Namespace = "web3"
|
Web3Namespace = "web3"
|
||||||
EthNamespace = "eth"
|
EthNamespace = "eth"
|
||||||
PersonalNamespace = "personal"
|
|
||||||
NetNamespace = "net"
|
NetNamespace = "net"
|
||||||
flagRPCAPI = "rpc-api"
|
|
||||||
|
|
||||||
apiVersion = "1.0"
|
apiVersion = "1.0"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,13 +2,19 @@ package eth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
vm1 "github.com/meshplus/bitxhub-kit/evm"
|
||||||
"github.com/meshplus/bitxhub-kit/types"
|
"github.com/meshplus/bitxhub-kit/types"
|
||||||
"github.com/meshplus/bitxhub-model/pb"
|
"github.com/meshplus/bitxhub-model/pb"
|
||||||
rpctypes "github.com/meshplus/bitxhub/api/jsonrpc/types"
|
rpctypes "github.com/meshplus/bitxhub/api/jsonrpc/types"
|
||||||
|
@ -23,6 +29,7 @@ import (
|
||||||
type PublicEthereumAPI struct {
|
type PublicEthereumAPI struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
|
config *repo.Config
|
||||||
chainID *big.Int
|
chainID *big.Int
|
||||||
logger logrus.FieldLogger
|
logger logrus.FieldLogger
|
||||||
api api.CoreAPI
|
api api.CoreAPI
|
||||||
|
@ -35,6 +42,7 @@ func NewAPI(config *repo.Config, api api.CoreAPI, logger logrus.FieldLogger) (*P
|
||||||
return &PublicEthereumAPI{
|
return &PublicEthereumAPI{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
|
config: config,
|
||||||
chainID: big.NewInt(int64(config.Genesis.ChainID)),
|
chainID: big.NewInt(int64(config.Genesis.ChainID)),
|
||||||
logger: logger,
|
logger: logger,
|
||||||
api: api,
|
api: api,
|
||||||
|
@ -58,8 +66,6 @@ func (api *PublicEthereumAPI) ChainId() (hexutil.Uint, error) { // nolint
|
||||||
func (api *PublicEthereumAPI) Syncing() (interface{}, error) {
|
func (api *PublicEthereumAPI) Syncing() (interface{}, error) {
|
||||||
api.logger.Debug("eth_syncing")
|
api.logger.Debug("eth_syncing")
|
||||||
|
|
||||||
api.api.Chain().Status()
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -80,7 +86,7 @@ func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 {
|
||||||
// GasPrice returns the current gas price based on Ethermint's gas price oracle.
|
// GasPrice returns the current gas price based on Ethermint's gas price oracle.
|
||||||
func (api *PublicEthereumAPI) GasPrice() *hexutil.Big {
|
func (api *PublicEthereumAPI) GasPrice() *hexutil.Big {
|
||||||
api.logger.Debug("eth_gasPrice")
|
api.logger.Debug("eth_gasPrice")
|
||||||
out := big.NewInt(0)
|
out := big.NewInt(rpctypes.GasPrice)
|
||||||
return (*hexutil.Big)(out)
|
return (*hexutil.Big)(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,12 +236,14 @@ func (api *PublicEthereumAPI) checkTransaction(tx *pb.EthTransaction) error {
|
||||||
return fmt.Errorf("from can't be empty")
|
return fmt.Errorf("from can't be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tx.GetTo() == nil {
|
||||||
|
if len(tx.GetPayload()) == 0 {
|
||||||
|
return fmt.Errorf("can't deploy empty contract")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if tx.GetFrom().String() == tx.GetTo().String() {
|
if tx.GetFrom().String() == tx.GetTo().String() {
|
||||||
return fmt.Errorf("from can`t be the same as to")
|
return fmt.Errorf("from can`t be the same as to")
|
||||||
}
|
}
|
||||||
|
|
||||||
if tx.GetTo().String() == emptyAddress.String() && len(tx.GetPayload()) == 0 {
|
|
||||||
return fmt.Errorf("can't deploy empty contract")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tx.GetTimeStamp() < time.Now().UnixNano()-10*time.Minute.Nanoseconds() ||
|
if tx.GetTimeStamp() < time.Now().UnixNano()-10*time.Minute.Nanoseconds() ||
|
||||||
|
@ -262,22 +270,87 @@ func (api *PublicEthereumAPI) sendTransaction(tx *pb.EthTransaction) (common.Has
|
||||||
return tx.GetHash().RawHash, nil
|
return tx.GetHash().RawHash, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call performs a raw contract call.
|
func newRevertError(data []byte) *revertError {
|
||||||
func (api *PublicEthereumAPI) Call(args rpctypes.CallArgs, blockNr uint64, _ *map[common.Address]rpctypes.Account) (hexutil.Bytes, error) {
|
reason, errUnpack := abi.UnpackRevert(data)
|
||||||
api.logger.Debugf("eth_call, args: %s, block number: %d", args, blockNr)
|
err := errors.New("execution reverted")
|
||||||
// TODO
|
if errUnpack == nil {
|
||||||
|
err = fmt.Errorf("execution reverted: %v", reason)
|
||||||
|
}
|
||||||
|
return &revertError{
|
||||||
|
error: err,
|
||||||
|
reason: hexutil.Encode(data),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil, nil
|
// revertError is an API error that encompassas an EVM revertal with JSON error
|
||||||
|
// code and a binary data blob.
|
||||||
|
type revertError struct {
|
||||||
|
error
|
||||||
|
reason string // revert reason hex encoded
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCode returns the JSON error code for a revertal.
|
||||||
|
// See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal
|
||||||
|
func (e *revertError) ErrorCode() int {
|
||||||
|
return 3
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorData returns the hex encoded revert reason.
|
||||||
|
func (e *revertError) ErrorData() interface{} {
|
||||||
|
return e.reason
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call performs a raw contract call.
|
||||||
|
func (api *PublicEthereumAPI) Call(args pb.CallArgs, blockNr rpc.BlockNumber, _ *map[common.Address]rpctypes.Account) (hexutil.Bytes, error) {
|
||||||
|
api.logger.Debugf("eth_call, args: %s, block number: %d", args, blockNr.Int64())
|
||||||
|
|
||||||
|
// Determine the highest gas limit can be used during call.
|
||||||
|
if args.Gas == nil || uint64(*args.Gas) < params.TxGas {
|
||||||
|
// Retrieve the block to act as the gas ceiling
|
||||||
|
args.Gas = (*hexutil.Uint64)(&api.config.GasLimit)
|
||||||
|
}
|
||||||
|
|
||||||
|
tx := &pb.EthTransaction{}
|
||||||
|
tx.FromCallArgs(args)
|
||||||
|
|
||||||
|
receipt, err := api.api.Broker().HandleView(tx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
api.logger.Warnf("receipt: %v", receipt)
|
||||||
|
|
||||||
|
if receipt.Status == pb.Receipt_FAILED {
|
||||||
|
errMsg := string(receipt.Ret)
|
||||||
|
if strings.HasPrefix(errMsg, vm1.ErrExecutionReverted.Error()) {
|
||||||
|
return nil, newRevertError(receipt.Ret[len(vm1.ErrExecutionReverted.Error()):])
|
||||||
|
}
|
||||||
|
return nil, errors.New(errMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
return receipt.Ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EstimateGas returns an estimate of gas usage for the given smart contract call.
|
// EstimateGas returns an estimate of gas usage for the given smart contract call.
|
||||||
// It adds 1,000 gas to the returned value instead of using the gas adjustment
|
// It adds 2,000 gas to the returned value instead of using the gas adjustment
|
||||||
// param from the SDK.
|
// param from the SDK.
|
||||||
func (api *PublicEthereumAPI) EstimateGas(args rpctypes.CallArgs) (hexutil.Uint64, error) {
|
func (api *PublicEthereumAPI) EstimateGas(args pb.CallArgs) (hexutil.Uint64, error) {
|
||||||
api.logger.Debugf("eth_estimateGas, args: %s", args)
|
api.logger.Debugf("eth_estimateGas, args: %s", args)
|
||||||
// TODO
|
|
||||||
|
|
||||||
return hexutil.Uint64(1000), nil
|
// Determine the highest gas limit can be used during the estimation.
|
||||||
|
if args.Gas == nil || uint64(*args.Gas) < params.TxGas {
|
||||||
|
// Retrieve the block to act as the gas ceiling
|
||||||
|
args.Gas = (*hexutil.Uint64)(&api.config.GasLimit)
|
||||||
|
}
|
||||||
|
tx := &pb.EthTransaction{}
|
||||||
|
tx.FromCallArgs(args)
|
||||||
|
|
||||||
|
result, err := api.api.Broker().HandleView(tx)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return hexutil.Uint64(result.GasUsed + 2000), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockByHash returns the block identified by hash.
|
// GetBlockByHash returns the block identified by hash.
|
||||||
|
@ -411,26 +484,40 @@ func (api *PublicEthereumAPI) GetTransactionReceipt(hash common.Hash) (map[strin
|
||||||
|
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"type": hexutil.Uint(ethTx.GetType()),
|
"type": hexutil.Uint(ethTx.GetType()),
|
||||||
"status": receipt.Status,
|
|
||||||
"cumulativeGasUsed": hexutil.Uint64(cumulativeGasUsed),
|
"cumulativeGasUsed": hexutil.Uint64(cumulativeGasUsed),
|
||||||
"logsBloom": receipt.Bloom,
|
"logsBloom": *receipt.Bloom,
|
||||||
"logs": receipt.EvmLogs,
|
"logs": receipt.EvmLogs,
|
||||||
|
|
||||||
"transactionHash": hash,
|
"transactionHash": hash,
|
||||||
"gasUsed": hexutil.Uint64(receipt.GasUsed),
|
"gasUsed": hexutil.Uint64(receipt.GasUsed),
|
||||||
|
|
||||||
"blockHash": meta.BlockHash,
|
"blockHash": common.BytesToHash(meta.BlockHash),
|
||||||
"blockNumber": hexutil.Uint64(meta.BlockHeight),
|
"blockNumber": hexutil.Uint64(meta.BlockHeight),
|
||||||
"transactionIndex": hexutil.Uint64(meta.Index),
|
"transactionIndex": hexutil.Uint64(meta.Index),
|
||||||
|
|
||||||
"from": tx.GetFrom().Bytes(),
|
"from": common.BytesToAddress(tx.GetFrom().Bytes()),
|
||||||
"to": tx.GetTo().Bytes(),
|
}
|
||||||
|
|
||||||
|
if len(receipt.EvmLogs) == 0 {
|
||||||
|
fields["logs"] = make([]*pb.EvmLog, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if receipt.Status == pb.Receipt_SUCCESS {
|
||||||
|
fields["status"] = hexutil.Uint(1)
|
||||||
|
} else {
|
||||||
|
fields["status"] = hexutil.Uint(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if receipt.ContractAddress != nil {
|
if receipt.ContractAddress != nil {
|
||||||
fields["contractAddress"] = receipt.ContractAddress.Bytes()
|
fields["contractAddress"] = common.BytesToAddress(receipt.ContractAddress.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tx.GetTo() != nil {
|
||||||
|
fields["to"] = common.BytesToAddress(tx.GetTo().Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
api.logger.Debugf("eth_getTransactionReceipt: %v", fields)
|
||||||
|
|
||||||
return fields, nil
|
return fields, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +613,7 @@ func (api *PublicEthereumAPI) formatBlock(block *pb.Block, fullTx bool) (map[str
|
||||||
"totalDifficulty": 0,
|
"totalDifficulty": 0,
|
||||||
"extraData": hexutil.Uint64(0),
|
"extraData": hexutil.Uint64(0),
|
||||||
"size": block.Size(),
|
"size": block.Size(),
|
||||||
"gasLimit": rpctypes.MaxGas, // Static gas limit
|
"gasLimit": api.config.GasLimit, // Static gas limit
|
||||||
"gasUsed": cumulativeGas,
|
"gasUsed": cumulativeGas,
|
||||||
"timestamp": block.BlockHeader.Timestamp,
|
"timestamp": block.BlockHeader.Timestamp,
|
||||||
"transactions": transactions,
|
"transactions": transactions,
|
||||||
|
|
|
@ -334,6 +334,7 @@ func (api *PublicFilterAPI) NewFilter(crit FilterCriteria) (rpc.ID, error) {
|
||||||
//
|
//
|
||||||
// https://eth.wiki/json-rpc/API#eth_getlogs
|
// https://eth.wiki/json-rpc/API#eth_getlogs
|
||||||
func (api *PublicFilterAPI) GetLogs(ctx context.Context, ethCrit FilterCriteria) ([]*pb.EvmLog, error) {
|
func (api *PublicFilterAPI) GetLogs(ctx context.Context, ethCrit FilterCriteria) ([]*pb.EvmLog, error) {
|
||||||
|
api.logger.Debugf("eth_getLogs: ethCrit: %s", ethCrit)
|
||||||
var filter *Filter
|
var filter *Filter
|
||||||
crit := ethCrit.toBxhFilterQuery()
|
crit := ethCrit.toBxhFilterQuery()
|
||||||
if crit.BlockHash != nil {
|
if crit.BlockHash != nil {
|
||||||
|
@ -588,11 +589,14 @@ func decodeTopic(s string) (common.Hash, error) {
|
||||||
|
|
||||||
func (fc *FilterCriteria) toBxhFilterQuery() FilterQuery {
|
func (fc *FilterCriteria) toBxhFilterQuery() FilterQuery {
|
||||||
fq := FilterQuery{
|
fq := FilterQuery{
|
||||||
BlockHash: types2.NewHash(fc.BlockHash.Bytes()),
|
|
||||||
FromBlock: fc.FromBlock,
|
FromBlock: fc.FromBlock,
|
||||||
ToBlock: fc.ToBlock,
|
ToBlock: fc.ToBlock,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fc.BlockHash != nil {
|
||||||
|
fq.BlockHash = types2.NewHash(fc.BlockHash.Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
for _, addr := range fc.Addresses {
|
for _, addr := range fc.Addresses {
|
||||||
fq.Addresses = append(fq.Addresses, types2.NewAddress(addr.Bytes()))
|
fq.Addresses = append(fq.Addresses, types2.NewAddress(addr.Bytes()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,30 +18,12 @@ const (
|
||||||
// ProtocolVersion is the latest supported version of the eth protocol.
|
// ProtocolVersion is the latest supported version of the eth protocol.
|
||||||
ProtocolVersion = eth65
|
ProtocolVersion = eth65
|
||||||
|
|
||||||
MaxGas = 1000000000
|
GasPrice = 5000000
|
||||||
|
|
||||||
// consider a filter inactive if it has not been polled for within deadline
|
// consider a filter inactive if it has not been polled for within deadline
|
||||||
Deadline = 5 * time.Minute
|
Deadline = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
// AccountResult struct for account proof
|
|
||||||
type AccountResult struct {
|
|
||||||
Address common.Address `json:"address"`
|
|
||||||
AccountProof []string `json:"accountProof"`
|
|
||||||
Balance *hexutil.Big `json:"balance"`
|
|
||||||
CodeHash common.Hash `json:"codeHash"`
|
|
||||||
Nonce hexutil.Uint64 `json:"nonce"`
|
|
||||||
StorageHash common.Hash `json:"storageHash"`
|
|
||||||
StorageProof []StorageResult `json:"storageProof"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// StorageResult defines the format for storage proof return
|
|
||||||
type StorageResult struct {
|
|
||||||
Key string `json:"key"`
|
|
||||||
Value *hexutil.Big `json:"value"`
|
|
||||||
Proof []string `json:"proof"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
|
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
|
||||||
type RPCTransaction struct {
|
type RPCTransaction struct {
|
||||||
BlockHash *common.Hash `json:"blockHash"`
|
BlockHash *common.Hash `json:"blockHash"`
|
||||||
|
@ -63,32 +45,6 @@ type RPCTransaction struct {
|
||||||
S *hexutil.Big `json:"s"`
|
S *hexutil.Big `json:"s"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendTxArgs represents the arguments to submit a new transaction into the transaction pool.
|
|
||||||
// Duplicate struct definition since geth struct is in internal package
|
|
||||||
// Ref: https://github.com/ethereum/go-ethereum/blob/release/1.9/internal/ethapi/api.go#L1346
|
|
||||||
type SendTxArgs struct {
|
|
||||||
From common.Address `json:"from"`
|
|
||||||
To *common.Address `json:"to"`
|
|
||||||
Gas *hexutil.Uint64 `json:"gas"`
|
|
||||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
|
||||||
Value *hexutil.Big `json:"value"`
|
|
||||||
Nonce *hexutil.Uint64 `json:"nonce"`
|
|
||||||
// We accept "data" and "input" for backwards-compatibility reasons. "input" is the
|
|
||||||
// newer name and should be preferred by clients.
|
|
||||||
Data *hexutil.Bytes `json:"data"`
|
|
||||||
Input *hexutil.Bytes `json:"input"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CallArgs represents the arguments for a call.
|
|
||||||
type CallArgs struct {
|
|
||||||
From *common.Address `json:"from"`
|
|
||||||
To *common.Address `json:"to"`
|
|
||||||
Gas *hexutil.Uint64 `json:"gas"`
|
|
||||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
|
||||||
Value *hexutil.Big `json:"value"`
|
|
||||||
Data *hexutil.Bytes `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Account indicates the overriding fields of account during the execution of
|
// Account indicates the overriding fields of account during the execution of
|
||||||
// a message call.
|
// a message call.
|
||||||
// NOTE: state and stateDiff can't be specified at the same time. If state is
|
// NOTE: state and stateDiff can't be specified at the same time. If state is
|
||||||
|
|
|
@ -42,7 +42,7 @@ solo = false
|
||||||
report_caller = false
|
report_caller = false
|
||||||
[log.module]
|
[log.module]
|
||||||
p2p = "info"
|
p2p = "info"
|
||||||
consensus = "debug"
|
consensus = "info"
|
||||||
executor = "info"
|
executor = "info"
|
||||||
router = "info"
|
router = "info"
|
||||||
api = "info"
|
api = "info"
|
||||||
|
@ -63,6 +63,7 @@ solo = false
|
||||||
|
|
||||||
[genesis]
|
[genesis]
|
||||||
chainid = 1
|
chainid = 1
|
||||||
|
gas_limit = 0x2fefd8
|
||||||
dider = "0xc7F999b83Af6DF9e67d0a37Ee7e900bF38b3D013"
|
dider = "0xc7F999b83Af6DF9e67d0a37Ee7e900bF38b3D013"
|
||||||
[[genesis.admins]]
|
[[genesis.admins]]
|
||||||
address = "0xc7F999b83Af6DF9e67d0a37Ee7e900bF38b3D013"
|
address = "0xc7F999b83Af6DF9e67d0a37Ee7e900bF38b3D013"
|
||||||
|
@ -76,9 +77,6 @@ solo = false
|
||||||
[[genesis.admins]]
|
[[genesis.admins]]
|
||||||
address = "0xc0Ff2e0b3189132D815b8eb325bE17285AC898f8"
|
address = "0xc0Ff2e0b3189132D815b8eb325bE17285AC898f8"
|
||||||
weight = 1
|
weight = 1
|
||||||
[[genesis.admins]]
|
|
||||||
address = "0x2962b85e2bEe2e1eA9C4CD69f2758cF7bbc3297E"
|
|
||||||
weight = 1
|
|
||||||
[genesis.strategy]
|
[genesis.strategy]
|
||||||
AppchainMgr = "SimpleMajority"
|
AppchainMgr = "SimpleMajority"
|
||||||
RuleMgr = "SimpleMajority"
|
RuleMgr = "SimpleMajority"
|
||||||
|
|
6
go.mod
6
go.mod
|
@ -26,9 +26,9 @@ require (
|
||||||
github.com/juju/ratelimit v1.0.1
|
github.com/juju/ratelimit v1.0.1
|
||||||
github.com/libp2p/go-libp2p-core v0.5.6
|
github.com/libp2p/go-libp2p-core v0.5.6
|
||||||
github.com/magiconair/properties v1.8.4
|
github.com/magiconair/properties v1.8.4
|
||||||
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210423140028-7c7e2fd80a46
|
github.com/meshplus/bitxhub-core v1.2.0
|
||||||
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425020456-3e87ac09c707
|
github.com/meshplus/bitxhub-kit v1.2.0
|
||||||
github.com/meshplus/bitxhub-model v1.1.2-0.20210425021723-411f67ad49be
|
github.com/meshplus/bitxhub-model v1.2.0
|
||||||
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a
|
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a
|
||||||
github.com/meshplus/did-registry v0.0.0-20210413035015-509c6c3a0bae
|
github.com/meshplus/did-registry v0.0.0-20210413035015-509c6c3a0bae
|
||||||
github.com/meshplus/go-libp2p-cert v0.0.0-20210125063330-7c25fd5b7a49
|
github.com/meshplus/go-libp2p-cert v0.0.0-20210125063330-7c25fd5b7a49
|
||||||
|
|
14
go.sum
14
go.sum
|
@ -819,6 +819,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
|
||||||
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210318102029-494ee3060b0c/go.mod h1:G19Wrz1u66UmwaES/iLM19jmlv3APAZ5qfYOlNnIIZw=
|
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210318102029-494ee3060b0c/go.mod h1:G19Wrz1u66UmwaES/iLM19jmlv3APAZ5qfYOlNnIIZw=
|
||||||
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210423140028-7c7e2fd80a46 h1:ZX6J+BcLFuxzCmC8yf7DC5ah9MVJ+birGL5xd5SMdgY=
|
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210423140028-7c7e2fd80a46 h1:ZX6J+BcLFuxzCmC8yf7DC5ah9MVJ+birGL5xd5SMdgY=
|
||||||
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210423140028-7c7e2fd80a46/go.mod h1:ijf/8xybq2lGz86VKSTghDQGrKhx7GHavDQpCJWcsDs=
|
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210423140028-7c7e2fd80a46/go.mod h1:ijf/8xybq2lGz86VKSTghDQGrKhx7GHavDQpCJWcsDs=
|
||||||
|
github.com/meshplus/bitxhub-core v1.2.0 h1:tSOIN3Fg89UJwu0XhlCIP+oCLwhg/TP4JQehTFp4Las=
|
||||||
|
github.com/meshplus/bitxhub-core v1.2.0/go.mod h1:2ksSKEiox4B06gSPT6h4+GcdWnh92/FDPUUImX/dI04=
|
||||||
github.com/meshplus/bitxhub-kit v1.1.1 h1:vkPO88oA3+Kpc0N8lIgfj/U52KBuI+633hPbMYt1xm8=
|
github.com/meshplus/bitxhub-kit v1.1.1 h1:vkPO88oA3+Kpc0N8lIgfj/U52KBuI+633hPbMYt1xm8=
|
||||||
github.com/meshplus/bitxhub-kit v1.1.1/go.mod h1:r4l4iqn0RPJreb/OmoYKfjCjQJrXpZX++6Qc31VG/1k=
|
github.com/meshplus/bitxhub-kit v1.1.1/go.mod h1:r4l4iqn0RPJreb/OmoYKfjCjQJrXpZX++6Qc31VG/1k=
|
||||||
github.com/meshplus/bitxhub-kit v1.1.2-0.20201021105954-468d0a9d7957/go.mod h1:r4l4iqn0RPJreb/OmoYKfjCjQJrXpZX++6Qc31VG/1k=
|
github.com/meshplus/bitxhub-kit v1.1.2-0.20201021105954-468d0a9d7957/go.mod h1:r4l4iqn0RPJreb/OmoYKfjCjQJrXpZX++6Qc31VG/1k=
|
||||||
|
@ -832,12 +834,20 @@ github.com/meshplus/bitxhub-kit v1.1.2-0.20210423082909-97edee705d22/go.mod h1:l
|
||||||
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425013549-7a642723d279/go.mod h1:ltiaMnupw2mzE1gENiV6LF6C8UYu0bF7w1NrG3QDvFQ=
|
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425013549-7a642723d279/go.mod h1:ltiaMnupw2mzE1gENiV6LF6C8UYu0bF7w1NrG3QDvFQ=
|
||||||
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425020456-3e87ac09c707 h1:xkeoue4sog72PnVVmPrcGgGiQDjaougHallr4RjDTEk=
|
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425020456-3e87ac09c707 h1:xkeoue4sog72PnVVmPrcGgGiQDjaougHallr4RjDTEk=
|
||||||
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425020456-3e87ac09c707/go.mod h1:Zs4eZnVtI0uX6aIMN7DnqXCJTthQ0WNrjF1/h6KkGRc=
|
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425020456-3e87ac09c707/go.mod h1:Zs4eZnVtI0uX6aIMN7DnqXCJTthQ0WNrjF1/h6KkGRc=
|
||||||
|
github.com/meshplus/bitxhub-kit v1.2.0 h1:lG6vyRD14bPoQFNU8ygmgzMXAy4xDlEueJyM6vShndo=
|
||||||
|
github.com/meshplus/bitxhub-kit v1.2.0/go.mod h1:vGTKDkCAU7/IlirT6tlq6BMnCpY9UbfrrwGDy6foQIg=
|
||||||
github.com/meshplus/bitxhub-model v1.1.1/go.mod h1:lUl9vPZXM9tP+B0ABRW/2eOW/6KCmjFTdoiTj5Vut/A=
|
github.com/meshplus/bitxhub-model v1.1.1/go.mod h1:lUl9vPZXM9tP+B0ABRW/2eOW/6KCmjFTdoiTj5Vut/A=
|
||||||
github.com/meshplus/bitxhub-model v1.1.2-0.20201021152621-0b3c17c54b23/go.mod h1:4qWBZx5wv7WZzUqiuBsbkQqQ2Ju8aOFpsoNpBBNy8Us=
|
github.com/meshplus/bitxhub-model v1.1.2-0.20201021152621-0b3c17c54b23/go.mod h1:4qWBZx5wv7WZzUqiuBsbkQqQ2Ju8aOFpsoNpBBNy8Us=
|
||||||
github.com/meshplus/bitxhub-model v1.1.2-0.20210409090411-de23bd385c5f/go.mod h1:x3H+TL24wcByzHegenLfs+5PQkQGNsk8eCm31QJMa+Q=
|
github.com/meshplus/bitxhub-model v1.1.2-0.20210409090411-de23bd385c5f/go.mod h1:x3H+TL24wcByzHegenLfs+5PQkQGNsk8eCm31QJMa+Q=
|
||||||
github.com/meshplus/bitxhub-model v1.1.2-0.20210423135747-9546174eabb0/go.mod h1:rW2Sd4ZFdBoch0h4i1lSuyHNFIOg/3t8loQ+LV5rvNc=
|
github.com/meshplus/bitxhub-model v1.1.2-0.20210423135747-9546174eabb0/go.mod h1:rW2Sd4ZFdBoch0h4i1lSuyHNFIOg/3t8loQ+LV5rvNc=
|
||||||
github.com/meshplus/bitxhub-model v1.1.2-0.20210425021723-411f67ad49be h1:SGCgDzpMEu/cpjlewBrotZmGujB9tPOEL614CrJxlLk=
|
github.com/meshplus/bitxhub-model v1.1.2-0.20210425021723-411f67ad49be h1:SGCgDzpMEu/cpjlewBrotZmGujB9tPOEL614CrJxlLk=
|
||||||
github.com/meshplus/bitxhub-model v1.1.2-0.20210425021723-411f67ad49be/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU=
|
github.com/meshplus/bitxhub-model v1.1.2-0.20210425021723-411f67ad49be/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU=
|
||||||
|
github.com/meshplus/bitxhub-model v1.1.2-0.20210426012554-bb170814ec11 h1:rdevlFfnfLNvoSfnJx/pdJkfUHAQGoJfyqxDxWOyhJw=
|
||||||
|
github.com/meshplus/bitxhub-model v1.1.2-0.20210426012554-bb170814ec11/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU=
|
||||||
|
github.com/meshplus/bitxhub-model v1.1.2-0.20210426065438-954f4d830abc h1:Xdr93A4XsYXzI0Sxcmrvsl9aDt0QGnaXfs8i1vbGmhk=
|
||||||
|
github.com/meshplus/bitxhub-model v1.1.2-0.20210426065438-954f4d830abc/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU=
|
||||||
|
github.com/meshplus/bitxhub-model v1.2.0 h1:Ac8ol1HZNLIegyZkU/DZGYkPeeAWp3ZgYsbJGNF2GV0=
|
||||||
|
github.com/meshplus/bitxhub-model v1.2.0/go.mod h1:QCYJy8fUQex0cvxqAZtGHJn31F5mwuXnE3Lyri15zUc=
|
||||||
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a h1:c4ESPDa60Jd4zfzZIGGTyzhfaVM3vKN+xV2G9BwIDGQ=
|
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a h1:c4ESPDa60Jd4zfzZIGGTyzhfaVM3vKN+xV2G9BwIDGQ=
|
||||||
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a/go.mod h1:vAldSRfDe2Qo7exsSTbchVmZWXPY7fhWQrRw18QJHho=
|
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a/go.mod h1:vAldSRfDe2Qo7exsSTbchVmZWXPY7fhWQrRw18QJHho=
|
||||||
github.com/meshplus/did-registry v0.0.0-20210413035015-509c6c3a0bae h1:E4iaFwHAg1ScyiU9Bz3RY0wjfXNZzPH3O43DBTl9iWg=
|
github.com/meshplus/did-registry v0.0.0-20210413035015-509c6c3a0bae h1:E4iaFwHAg1ScyiU9Bz3RY0wjfXNZzPH3O43DBTl9iWg=
|
||||||
|
@ -995,6 +1005,7 @@ github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNC
|
||||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
||||||
github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
|
github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
|
||||||
|
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 h1:oYW+YCJ1pachXTQmzR3rNLYGGz4g/UgFcjb28p/viDM=
|
||||||
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
|
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
|
||||||
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
|
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
|
||||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||||
|
@ -1052,6 +1063,7 @@ github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqn
|
||||||
github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc=
|
github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc=
|
||||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo=
|
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo=
|
||||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM=
|
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM=
|
||||||
|
github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE=
|
||||||
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=
|
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=
|
||||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||||
|
@ -1125,6 +1137,7 @@ github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q
|
||||||
github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
|
github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
|
||||||
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
||||||
github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/R4aaNBc=
|
github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/R4aaNBc=
|
||||||
|
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg=
|
||||||
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
|
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
|
||||||
github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw=
|
github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw=
|
||||||
github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU=
|
github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU=
|
||||||
|
@ -1168,6 +1181,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
github.com/tommy-muehle/go-mnd v1.1.1/go.mod h1:dSUh0FtTP8VhvkL1S+gUR1OKd9ZnSaozuI6r3m6wOig=
|
github.com/tommy-muehle/go-mnd v1.1.1/go.mod h1:dSUh0FtTP8VhvkL1S+gUR1OKd9ZnSaozuI6r3m6wOig=
|
||||||
|
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef h1:wHSqTBrZW24CsNJDfeh9Ex6Pm0Rcpc7qrgKBiL44vF4=
|
||||||
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
|
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
|
||||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
|
|
|
@ -128,12 +128,12 @@ func GenerateBitXHubWithoutOrder(rep *repo.Repo) (*BitXHub, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. create executor and view executor
|
// 1. create executor and view executor
|
||||||
txExec, err := executor.New(rwLdg, loggers.Logger(loggers.Executor), rep.Config.Executor.Type)
|
txExec, err := executor.New(rwLdg, loggers.Logger(loggers.Executor), rep.Config.Executor.Type, rep.Config.GasLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("create BlockExecutor: %w", err)
|
return nil, fmt.Errorf("create BlockExecutor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
viewExec, err := executor.New(viewLdg, loggers.Logger(loggers.Executor), rep.Config.Executor.Type)
|
viewExec, err := executor.New(viewLdg, loggers.Logger(loggers.Executor), rep.Config.Executor.Type, rep.Config.GasLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("create ViewExecutor: %w", err)
|
return nil, fmt.Errorf("create ViewExecutor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,11 @@ type BlockExecutor struct {
|
||||||
|
|
||||||
evm *vm.EVM
|
evm *vm.EVM
|
||||||
evmChainCfg *params.ChainConfig
|
evmChainCfg *params.ChainConfig
|
||||||
|
gasLimit uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates executor instance
|
// New creates executor instance
|
||||||
func New(chainLedger ledger.Ledger, logger logrus.FieldLogger, typ string) (*BlockExecutor, error) {
|
func New(chainLedger ledger.Ledger, logger logrus.FieldLogger, typ string, gasLimit uint64) (*BlockExecutor, error) {
|
||||||
ibtpVerify := proof.New(chainLedger, logger)
|
ibtpVerify := proof.New(chainLedger, logger)
|
||||||
|
|
||||||
txsExecutor, err := agency.GetExecutorConstructor(typ)
|
txsExecutor, err := agency.GetExecutorConstructor(typ)
|
||||||
|
@ -77,7 +78,11 @@ func New(chainLedger ledger.Ledger, logger logrus.FieldLogger, typ string) (*Blo
|
||||||
currentBlockHash: chainLedger.GetChainMeta().BlockHash,
|
currentBlockHash: chainLedger.GetChainMeta().BlockHash,
|
||||||
wasmInstances: make(map[string]wasmer.Instance),
|
wasmInstances: make(map[string]wasmer.Instance),
|
||||||
evmChainCfg: newEVMChainCfg(),
|
evmChainCfg: newEVMChainCfg(),
|
||||||
|
gasLimit: gasLimit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockExecutor.evm = newEvm(1, uint64(0), blockExecutor.evmChainCfg, blockExecutor.ledger.StateDB())
|
||||||
|
|
||||||
blockExecutor.txsExecutor = txsExecutor(blockExecutor.applyTx, registerBoltContracts, logger)
|
blockExecutor.txsExecutor = txsExecutor(blockExecutor.applyTx, registerBoltContracts, logger)
|
||||||
|
|
||||||
return blockExecutor, nil
|
return blockExecutor, nil
|
||||||
|
|
|
@ -36,6 +36,7 @@ const (
|
||||||
dstMethod = "did:bitxhub:appchain2:."
|
dstMethod = "did:bitxhub:appchain2:."
|
||||||
from = "0x3f9d18f7c3a6e5e4c0b877fe3e688ab08840b997"
|
from = "0x3f9d18f7c3a6e5e4c0b877fe3e688ab08840b997"
|
||||||
executorType = "serial"
|
executorType = "serial"
|
||||||
|
gasLimit = 10000000
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNew(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
|
@ -50,7 +51,7 @@ func TestNew(t *testing.T) {
|
||||||
mockLedger.EXPECT().GetChainMeta().Return(chainMeta).AnyTimes()
|
mockLedger.EXPECT().GetChainMeta().Return(chainMeta).AnyTimes()
|
||||||
|
|
||||||
logger := log.NewWithModule("executor")
|
logger := log.NewWithModule("executor")
|
||||||
executor, err := New(mockLedger, logger, executorType)
|
executor, err := New(mockLedger, logger, executorType, gasLimit)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.NotNil(t, executor)
|
assert.NotNil(t, executor)
|
||||||
|
|
||||||
|
@ -105,9 +106,10 @@ func TestBlockExecutor_ExecuteBlock(t *testing.T) {
|
||||||
mockLedger.EXPECT().PersistBlockData(gomock.Any()).AnyTimes()
|
mockLedger.EXPECT().PersistBlockData(gomock.Any()).AnyTimes()
|
||||||
mockLedger.EXPECT().StateDB().AnyTimes()
|
mockLedger.EXPECT().StateDB().AnyTimes()
|
||||||
mockLedger.EXPECT().PrepareBlock(gomock.Any()).AnyTimes()
|
mockLedger.EXPECT().PrepareBlock(gomock.Any()).AnyTimes()
|
||||||
|
mockLedger.EXPECT().StateDB().Return(mockLedger).AnyTimes()
|
||||||
logger := log.NewWithModule("executor")
|
logger := log.NewWithModule("executor")
|
||||||
|
|
||||||
exec, err := New(mockLedger, logger, executorType)
|
exec, err := New(mockLedger, logger, executorType, gasLimit)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// mock data for block
|
// mock data for block
|
||||||
|
@ -213,7 +215,7 @@ func TestBlockExecutor_ApplyReadonlyTransactions(t *testing.T) {
|
||||||
mockLedger.EXPECT().SetNonce(gomock.Any(), gomock.Any()).AnyTimes()
|
mockLedger.EXPECT().SetNonce(gomock.Any(), gomock.Any()).AnyTimes()
|
||||||
logger := log.NewWithModule("executor")
|
logger := log.NewWithModule("executor")
|
||||||
|
|
||||||
exec, err := New(mockLedger, logger, executorType)
|
exec, err := New(mockLedger, logger, executorType, gasLimit)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// mock data for block
|
// mock data for block
|
||||||
|
@ -306,7 +308,7 @@ func TestBlockExecutor_ExecuteBlock_Transfer(t *testing.T) {
|
||||||
err = ldg.PersistExecutionResult(mockBlock(1, nil), nil, &pb.InterchainMeta{})
|
err = ldg.PersistExecutionResult(mockBlock(1, nil), nil, &pb.InterchainMeta{})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
executor, err := New(ldg, log.NewWithModule("executor"), executorType)
|
executor, err := New(ldg, log.NewWithModule("executor"), executorType, gasLimit)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
err = executor.Start()
|
err = executor.Start()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
@ -331,7 +333,7 @@ func TestBlockExecutor_ExecuteBlock_Transfer(t *testing.T) {
|
||||||
viewLedger, err := ledger.New(createMockRepo(t), blockchainStorage, ldb, blockFile, accountCache, log.NewWithModule("ledger"))
|
viewLedger, err := ledger.New(createMockRepo(t), blockchainStorage, ldb, blockFile, accountCache, log.NewWithModule("ledger"))
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
exec, err := New(viewLedger, log.NewWithModule("executor"), executorType)
|
exec, err := New(viewLedger, log.NewWithModule("executor"), executorType, gasLimit)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
tx := mockTransferTx(t)
|
tx := mockTransferTx(t)
|
||||||
|
|
|
@ -297,7 +297,6 @@ func (exec *BlockExecutor) applyTransaction(i int, tx pb.Transaction, invalidRea
|
||||||
}
|
}
|
||||||
return receipt
|
return receipt
|
||||||
case *pb.EthTransaction:
|
case *pb.EthTransaction:
|
||||||
// TODO
|
|
||||||
ethTx := tx.(*pb.EthTransaction)
|
ethTx := tx.(*pb.EthTransaction)
|
||||||
return exec.applyEthTransaction(i, ethTx)
|
return exec.applyEthTransaction(i, ethTx)
|
||||||
}
|
}
|
||||||
|
@ -362,16 +361,18 @@ func (exec *BlockExecutor) applyEthTransaction(i int, tx *pb.EthTransaction) *pb
|
||||||
Version: tx.GetVersion(),
|
Version: tx.GetVersion(),
|
||||||
TxHash: tx.GetHash(),
|
TxHash: tx.GetHash(),
|
||||||
}
|
}
|
||||||
gp := new(core.GasPool).AddGas(0x2fefd8)
|
|
||||||
|
gp := new(core.GasPool).AddGas(exec.gasLimit)
|
||||||
msg := ledger.NewMessage(tx)
|
msg := ledger.NewMessage(tx)
|
||||||
statedb := exec.ledger.StateDB()
|
statedb := exec.ledger.StateDB()
|
||||||
statedb.PrepareEVM(common.BytesToHash(tx.GetHash().Bytes()), i)
|
statedb.PrepareEVM(common.BytesToHash(tx.GetHash().Bytes()), i)
|
||||||
snapshot := statedb.Snapshot()
|
snapshot := statedb.Snapshot()
|
||||||
txContext := vm1.NewEVMTxContext(msg)
|
txContext := vm1.NewEVMTxContext(msg)
|
||||||
exec.evm.Reset(txContext, exec.ledger.StateDB())
|
exec.evm.Reset(txContext, exec.ledger.StateDB())
|
||||||
|
exec.logger.Warnf("msg gas: %v", msg.Gas())
|
||||||
result, err := vm1.ApplyMessage(exec.evm, msg, gp)
|
result, err := vm1.ApplyMessage(exec.evm, msg, gp)
|
||||||
exec.logger.Errorln(err)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
exec.logger.Errorf("apply msg failed: %s", err.Error())
|
||||||
statedb.RevertToSnapshot(snapshot)
|
statedb.RevertToSnapshot(snapshot)
|
||||||
receipt.Status = pb.Receipt_FAILED
|
receipt.Status = pb.Receipt_FAILED
|
||||||
receipt.Ret = []byte(err.Error())
|
receipt.Ret = []byte(err.Error())
|
||||||
|
@ -379,11 +380,14 @@ func (exec *BlockExecutor) applyEthTransaction(i int, tx *pb.EthTransaction) *pb
|
||||||
return receipt
|
return receipt
|
||||||
}
|
}
|
||||||
if result.Failed() {
|
if result.Failed() {
|
||||||
exec.logger.Infoln(result.Failed())
|
exec.logger.Warnf("execute tx failed: %s", result.Err.Error())
|
||||||
receipt.Status = pb.Receipt_FAILED
|
receipt.Status = pb.Receipt_FAILED
|
||||||
|
receipt.Ret = append([]byte(result.Err.Error()), result.Revert()...)
|
||||||
} else {
|
} else {
|
||||||
receipt.Status = pb.Receipt_SUCCESS
|
receipt.Status = pb.Receipt_SUCCESS
|
||||||
|
receipt.Ret = result.Return()
|
||||||
}
|
}
|
||||||
|
|
||||||
receipt.TxHash = tx.GetHash()
|
receipt.TxHash = tx.GetHash()
|
||||||
receipt.GasUsed = result.UsedGas
|
receipt.GasUsed = result.UsedGas
|
||||||
exec.ledger.ClearChangerAndRefund()
|
exec.ledger.ClearChangerAndRefund()
|
||||||
|
|
|
@ -348,7 +348,7 @@ func innerAccountChanged(account0 *innerAccount, account1 *innerAccount) bool {
|
||||||
// If account already exists, account0 is not nil. We should compare account0 and account1 to get the result.
|
// If account already exists, account0 is not nil. We should compare account0 and account1 to get the result.
|
||||||
if account0 != nil &&
|
if account0 != nil &&
|
||||||
account0.Nonce == account1.Nonce &&
|
account0.Nonce == account1.Nonce &&
|
||||||
account0.Balance == account1.Balance &&
|
account0.Balance.Cmp(account1.Balance) == 0 &&
|
||||||
bytes.Equal(account0.CodeHash, account1.CodeHash) {
|
bytes.Equal(account0.CodeHash, account1.CodeHash) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ func (o *innerAccount) Unmarshal(data []byte) error {
|
||||||
|
|
||||||
func copyOrNewIfEmpty(o *innerAccount) *innerAccount {
|
func copyOrNewIfEmpty(o *innerAccount) *innerAccount {
|
||||||
if o == nil {
|
if o == nil {
|
||||||
return &innerAccount{}
|
return &innerAccount{Balance: big.NewInt(0)}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &innerAccount{
|
return &innerAccount{
|
||||||
|
|
|
@ -206,12 +206,22 @@ func CreateBloom(receipts EvmReceipts) *types.Bloom {
|
||||||
|
|
||||||
func NewMessage(tx *pb.EthTransaction) etherTypes.Message {
|
func NewMessage(tx *pb.EthTransaction) etherTypes.Message {
|
||||||
from := common.BytesToAddress(tx.GetFrom().Bytes())
|
from := common.BytesToAddress(tx.GetFrom().Bytes())
|
||||||
to := common.BytesToAddress(tx.GetTo().Bytes())
|
var to *common.Address
|
||||||
|
if tx.GetTo() != nil {
|
||||||
|
toAddr := common.BytesToAddress(tx.GetTo().Bytes())
|
||||||
|
to = &toAddr
|
||||||
|
}
|
||||||
nonce := tx.GetNonce()
|
nonce := tx.GetNonce()
|
||||||
amount := new(big.Int).SetUint64(tx.GetAmount())
|
amount := new(big.Int).SetUint64(tx.GetAmount())
|
||||||
gas := tx.GetGas()
|
gas := tx.GetGas()
|
||||||
gasPrice := tx.GetGasPrice()
|
gasPrice := tx.GetGasPrice()
|
||||||
data := tx.GetPayload()
|
data := tx.GetPayload()
|
||||||
accessList := tx.AccessList()
|
accessList := tx.AccessList()
|
||||||
return etherTypes.NewMessage(from, &to, nonce, amount, gas, gasPrice, data, accessList, true)
|
|
||||||
|
checkNonce := true
|
||||||
|
if v, _, _ := tx.GetRawSignature(); v == nil {
|
||||||
|
checkNonce = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return etherTypes.NewMessage(from, to, nonce, amount, gas, gasPrice, data, accessList, checkNonce)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (l *ChainLedger) GetAccount(address *types.Address) *Account {
|
||||||
}
|
}
|
||||||
|
|
||||||
if data := l.ldb.Get(compositeKey(accountKey, address)); data != nil {
|
if data := l.ldb.Get(compositeKey(accountKey, address)); data != nil {
|
||||||
account.originAccount = &innerAccount{}
|
account.originAccount = &innerAccount{Balance: big.NewInt(0)}
|
||||||
if err := account.originAccount.Unmarshal(data); err != nil {
|
if err := account.originAccount.Unmarshal(data); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ type LogModule struct {
|
||||||
|
|
||||||
type Genesis struct {
|
type Genesis struct {
|
||||||
ChainID uint64 `json:"chainid" toml:"chainid"`
|
ChainID uint64 `json:"chainid" toml:"chainid"`
|
||||||
|
GasLimit uint64 `json:"gas_limit" toml:"gas_limit"`
|
||||||
Admins []*Admin `json:"admins" toml:"admins"`
|
Admins []*Admin `json:"admins" toml:"admins"`
|
||||||
Strategy map[string]string `json:"strategy" toml:"strategy"`
|
Strategy map[string]string `json:"strategy" toml:"strategy"`
|
||||||
Dider string `json:"dider" toml:"dider"`
|
Dider string `json:"dider" toml:"dider"`
|
||||||
|
@ -187,6 +188,10 @@ func DefaultConfig() (*Config, error) {
|
||||||
Executor: Executor{
|
Executor: Executor{
|
||||||
Type: "serial",
|
Type: "serial",
|
||||||
},
|
},
|
||||||
|
Genesis: Genesis{
|
||||||
|
ChainID: 1,
|
||||||
|
GasLimit: 0x2fefd8,
|
||||||
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,403 @@
|
||||||
|
// Code generated - DO NOT EDIT.
|
||||||
|
// This file is a generated binding and any manual changes will be lost.
|
||||||
|
|
||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/big"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
ethereum "github.com/ethereum/go-ethereum"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var (
|
||||||
|
_ = big.NewInt
|
||||||
|
_ = strings.NewReader
|
||||||
|
_ = ethereum.NotFound
|
||||||
|
_ = bind.Bind
|
||||||
|
_ = common.Big1
|
||||||
|
_ = types.BloomLookup
|
||||||
|
_ = event.NewSubscription
|
||||||
|
)
|
||||||
|
|
||||||
|
// StorageABI is the input ABI used to generate the binding from.
|
||||||
|
const StorageABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"number\",\"type\":\"uint256\"}],\"name\":\"storeNumber\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[],\"name\":\"retrieve\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"string\",\"name\":\"num\",\"type\":\"string\"}],\"name\":\"store\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"store\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
|
||||||
|
|
||||||
|
// StorageFuncSigs maps the 4-byte function signature to its string representation.
|
||||||
|
var StorageFuncSigs = map[string]string{
|
||||||
|
"2e64cec1": "retrieve()",
|
||||||
|
"131a0680": "store(string)",
|
||||||
|
"6057361d": "store(uint256)",
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageBin is the compiled bytecode used for deploying new contracts.
|
||||||
|
var StorageBin = "0x608060405234801561001057600080fd5b5061019e806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063131a0680146100465780632e64cec1146100ee5780636057361d14610108575b600080fd5b6100ec6004803603602081101561005c57600080fd5b81019060208101813564010000000081111561007757600080fd5b82018360208201111561008957600080fd5b803590602001918460018302840111640100000000831117156100ab57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610125945050505050565b005b6100f6610128565b60408051918252519081900360200190f35b6100ec6004803603602081101561011e57600080fd5b503561012e565b50565b60005490565b60008190556040805182815290517fb6339418f01686c6855f277c90d2fad82f81ee01e71a4924f21a7ea075bc90d99181900360200190a15056fea265627a7a723158204eb4d69c6674fb559d0cef248191f1ef8f75b62caa7fb4095a698c83ea8d573c64736f6c63430005110032"
|
||||||
|
|
||||||
|
// DeployStorage deploys a new Ethereum contract, binding an instance of Storage to it.
|
||||||
|
func DeployStorage(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Storage, error) {
|
||||||
|
parsed, err := abi.JSON(strings.NewReader(StorageABI))
|
||||||
|
if err != nil {
|
||||||
|
return common.Address{}, nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(StorageBin), backend)
|
||||||
|
if err != nil {
|
||||||
|
return common.Address{}, nil, nil, err
|
||||||
|
}
|
||||||
|
return address, tx, &Storage{StorageCaller: StorageCaller{contract: contract}, StorageTransactor: StorageTransactor{contract: contract}, StorageFilterer: StorageFilterer{contract: contract}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Storage is an auto generated Go binding around an Ethereum contract.
|
||||||
|
type Storage struct {
|
||||||
|
StorageCaller // Read-only binding to the contract
|
||||||
|
StorageTransactor // Write-only binding to the contract
|
||||||
|
StorageFilterer // Log filterer for contract events
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||||
|
type StorageCaller struct {
|
||||||
|
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||||
|
type StorageTransactor struct {
|
||||||
|
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
|
||||||
|
type StorageFilterer struct {
|
||||||
|
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageSession is an auto generated Go binding around an Ethereum contract,
|
||||||
|
// with pre-set call and transact options.
|
||||||
|
type StorageSession struct {
|
||||||
|
Contract *Storage // Generic contract binding to set the session for
|
||||||
|
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||||
|
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||||
|
// with pre-set call options.
|
||||||
|
type StorageCallerSession struct {
|
||||||
|
Contract *StorageCaller // Generic contract caller binding to set the session for
|
||||||
|
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||||
|
// with pre-set transact options.
|
||||||
|
type StorageTransactorSession struct {
|
||||||
|
Contract *StorageTransactor // Generic contract transactor binding to set the session for
|
||||||
|
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||||
|
type StorageRaw struct {
|
||||||
|
Contract *Storage // Generic contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||||
|
type StorageCallerRaw struct {
|
||||||
|
Contract *StorageCaller // Generic read-only contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||||
|
type StorageTransactorRaw struct {
|
||||||
|
Contract *StorageTransactor // Generic write-only contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewStorage creates a new instance of Storage, bound to a specific deployed contract.
|
||||||
|
func NewStorage(address common.Address, backend bind.ContractBackend) (*Storage, error) {
|
||||||
|
contract, err := bindStorage(address, backend, backend, backend)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &Storage{StorageCaller: StorageCaller{contract: contract}, StorageTransactor: StorageTransactor{contract: contract}, StorageFilterer: StorageFilterer{contract: contract}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewStorageCaller creates a new read-only instance of Storage, bound to a specific deployed contract.
|
||||||
|
func NewStorageCaller(address common.Address, caller bind.ContractCaller) (*StorageCaller, error) {
|
||||||
|
contract, err := bindStorage(address, caller, nil, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &StorageCaller{contract: contract}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewStorageTransactor creates a new write-only instance of Storage, bound to a specific deployed contract.
|
||||||
|
func NewStorageTransactor(address common.Address, transactor bind.ContractTransactor) (*StorageTransactor, error) {
|
||||||
|
contract, err := bindStorage(address, nil, transactor, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &StorageTransactor{contract: contract}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewStorageFilterer creates a new log filterer instance of Storage, bound to a specific deployed contract.
|
||||||
|
func NewStorageFilterer(address common.Address, filterer bind.ContractFilterer) (*StorageFilterer, error) {
|
||||||
|
contract, err := bindStorage(address, nil, nil, filterer)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &StorageFilterer{contract: contract}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// bindStorage binds a generic wrapper to an already deployed contract.
|
||||||
|
func bindStorage(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
|
||||||
|
parsed, err := abi.JSON(strings.NewReader(StorageABI))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call invokes the (constant) contract method with params as input values and
|
||||||
|
// sets the output to result. The result type might be a single field for simple
|
||||||
|
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||||
|
// returns.
|
||||||
|
func (_Storage *StorageRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||||
|
return _Storage.Contract.StorageCaller.contract.Call(opts, result, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||||
|
// its default method if one is available.
|
||||||
|
func (_Storage *StorageRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return _Storage.Contract.StorageTransactor.contract.Transfer(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transact invokes the (paid) contract method with params as input values.
|
||||||
|
func (_Storage *StorageRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||||
|
return _Storage.Contract.StorageTransactor.contract.Transact(opts, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call invokes the (constant) contract method with params as input values and
|
||||||
|
// sets the output to result. The result type might be a single field for simple
|
||||||
|
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||||
|
// returns.
|
||||||
|
func (_Storage *StorageCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||||
|
return _Storage.Contract.contract.Call(opts, result, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||||
|
// its default method if one is available.
|
||||||
|
func (_Storage *StorageTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return _Storage.Contract.contract.Transfer(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transact invokes the (paid) contract method with params as input values.
|
||||||
|
func (_Storage *StorageTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||||
|
return _Storage.Contract.contract.Transact(opts, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve is a free data retrieval call binding the contract method 0x2e64cec1.
|
||||||
|
//
|
||||||
|
// Solidity: function retrieve() view returns(uint256)
|
||||||
|
func (_Storage *StorageCaller) Retrieve(opts *bind.CallOpts) (*big.Int, error) {
|
||||||
|
var out []interface{}
|
||||||
|
err := _Storage.contract.Call(opts, &out, "retrieve")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return *new(*big.Int), err
|
||||||
|
}
|
||||||
|
|
||||||
|
out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
|
||||||
|
|
||||||
|
return out0, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve is a free data retrieval call binding the contract method 0x2e64cec1.
|
||||||
|
//
|
||||||
|
// Solidity: function retrieve() view returns(uint256)
|
||||||
|
func (_Storage *StorageSession) Retrieve() (*big.Int, error) {
|
||||||
|
return _Storage.Contract.Retrieve(&_Storage.CallOpts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve is a free data retrieval call binding the contract method 0x2e64cec1.
|
||||||
|
//
|
||||||
|
// Solidity: function retrieve() view returns(uint256)
|
||||||
|
func (_Storage *StorageCallerSession) Retrieve() (*big.Int, error) {
|
||||||
|
return _Storage.Contract.Retrieve(&_Storage.CallOpts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store is a paid mutator transaction binding the contract method 0x131a0680.
|
||||||
|
//
|
||||||
|
// Solidity: function store(string num) returns()
|
||||||
|
func (_Storage *StorageTransactor) Store(opts *bind.TransactOpts, num string) (*types.Transaction, error) {
|
||||||
|
return _Storage.contract.Transact(opts, "store", num)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store is a paid mutator transaction binding the contract method 0x131a0680.
|
||||||
|
//
|
||||||
|
// Solidity: function store(string num) returns()
|
||||||
|
func (_Storage *StorageSession) Store(num string) (*types.Transaction, error) {
|
||||||
|
return _Storage.Contract.Store(&_Storage.TransactOpts, num)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store is a paid mutator transaction binding the contract method 0x131a0680.
|
||||||
|
//
|
||||||
|
// Solidity: function store(string num) returns()
|
||||||
|
func (_Storage *StorageTransactorSession) Store(num string) (*types.Transaction, error) {
|
||||||
|
return _Storage.Contract.Store(&_Storage.TransactOpts, num)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store0 is a paid mutator transaction binding the contract method 0x6057361d.
|
||||||
|
//
|
||||||
|
// Solidity: function store(uint256 num) returns()
|
||||||
|
func (_Storage *StorageTransactor) Store0(opts *bind.TransactOpts, num *big.Int) (*types.Transaction, error) {
|
||||||
|
return _Storage.contract.Transact(opts, "store0", num)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store0 is a paid mutator transaction binding the contract method 0x6057361d.
|
||||||
|
//
|
||||||
|
// Solidity: function store(uint256 num) returns()
|
||||||
|
func (_Storage *StorageSession) Store0(num *big.Int) (*types.Transaction, error) {
|
||||||
|
return _Storage.Contract.Store0(&_Storage.TransactOpts, num)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store0 is a paid mutator transaction binding the contract method 0x6057361d.
|
||||||
|
//
|
||||||
|
// Solidity: function store(uint256 num) returns()
|
||||||
|
func (_Storage *StorageTransactorSession) Store0(num *big.Int) (*types.Transaction, error) {
|
||||||
|
return _Storage.Contract.Store0(&_Storage.TransactOpts, num)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageStoreNumberIterator is returned from FilterStoreNumber and is used to iterate over the raw logs and unpacked data for StoreNumber events raised by the Storage contract.
|
||||||
|
type StorageStoreNumberIterator struct {
|
||||||
|
Event *StorageStoreNumber // Event containing the contract specifics and raw log
|
||||||
|
|
||||||
|
contract *bind.BoundContract // Generic contract to use for unpacking event data
|
||||||
|
event string // Event name to use for unpacking event data
|
||||||
|
|
||||||
|
logs chan types.Log // Log channel receiving the found contract events
|
||||||
|
sub ethereum.Subscription // Subscription for errors, completion and termination
|
||||||
|
done bool // Whether the subscription completed delivering logs
|
||||||
|
fail error // Occurred error to stop iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next advances the iterator to the subsequent event, returning whether there
|
||||||
|
// are any more events found. In case of a retrieval or parsing error, false is
|
||||||
|
// returned and Error() can be queried for the exact failure.
|
||||||
|
func (it *StorageStoreNumberIterator) Next() bool {
|
||||||
|
// If the iterator failed, stop iterating
|
||||||
|
if it.fail != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// If the iterator completed, deliver directly whatever's available
|
||||||
|
if it.done {
|
||||||
|
select {
|
||||||
|
case log := <-it.logs:
|
||||||
|
it.Event = new(StorageStoreNumber)
|
||||||
|
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
|
||||||
|
it.fail = err
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.Event.Raw = log
|
||||||
|
return true
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Iterator still in progress, wait for either a data or an error event
|
||||||
|
select {
|
||||||
|
case log := <-it.logs:
|
||||||
|
it.Event = new(StorageStoreNumber)
|
||||||
|
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
|
||||||
|
it.fail = err
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
it.Event.Raw = log
|
||||||
|
return true
|
||||||
|
|
||||||
|
case err := <-it.sub.Err():
|
||||||
|
it.done = true
|
||||||
|
it.fail = err
|
||||||
|
return it.Next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error returns any retrieval or parsing error occurred during filtering.
|
||||||
|
func (it *StorageStoreNumberIterator) Error() error {
|
||||||
|
return it.fail
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close terminates the iteration process, releasing any pending underlying
|
||||||
|
// resources.
|
||||||
|
func (it *StorageStoreNumberIterator) Close() error {
|
||||||
|
it.sub.Unsubscribe()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageStoreNumber represents a StoreNumber event raised by the Storage contract.
|
||||||
|
type StorageStoreNumber struct {
|
||||||
|
Number *big.Int
|
||||||
|
Raw types.Log // Blockchain specific contextual infos
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterStoreNumber is a free log retrieval operation binding the contract event 0xb6339418f01686c6855f277c90d2fad82f81ee01e71a4924f21a7ea075bc90d9.
|
||||||
|
//
|
||||||
|
// Solidity: event storeNumber(uint256 number)
|
||||||
|
func (_Storage *StorageFilterer) FilterStoreNumber(opts *bind.FilterOpts) (*StorageStoreNumberIterator, error) {
|
||||||
|
|
||||||
|
logs, sub, err := _Storage.contract.FilterLogs(opts, "storeNumber")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &StorageStoreNumberIterator{contract: _Storage.contract, event: "storeNumber", logs: logs, sub: sub}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WatchStoreNumber is a free log subscription operation binding the contract event 0xb6339418f01686c6855f277c90d2fad82f81ee01e71a4924f21a7ea075bc90d9.
|
||||||
|
//
|
||||||
|
// Solidity: event storeNumber(uint256 number)
|
||||||
|
func (_Storage *StorageFilterer) WatchStoreNumber(opts *bind.WatchOpts, sink chan<- *StorageStoreNumber) (event.Subscription, error) {
|
||||||
|
|
||||||
|
logs, sub, err := _Storage.contract.WatchLogs(opts, "storeNumber")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return event.NewSubscription(func(quit <-chan struct{}) error {
|
||||||
|
defer sub.Unsubscribe()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case log := <-logs:
|
||||||
|
// New log arrived, parse the event and forward to the user
|
||||||
|
event := new(StorageStoreNumber)
|
||||||
|
if err := _Storage.contract.UnpackLog(event, "storeNumber", log); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
event.Raw = log
|
||||||
|
|
||||||
|
select {
|
||||||
|
case sink <- event:
|
||||||
|
case err := <-sub.Err():
|
||||||
|
return err
|
||||||
|
case <-quit:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
case err := <-sub.Err():
|
||||||
|
return err
|
||||||
|
case <-quit:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseStoreNumber is a log parse operation binding the contract event 0xb6339418f01686c6855f277c90d2fad82f81ee01e71a4924f21a7ea075bc90d9.
|
||||||
|
//
|
||||||
|
// Solidity: event storeNumber(uint256 number)
|
||||||
|
func (_Storage *StorageFilterer) ParseStoreNumber(log types.Log) (*StorageStoreNumber, error) {
|
||||||
|
event := new(StorageStoreNumber)
|
||||||
|
if err := _Storage.contract.UnpackLog(event, "storeNumber", log); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
event.Raw = log
|
||||||
|
return event, nil
|
||||||
|
}
|
|
@ -5,6 +5,8 @@
|
||||||
package mock_peermgr
|
package mock_peermgr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
reflect "reflect"
|
||||||
|
|
||||||
event "github.com/ethereum/go-ethereum/event"
|
event "github.com/ethereum/go-ethereum/event"
|
||||||
gomock "github.com/golang/mock/gomock"
|
gomock "github.com/golang/mock/gomock"
|
||||||
peer "github.com/libp2p/go-libp2p-core/peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
@ -12,61 +14,44 @@ import (
|
||||||
events "github.com/meshplus/bitxhub/internal/model/events"
|
events "github.com/meshplus/bitxhub/internal/model/events"
|
||||||
peermgr "github.com/meshplus/bitxhub/pkg/peermgr"
|
peermgr "github.com/meshplus/bitxhub/pkg/peermgr"
|
||||||
network "github.com/meshplus/go-lightp2p"
|
network "github.com/meshplus/go-lightp2p"
|
||||||
reflect "reflect"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockPeerManager is a mock of PeerManager interface
|
// MockPeerManager is a mock of PeerManager interface.
|
||||||
type MockPeerManager struct {
|
type MockPeerManager struct {
|
||||||
ctrl *gomock.Controller
|
ctrl *gomock.Controller
|
||||||
recorder *MockPeerManagerMockRecorder
|
recorder *MockPeerManagerMockRecorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockPeerManagerMockRecorder is the mock recorder for MockPeerManager
|
// MockPeerManagerMockRecorder is the mock recorder for MockPeerManager.
|
||||||
type MockPeerManagerMockRecorder struct {
|
type MockPeerManagerMockRecorder struct {
|
||||||
mock *MockPeerManager
|
mock *MockPeerManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMockPeerManager creates a new mock instance
|
// NewMockPeerManager creates a new mock instance.
|
||||||
func NewMockPeerManager(ctrl *gomock.Controller) *MockPeerManager {
|
func NewMockPeerManager(ctrl *gomock.Controller) *MockPeerManager {
|
||||||
mock := &MockPeerManager{ctrl: ctrl}
|
mock := &MockPeerManager{ctrl: ctrl}
|
||||||
mock.recorder = &MockPeerManagerMockRecorder{mock}
|
mock.recorder = &MockPeerManagerMockRecorder{mock}
|
||||||
return mock
|
return mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||||
func (m *MockPeerManager) EXPECT() *MockPeerManagerMockRecorder {
|
func (m *MockPeerManager) EXPECT() *MockPeerManagerMockRecorder {
|
||||||
return m.recorder
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start mocks base method
|
// AddNode mocks base method.
|
||||||
func (m *MockPeerManager) Start() error {
|
func (m *MockPeerManager) AddNode(newNodeID uint64, vpInfo *pb.VpInfo) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Start")
|
m.ctrl.Call(m, "AddNode", newNodeID, vpInfo)
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start indicates an expected call of Start
|
// AddNode indicates an expected call of AddNode.
|
||||||
func (mr *MockPeerManagerMockRecorder) Start() *gomock.Call {
|
func (mr *MockPeerManagerMockRecorder) AddNode(newNodeID, vpInfo interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockPeerManager)(nil).Start))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddNode", reflect.TypeOf((*MockPeerManager)(nil).AddNode), newNodeID, vpInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop mocks base method
|
// AsyncSend mocks base method.
|
||||||
func (m *MockPeerManager) Stop() error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Stop")
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop indicates an expected call of Stop
|
|
||||||
func (mr *MockPeerManagerMockRecorder) Stop() *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockPeerManager)(nil).Stop))
|
|
||||||
}
|
|
||||||
|
|
||||||
// AsyncSend mocks base method
|
|
||||||
func (m *MockPeerManager) AsyncSend(arg0 uint64, arg1 *pb.Message) error {
|
func (m *MockPeerManager) AsyncSend(arg0 uint64, arg1 *pb.Message) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "AsyncSend", arg0, arg1)
|
ret := m.ctrl.Call(m, "AsyncSend", arg0, arg1)
|
||||||
|
@ -74,27 +59,107 @@ func (m *MockPeerManager) AsyncSend(arg0 uint64, arg1 *pb.Message) error {
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsyncSend indicates an expected call of AsyncSend
|
// AsyncSend indicates an expected call of AsyncSend.
|
||||||
func (mr *MockPeerManagerMockRecorder) AsyncSend(arg0, arg1 interface{}) *gomock.Call {
|
func (mr *MockPeerManagerMockRecorder) AsyncSend(arg0, arg1 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AsyncSend", reflect.TypeOf((*MockPeerManager)(nil).AsyncSend), arg0, arg1)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AsyncSend", reflect.TypeOf((*MockPeerManager)(nil).AsyncSend), arg0, arg1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendWithStream mocks base method
|
// Broadcast mocks base method.
|
||||||
func (m *MockPeerManager) SendWithStream(arg0 network.Stream, arg1 *pb.Message) error {
|
func (m *MockPeerManager) Broadcast(arg0 *pb.Message) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "SendWithStream", arg0, arg1)
|
ret := m.ctrl.Call(m, "Broadcast", arg0)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendWithStream indicates an expected call of SendWithStream
|
// Broadcast indicates an expected call of Broadcast.
|
||||||
func (mr *MockPeerManagerMockRecorder) SendWithStream(arg0, arg1 interface{}) *gomock.Call {
|
func (mr *MockPeerManagerMockRecorder) Broadcast(arg0 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendWithStream", reflect.TypeOf((*MockPeerManager)(nil).SendWithStream), arg0, arg1)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Broadcast", reflect.TypeOf((*MockPeerManager)(nil).Broadcast), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send mocks base method
|
// CountConnectedPeers mocks base method.
|
||||||
|
func (m *MockPeerManager) CountConnectedPeers() uint64 {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "CountConnectedPeers")
|
||||||
|
ret0, _ := ret[0].(uint64)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountConnectedPeers indicates an expected call of CountConnectedPeers.
|
||||||
|
func (mr *MockPeerManagerMockRecorder) CountConnectedPeers() *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountConnectedPeers", reflect.TypeOf((*MockPeerManager)(nil).CountConnectedPeers))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelNode mocks base method.
|
||||||
|
func (m *MockPeerManager) DelNode(delID uint64) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
m.ctrl.Call(m, "DelNode", delID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelNode indicates an expected call of DelNode.
|
||||||
|
func (mr *MockPeerManagerMockRecorder) DelNode(delID interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DelNode", reflect.TypeOf((*MockPeerManager)(nil).DelNode), delID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disconnect mocks base method.
|
||||||
|
func (m *MockPeerManager) Disconnect(vpInfos map[uint64]*pb.VpInfo) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
m.ctrl.Call(m, "Disconnect", vpInfos)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disconnect indicates an expected call of Disconnect.
|
||||||
|
func (mr *MockPeerManagerMockRecorder) Disconnect(vpInfos interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Disconnect", reflect.TypeOf((*MockPeerManager)(nil).Disconnect), vpInfos)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OtherPeers mocks base method.
|
||||||
|
func (m *MockPeerManager) OtherPeers() map[uint64]*peer.AddrInfo {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "OtherPeers")
|
||||||
|
ret0, _ := ret[0].(map[uint64]*peer.AddrInfo)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// OtherPeers indicates an expected call of OtherPeers.
|
||||||
|
func (mr *MockPeerManagerMockRecorder) OtherPeers() *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OtherPeers", reflect.TypeOf((*MockPeerManager)(nil).OtherPeers))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Peers mocks base method.
|
||||||
|
func (m *MockPeerManager) Peers() map[uint64]*pb.VpInfo {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Peers")
|
||||||
|
ret0, _ := ret[0].(map[uint64]*pb.VpInfo)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Peers indicates an expected call of Peers.
|
||||||
|
func (mr *MockPeerManagerMockRecorder) Peers() *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Peers", reflect.TypeOf((*MockPeerManager)(nil).Peers))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PierManager mocks base method.
|
||||||
|
func (m *MockPeerManager) PierManager() peermgr.PierManager {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "PierManager")
|
||||||
|
ret0, _ := ret[0].(peermgr.PierManager)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// PierManager indicates an expected call of PierManager.
|
||||||
|
func (mr *MockPeerManagerMockRecorder) PierManager() *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PierManager", reflect.TypeOf((*MockPeerManager)(nil).PierManager))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send mocks base method.
|
||||||
func (m *MockPeerManager) Send(arg0 uint64, arg1 *pb.Message) (*pb.Message, error) {
|
func (m *MockPeerManager) Send(arg0 uint64, arg1 *pb.Message) (*pb.Message, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Send", arg0, arg1)
|
ret := m.ctrl.Call(m, "Send", arg0, arg1)
|
||||||
|
@ -103,69 +168,55 @@ func (m *MockPeerManager) Send(arg0 uint64, arg1 *pb.Message) (*pb.Message, erro
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send indicates an expected call of Send
|
// Send indicates an expected call of Send.
|
||||||
func (mr *MockPeerManagerMockRecorder) Send(arg0, arg1 interface{}) *gomock.Call {
|
func (mr *MockPeerManagerMockRecorder) Send(arg0, arg1 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockPeerManager)(nil).Send), arg0, arg1)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockPeerManager)(nil).Send), arg0, arg1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast mocks base method
|
// SendWithStream mocks base method.
|
||||||
func (m *MockPeerManager) Broadcast(arg0 *pb.Message) error {
|
func (m *MockPeerManager) SendWithStream(arg0 network.Stream, arg1 *pb.Message) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Broadcast", arg0)
|
ret := m.ctrl.Call(m, "SendWithStream", arg0, arg1)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast indicates an expected call of Broadcast
|
// SendWithStream indicates an expected call of SendWithStream.
|
||||||
func (mr *MockPeerManagerMockRecorder) Broadcast(arg0 interface{}) *gomock.Call {
|
func (mr *MockPeerManagerMockRecorder) SendWithStream(arg0, arg1 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Broadcast", reflect.TypeOf((*MockPeerManager)(nil).Broadcast), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendWithStream", reflect.TypeOf((*MockPeerManager)(nil).SendWithStream), arg0, arg1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountConnectedPeers mocks base method
|
// Start mocks base method.
|
||||||
func (m *MockPeerManager) CountConnectedPeers() uint64 {
|
func (m *MockPeerManager) Start() error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "CountConnectedPeers")
|
ret := m.ctrl.Call(m, "Start")
|
||||||
ret0, _ := ret[0].(uint64)
|
ret0, _ := ret[0].(error)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountConnectedPeers indicates an expected call of CountConnectedPeers
|
// Start indicates an expected call of Start.
|
||||||
func (mr *MockPeerManagerMockRecorder) CountConnectedPeers() *gomock.Call {
|
func (mr *MockPeerManagerMockRecorder) Start() *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountConnectedPeers", reflect.TypeOf((*MockPeerManager)(nil).CountConnectedPeers))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockPeerManager)(nil).Start))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Peers mocks base method
|
// Stop mocks base method.
|
||||||
func (m *MockPeerManager) Peers() map[uint64]*pb.VpInfo {
|
func (m *MockPeerManager) Stop() error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Peers")
|
ret := m.ctrl.Call(m, "Stop")
|
||||||
ret0, _ := ret[0].(map[uint64]*pb.VpInfo)
|
ret0, _ := ret[0].(error)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Peers indicates an expected call of Peers
|
// Stop indicates an expected call of Stop.
|
||||||
func (mr *MockPeerManagerMockRecorder) Peers() *gomock.Call {
|
func (mr *MockPeerManagerMockRecorder) Stop() *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Peers", reflect.TypeOf((*MockPeerManager)(nil).Peers))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockPeerManager)(nil).Stop))
|
||||||
}
|
}
|
||||||
|
|
||||||
// OtherPeers mocks base method
|
// SubscribeOrderMessage mocks base method.
|
||||||
func (m *MockPeerManager) OtherPeers() map[uint64]*peer.AddrInfo {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "OtherPeers")
|
|
||||||
ret0, _ := ret[0].(map[uint64]*peer.AddrInfo)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// OtherPeers indicates an expected call of OtherPeers
|
|
||||||
func (mr *MockPeerManagerMockRecorder) OtherPeers() *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OtherPeers", reflect.TypeOf((*MockPeerManager)(nil).OtherPeers))
|
|
||||||
}
|
|
||||||
|
|
||||||
// SubscribeOrderMessage mocks base method
|
|
||||||
func (m *MockPeerManager) SubscribeOrderMessage(ch chan<- events.OrderMessageEvent) event.Subscription {
|
func (m *MockPeerManager) SubscribeOrderMessage(ch chan<- events.OrderMessageEvent) event.Subscription {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "SubscribeOrderMessage", ch)
|
ret := m.ctrl.Call(m, "SubscribeOrderMessage", ch)
|
||||||
|
@ -173,37 +224,13 @@ func (m *MockPeerManager) SubscribeOrderMessage(ch chan<- events.OrderMessageEve
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubscribeOrderMessage indicates an expected call of SubscribeOrderMessage
|
// SubscribeOrderMessage indicates an expected call of SubscribeOrderMessage.
|
||||||
func (mr *MockPeerManagerMockRecorder) SubscribeOrderMessage(ch interface{}) *gomock.Call {
|
func (mr *MockPeerManagerMockRecorder) SubscribeOrderMessage(ch interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeOrderMessage", reflect.TypeOf((*MockPeerManager)(nil).SubscribeOrderMessage), ch)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeOrderMessage", reflect.TypeOf((*MockPeerManager)(nil).SubscribeOrderMessage), ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddNode mocks base method
|
// UpdateRouter mocks base method.
|
||||||
func (m *MockPeerManager) AddNode(newNodeID uint64, vpInfo *pb.VpInfo) {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
m.ctrl.Call(m, "AddNode", newNodeID, vpInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddNode indicates an expected call of AddNode
|
|
||||||
func (mr *MockPeerManagerMockRecorder) AddNode(newNodeID, vpInfo interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddNode", reflect.TypeOf((*MockPeerManager)(nil).AddNode), newNodeID, vpInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DelNode mocks base method
|
|
||||||
func (m *MockPeerManager) DelNode(delID uint64) {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
m.ctrl.Call(m, "DelNode", delID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DelNode indicates an expected call of DelNode
|
|
||||||
func (mr *MockPeerManagerMockRecorder) DelNode(delID interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DelNode", reflect.TypeOf((*MockPeerManager)(nil).DelNode), delID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateRouter mocks base method
|
|
||||||
func (m *MockPeerManager) UpdateRouter(vpInfos map[uint64]*pb.VpInfo, isNew bool) bool {
|
func (m *MockPeerManager) UpdateRouter(vpInfos map[uint64]*pb.VpInfo, isNew bool) bool {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "UpdateRouter", vpInfos, isNew)
|
ret := m.ctrl.Call(m, "UpdateRouter", vpInfos, isNew)
|
||||||
|
@ -211,76 +238,36 @@ func (m *MockPeerManager) UpdateRouter(vpInfos map[uint64]*pb.VpInfo, isNew bool
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRouter indicates an expected call of UpdateRouter
|
// UpdateRouter indicates an expected call of UpdateRouter.
|
||||||
func (mr *MockPeerManagerMockRecorder) UpdateRouter(vpInfos, isNew interface{}) *gomock.Call {
|
func (mr *MockPeerManagerMockRecorder) UpdateRouter(vpInfos, isNew interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRouter", reflect.TypeOf((*MockPeerManager)(nil).UpdateRouter), vpInfos, isNew)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRouter", reflect.TypeOf((*MockPeerManager)(nil).UpdateRouter), vpInfos, isNew)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disconnect mocks base method
|
// MockPierManager is a mock of PierManager interface.
|
||||||
func (m *MockPeerManager) Disconnect(vpInfos map[uint64]*pb.VpInfo) {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
m.ctrl.Call(m, "Disconnect", vpInfos)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disconnect indicates an expected call of Disconnect
|
|
||||||
func (mr *MockPeerManagerMockRecorder) Disconnect(vpInfos interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Disconnect", reflect.TypeOf((*MockPeerManager)(nil).Disconnect), vpInfos)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PierManager mocks base method
|
|
||||||
func (m *MockPeerManager) PierManager() peermgr.PierManager {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "PierManager")
|
|
||||||
ret0, _ := ret[0].(peermgr.PierManager)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// PierManager indicates an expected call of PierManager
|
|
||||||
func (mr *MockPeerManagerMockRecorder) PierManager() *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PierManager", reflect.TypeOf((*MockPeerManager)(nil).PierManager))
|
|
||||||
}
|
|
||||||
|
|
||||||
// MockPierManager is a mock of PierManager interface
|
|
||||||
type MockPierManager struct {
|
type MockPierManager struct {
|
||||||
ctrl *gomock.Controller
|
ctrl *gomock.Controller
|
||||||
recorder *MockPierManagerMockRecorder
|
recorder *MockPierManagerMockRecorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockPierManagerMockRecorder is the mock recorder for MockPierManager
|
// MockPierManagerMockRecorder is the mock recorder for MockPierManager.
|
||||||
type MockPierManagerMockRecorder struct {
|
type MockPierManagerMockRecorder struct {
|
||||||
mock *MockPierManager
|
mock *MockPierManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMockPierManager creates a new mock instance
|
// NewMockPierManager creates a new mock instance.
|
||||||
func NewMockPierManager(ctrl *gomock.Controller) *MockPierManager {
|
func NewMockPierManager(ctrl *gomock.Controller) *MockPierManager {
|
||||||
mock := &MockPierManager{ctrl: ctrl}
|
mock := &MockPierManager{ctrl: ctrl}
|
||||||
mock.recorder = &MockPierManagerMockRecorder{mock}
|
mock.recorder = &MockPierManagerMockRecorder{mock}
|
||||||
return mock
|
return mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||||
func (m *MockPierManager) EXPECT() *MockPierManagerMockRecorder {
|
func (m *MockPierManager) EXPECT() *MockPierManagerMockRecorder {
|
||||||
return m.recorder
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Piers mocks base method
|
// AskPierMaster mocks base method.
|
||||||
func (m *MockPierManager) Piers() *peermgr.Piers {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Piers")
|
|
||||||
ret0, _ := ret[0].(*peermgr.Piers)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Piers indicates an expected call of Piers
|
|
||||||
func (mr *MockPierManagerMockRecorder) Piers() *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Piers", reflect.TypeOf((*MockPierManager)(nil).Piers))
|
|
||||||
}
|
|
||||||
|
|
||||||
// AskPierMaster mocks base method
|
|
||||||
func (m *MockPierManager) AskPierMaster(arg0 string) (bool, error) {
|
func (m *MockPierManager) AskPierMaster(arg0 string) (bool, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "AskPierMaster", arg0)
|
ret := m.ctrl.Call(m, "AskPierMaster", arg0)
|
||||||
|
@ -289,8 +276,22 @@ func (m *MockPierManager) AskPierMaster(arg0 string) (bool, error) {
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// AskPierMaster indicates an expected call of AskPierMaster
|
// AskPierMaster indicates an expected call of AskPierMaster.
|
||||||
func (mr *MockPierManagerMockRecorder) AskPierMaster(arg0 interface{}) *gomock.Call {
|
func (mr *MockPierManagerMockRecorder) AskPierMaster(arg0 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AskPierMaster", reflect.TypeOf((*MockPierManager)(nil).AskPierMaster), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AskPierMaster", reflect.TypeOf((*MockPierManager)(nil).AskPierMaster), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Piers mocks base method.
|
||||||
|
func (m *MockPierManager) Piers() *peermgr.Piers {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "Piers")
|
||||||
|
ret0, _ := ret[0].(*peermgr.Piers)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Piers indicates an expected call of Piers.
|
||||||
|
func (mr *MockPierManagerMockRecorder) Piers() *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Piers", reflect.TypeOf((*MockPierManager)(nil).Piers))
|
||||||
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@ new = false
|
||||||
account = ""
|
account = ""
|
||||||
hosts = ["/ip4/127.0.0.1/tcp/5002/p2p/"]
|
hosts = ["/ip4/127.0.0.1/tcp/5002/p2p/"]
|
||||||
id = 2
|
id = 2
|
||||||
pid = "QmdvuDHAMgnVApnSUHA62JwP9G9d5N4rXtoHuNrcYyYdLw"
|
pid = "QmXMvjymbf1aowm2nktZXNzv6eaS74RHX2ZkXQbLiKB1MB"
|
||||||
|
|
||||||
[[nodes]]
|
[[nodes]]
|
||||||
account = ""
|
account = ""
|
||||||
hosts = ["/ip4/127.0.0.1/tcp/5003/p2p/"]
|
hosts = ["/ip4/127.0.0.1/tcp/5003/p2p/"]
|
||||||
id = 3
|
id = 3
|
||||||
pid = "QmXnkes8fqLBpG8RH6uFiokWRFCGCvWnNhQJoUhWkbNijE"
|
pid = "QmQzYVJimwwyNpZHdmyLAwUz6dFeXFzAghZvwn3fzw7VeS"
|
||||||
|
|
|
@ -9,6 +9,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/meshplus/bitxhub/api/jsonrpc"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/meshplus/bitxhub-kit/crypto/asym"
|
"github.com/meshplus/bitxhub-kit/crypto/asym"
|
||||||
|
@ -103,12 +105,13 @@ func TestTester(t *testing.T) {
|
||||||
require.True(t, ret.IsSuccess(), string(ret.Ret))
|
require.True(t, ret.IsSuccess(), string(ret.Ret))
|
||||||
adminNonce1++
|
adminNonce1++
|
||||||
|
|
||||||
suite.Run(t, &API{api: node1})
|
//suite.Run(t, &API{api: node1})
|
||||||
suite.Run(t, &RegisterAppchain{api: node2})
|
//suite.Run(t, &RegisterAppchain{api: node2})
|
||||||
suite.Run(t, &Interchain{api: node3})
|
//suite.Run(t, &Interchain{api: node3})
|
||||||
suite.Run(t, &Role{api: node4})
|
//suite.Run(t, &Role{api: node4})
|
||||||
suite.Run(t, &Store{api: node1})
|
//suite.Run(t, &Store{api: node1})
|
||||||
suite.Run(t, &Governance{api: node2})
|
//suite.Run(t, &Governance{api: node2})
|
||||||
|
suite.Run(t, &JsonRpc{api: node1})
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupNode(t *testing.T, path string) api.CoreAPI {
|
func setupNode(t *testing.T, path string) api.CoreAPI {
|
||||||
|
@ -127,6 +130,13 @@ func setupNode(t *testing.T, path string) api.CoreAPI {
|
||||||
api, err := coreapi.New(bxh)
|
api, err := coreapi.New(bxh)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
// start json-rpc service
|
||||||
|
cbs, err := jsonrpc.NewChainBrokerService(api, repo.Config)
|
||||||
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
err = cbs.Start()
|
||||||
|
require.Nil(t, err)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
err = bxh.Start()
|
err = bxh.Start()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
Loading…
Reference in New Issue