• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版ec656812f0b14534a86b1518ef49c9ce71791de1 (tree)
时间2019-12-04 18:04:04
作者shenao78 <shenao.78@163....>
Commitershenao78

Log Message

validate equals trade pair

更改概述

差异

--- a/application/mov/mov_core.go
+++ b/application/mov/mov_core.go
@@ -197,7 +197,7 @@ func (m *MovCore) ValidateTx(tx *types.Tx, verifyResult *bc.TxVerifyResult) erro
197197 return errStatusFailMustFalse
198198 }
199199
200- if err := validateMagneticContractArgs(output.AssetAmount().Amount, output.ControlProgram()); err != nil {
200+ if err := validateMagneticContractArgs(output.AssetAmount(), output.ControlProgram()); err != nil {
201201 return err
202202 }
203203 }
@@ -221,17 +221,21 @@ func validateCancelOrderTx(tx *types.Tx, verifyResult *bc.TxVerifyResult) error
221221 return nil
222222 }
223223
224-func validateMagneticContractArgs(fromAmount uint64, program []byte) error {
224+func validateMagneticContractArgs(fromAssetAmount bc.AssetAmount, program []byte) error {
225225 contractArgs, err := segwit.DecodeP2WMCProgram(program)
226226 if err != nil {
227227 return err
228228 }
229229
230+ if *fromAssetAmount.AssetId == contractArgs.RequestedAsset {
231+ return errInvalidTradePairs
232+ }
233+
230234 if contractArgs.RatioNumerator <= 0 || contractArgs.RatioDenominator <= 0 {
231235 return errRatioOfTradeLessThanZero
232236 }
233237
234- if match.CalcRequestAmount(fromAmount, contractArgs) < 1 {
238+ if match.CalcRequestAmount(fromAssetAmount.Amount, contractArgs) < 1 {
235239 return errRequestAmountMath
236240 }
237241 return nil
@@ -258,10 +262,6 @@ func validateMatchedTx(tx *types.Tx, verifyResult *bc.TxVerifyResult) error {
258262 return err
259263 }
260264
261- if *order.FromAssetID == *order.ToAssetID {
262- return errInvalidTradePairs
263- }
264-
265265 fromAssetIDMap[order.FromAssetID.String()] = true
266266 toAssetIDMap[order.ToAssetID.String()] = true
267267 }
Show on old repository browser