线上多签交易部署合约
多签交易投票通过后,查询链上合约不存在。
func newContractInitPairs() []*common.KeyValuePair {
goContractBytes, err := ioutil.ReadFile(contractByteCodePath)
if err != nil {
log.Fatalln(err)
}
return []*common.KeyValuePair{
{
Key: syscontract.MultiReq_SYS_CONTRACT_NAME.String(),
Value: []byte(syscontract.SystemContract_CONTRACT_MANAGE.String()),
},
{
Key: syscontract.MultiReq_SYS_METHOD.String(),
Value: []byte(syscontract.ContractManageFunction_INIT_CONTRACT.String()),
},
{
Key: syscontract.InitContract_CONTRACT_NAME.String(),
Value: []byte("zoo_6"),
},
{
Key: syscontract.InitContract_CONTRACT_VERSION.String(),
Value: []byte("1.0.0"),
},
{
Key: syscontract.InitContract_CONTRACT_BYTECODE.String(),
Value: goContractBytes,
},
{
Key: syscontract.InitContract_CONTRACT_RUNTIME_TYPE.String(),
Value: []byte(common.RuntimeType_DOCKER_GO.String()),
},
}
}
func main() {
cc, err := examples.CreateChainClientWithSDKConf(sdkConfigPKUser1Path)
if err != nil {
log.Fatalln(err)
}
fmt.Println("====================== 发送线上多签部署合约的交易 ======================")
kvs := newContractInitPairs() //构造交易发起 kv pairs
payload := cc.CreateMultiSignReqPayload(kvs)
resp, err := cc.MultiSignContractReq(payload)
if err != nil {
log.Fatalln(err)
}
fmt.Printf("send MultiSignContractReq resp: %+v\n", resp)
fmt.Println("====================== 各链管理员开始投票 ======================")
endorsers, err := examples.GetEndorsersWithAuthType(cc.GetHashType(),
cc.GetAuthType(), payload, examples.UserNameOrg1Admin1, examples.UserNameOrg2Admin1)
if err != nil {
log.Fatalln(err)
}
for i, e := range endorsers {
fmt.Printf("====================== 链管理员 %d 投票 ======================\n", i)
time.Sleep(3 * time.Second)
resp, err = cc.MultiSignContractVote(payload, e, true)
if err != nil {
log.Fatalln(err)
}
fmt.Printf("send MultiSignContractVote resp: %+v\n", resp)
time.Sleep(3 * time.Second)
fmt.Println("====================== 查询本多签交易的投票情况 ======================")
resp, err = cc.MultiSignContractQuery(payload.TxId)
if err != nil {
log.Fatalln(err)
}
//fmt.Printf("query MultiSignContractQuery resp: %+v\n", resp)
//查看详细投票信息
multiSignInfo := &syscontract.MultiSignInfo{}
fmt.Println("已完成投票:", len(multiSignInfo.VoteInfos))
//err = proto.Unmarshal(resp.ContractResult.Result, multiSignInfo)
//if err != nil {
// fmt.Printf(" multiSignInfoDB Unmarshal error: %s", err)
//}
//fmt.Printf("multi sign query finished, vote info: %v", multiSignInfo.VoteInfos)
//result, err := cc.GetSyncResult(resp.TxId)
//if err != nil {
// log.Fatalln(err)
//}
//fmt.Printf("result code:%d, msg:%s\n", result.Code, result.Code.String())
//fmt.Printf("contract result code:%d, msg:%s\n",
// result.ContractResult.Code, result.ContractResult.Message)
//if i+1 == needEndorserCount {
// break
//}
}
//fmt.Println("====================== 调用上边创建的合约 ======================")
//time.Sleep(time.Second * 3)
//fileHash := invokeUserContract(cc, true)
//
//fmt.Println("====================== 执行合约查询接口 ======================")
//kvs = []*common.KeyValuePair{
// {
// Key: "file_hash",
// Value: []byte(fileHash),
// },
//}
//testUserContractClaimQuery(cc, "find_by_file_hash", kvs)
}
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information