func (s *ApiService) dealTransact(tx *commonPb.Transaction, source protocol.TxSource) *commonPb.TxResponse {
var (
err error
errMsg string
errCode commonErr.ErrCode
resp = &commonPb.TxResponse{TxId: tx.Payload.TxId}
)
//在一条链上添加一笔交易,source是 rpc
err = s.chainMakerServer.AddTx(tx.Payload.ChainId, tx, source)
//增加一次调用计数
s.incInvokeCounter(tx.Payload.ChainId, err)
//更新交易大小
s.updateTxSizeHistogram(tx, err)
if err != nil {
errMsg = fmt.Sprintf("Add tx failed, %s, chainId:%s, txId:%s",
err.Error(), tx.Payload.ChainId, tx.Payload.TxId)
s.log.Warn(errMsg)
resp.Code = commonPb.TxStatusCode_INTERNAL_ERROR
resp.Message = errMsg
resp.TxId = tx.Payload.TxId
return resp
}
s.log.Debugf("Add tx success, chainId:%s, txId:%s", tx.Payload.ChainId, tx.Payload.TxId)
errCode = commonErr.ERR_CODE_OK
resp.Code = commonPb.TxStatusCode_SUCCESS
resp.Message = errCode.String()
resp.TxId = tx.Payload.TxId
return resp
}
评论