xuperchain / xuper-sdk-go

Xuper-SDK is a powerful tool for the Go developers to access and use public network of XuperChain easily and quickly.
Apache License 2.0
41 stars 51 forks source link

编译后执行example/main.go中testTransfer报错 #19

Open Ailab666666 opened 4 years ago

Ailab666666 commented 4 years ago

账户余额查询正确,执行transfer报错,错误信息如下:

2020/08/05 15:58:44 PreExecWithSelecUTXO EndorserCall failed, err: rpc error: code = DeadlineExceeded desc = context deadline exceeded 2020/08/05 15:58:44 Transfer PreExecWithSelecUTXO failed, err: EndorserCall error! Response is: rpc error: code = DeadlineExceeded desc = context deadline exceeded Transfer err: EndorserCall error! Response is: rpc error: code = DeadlineExceeded desc = context deadline exceeded transfer tx:

qizheng09 commented 4 years ago

Now TestTransfer can not be used in TestNet and Open NetWork. You can use this function in your own chain.

Ailab666666 commented 4 years ago

@qizheng09 您好,使用BAAS尝试了建立自己网络,建立普通节点后, 使用sdk链接节点列表中显示的IP报错连接超时

YangEfei commented 3 years ago

在发送交易时会读取 config 文件

xuper-sdk-go/transfer/transfer.go

// InitTrans init a client to transfer
func InitTrans(account *account.Account, node, bcname string) *Trans {
    commConfig := config.GetInstance()

    return &Trans{
        Xchain: xchain.Xchain{
            Cfg:       commConfig,
            Account:   account,
            XchainSer: node,
            ChainName: bcname,
        },
    }
}

在 config 模块中含有 config 文件路径,可按需修改为自己的 config 文件路径

xuper-sdk-go/config/config.go

const confPath = "./conf"
const confName = "sdk.yaml"

const CRYPTO_XCHAIN = "xchain"
const CRYPTO_GM = "gm"

var config *CommConfig

func GetInstance() *CommConfig {
    if config == nil {
        config = GetConfig(confPath, confName)
    }
    return config
}

在 config 文件中需指明背书服务器的地址,如默认本地环境可更换为 127.0.0.1:37101

xuper-sdk-go/conf/sdk.yaml

# endorseService Info
# testNet addrs
endorseServiceHost: "39.156.69.83:37100"  # 默认本地环境 127.0.0.1:37101
complianceCheck:
  # 是否需要进行合规性背书
  isNeedComplianceCheck: true
  # 是否需要支付合规性背书费用
  isNeedComplianceCheckFee: true
  # 合规性背书费用
  complianceCheckEndorseServiceFee: 400
  # 支付合规性背书费用的收款地址
  complianceCheckEndorseServiceFeeAddr: aB2hpHnTBDxko3UoP2BpBZRujwhdcAFoT
  # 如果通过合规性检查,签发认证签名的地址
  complianceCheckEndorseServiceAddr: jknGxa6eyum1JrATWvSJKW3thJ9GKHA9n
#创建平行链所需要的最低费用
minNewChainAmount: "100"
crypto: "xchain"

此外该背书服务器在启动链时需开启背书服务,该服务可通过区块链的配置文件进行修改(编译后在 output/conf/xchain.yaml 下进行修改)

xuperchain/conf/xchain.yaml

# 背书服务相关配置
xendorser:
  # 是否开启默认的XEndorser背书服务
  enable: false  # 交易指向的背书服务器需置为 true
  module: "default"
  #confPath: "./conf/xendorser.yaml"