Skip to content

Commit

Permalink
add jury quantity judgment and unify container error return
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-li-hua committed Apr 14, 2020
1 parent 63995ad commit 9d2e60a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions validator/validate_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ func (validate *Validate) validateContractSignature(signatures []modules.Signatu
}
}
// 1.对于用户合约,确认签名者都是Jury
if common.IsUserContractId(contractId) { // user contract
if jury == nil && common.IsUserContractId(contractId) { // user contract
jury, err = validate.statequery.GetContractJury(contractId)
if err != nil {
log.Errorf("GetContractJury by contractId[%x] throw an error:%s",
log.Errorf("validateContractSignature, GetContractJury by contractId[%x] throw an error:%s",
contractId, err.Error())
return TxValidationCode_INVALID_CONTRACT_SIGN
}
}
if jury != nil { //有陪审团信息,判断公钥和陪审员是否匹配
if jury != nil && len(jury.EleList) > 0 { //有陪审团信息,判断公钥和陪审员是否匹配
jurorCount := len(jury.EleList)
needSign = int(math.Ceil((float64(jurorCount)*2 + 1) / 3))
for _, s := range signatures {
Expand All @@ -115,7 +115,7 @@ func (validate *Validate) validateContractSignature(signatures []modules.Signatu
}
}
if !find { //签名者不是合法的陪审员
log.Warnf("Tx[%s] signature payload addr[%s] is not a valid juror", txHash, crypto.PubkeyBytesToAddress(s.PubKey).String())
log.Warnf("validateContractSignature, Tx[%s] signature payload addr[%s] is not a valid juror", txHash, crypto.PubkeyBytesToAddress(s.PubKey).String())
return TxValidationCode_INVALID_CONTRACT_SIGN
}
}
Expand Down
6 changes: 4 additions & 2 deletions vm/dockercontroller/dockercontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ func (vm *DockerVM) Start(_ context.Context, ccid ccintf.CCID,
})

if err != nil {
return fmt.Errorf("Error uploading files to the container instance %s: %s", containerID, err)
log.Errorf("Error uploading files to the container instance %s: %s", containerID, err.Error())
return fmt.Errorf("Error uploading files to the container: %s", err.Error())
}
}

Expand All @@ -429,7 +430,8 @@ func (vm *DockerVM) Start(_ context.Context, ccid ccintf.CCID,
NoOverwriteDirNonDir: false,
})
if err != nil {
return fmt.Errorf("Error uploading files to the container instance %s: %s", containerID, err)
log.Errorf("Error uploading files to the container instance %s: %s", containerID, err.Error())
return fmt.Errorf("Error uploading files to the container: %s", err.Error())
}
// start container with HostConfig was deprecated since v1.10 and removed in v1.2
err = client.StartContainer(containerID, nil)
Expand Down

0 comments on commit 9d2e60a

Please sign in to comment.