• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版a2089dca7bc4e72a662db7b9765eba0ae0b66310 (tree)
时间2020-03-10 15:58:40
作者paladz <453256728@qq.c...>
Commiterpaladz

Log Message

edit for code review

更改概述

差异

--- a/protocol/vm/vmutil/script.go
+++ b/protocol/vm/vmutil/script.go
@@ -167,9 +167,9 @@ func P2WMCProgram(magneticContractArgs MagneticContractArgs) ([]byte, error) {
167167 // sellerKey: PublicKey) locks valueAmount of valueAsset {
168168 // clause partialTrade(exchangeAmount: Amount) {
169169 // define actualAmount: Integer = exchangeAmount * ratioDenominator / ratioNumerator
170-// actualAmount: Integer = actualAmount * 999 / 1000
171170 // verify actualAmount > 0 && actualAmount < valueAmount
172-// lock exchangeAmount of requestedAsset with sellerProgram
171+// define receiveAmount: Integer = exchangeAmount * 999 / 1000
172+// lock receiveAmount of requestedAsset with sellerProgram
173173 // lock valueAmount-actualAmount of valueAsset with standardProgram
174174 // unlock actualAmount of valueAsset
175175 // }
@@ -205,9 +205,6 @@ func P2WMCProgram(magneticContractArgs MagneticContractArgs) ([]byte, error) {
205205 // 3 [... exchangeAmount sellerKey standardProgram sellerProgram ratioNumerator requestedAsset exchangeAmount ratioDenominator 3]
206206 // ROLL [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset exchangeAmount ratioDenominator ratioNumerator]
207207 // MULFRACTION [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset actualAmount]
208-// 999 [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset actualAmount 999]
209-// 1000 [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset actualAmount 999 1000]
210-// MULFRACTION [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset actualAmount]
211208 // AMOUNT [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset actualAmount valueAmount]
212209 // OVER [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset actualAmount valueAmount actualAmount]
213210 // 0 [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset actualAmount valueAmount actualAmount 0]
@@ -224,12 +221,15 @@ func P2WMCProgram(magneticContractArgs MagneticContractArgs) ([]byte, error) {
224221 // TOALTSTACK [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset actualAmount <position>]
225222 // 6 [... exchangeAmount sellerKey standardProgram sellerProgram requestedAsset actualAmount <position> 6]
226223 // ROLL [... sellerKey standardProgram sellerProgram requestedAsset actualAmount <position> exchangeAmount]
227-// 3 [... sellerKey standardProgram sellerProgram requestedAsset actualAmount <position> exchangeAmount 3]
228-// ROLL [... sellerKey standardProgram sellerProgram actualAmount <position> exchangeAmount requestedAsset]
229-// 1 [... sellerKey standardProgram sellerProgram actualAmount <position> exchangeAmount requestedAsset 1]
230-// 5 [... sellerKey standardProgram sellerProgram actualAmount <position> exchangeAmount requestedAsset 1 5]
231-// ROLL [... sellerKey standardProgram actualAmount <position> exchangeAmount requestedAsset 1 sellerProgram]
232-// CHECKOUTPUT [... sellerKey standardProgram actualAmount checkOutput(exchangeAmount, requestedAsset, sellerProgram)]
224+// 999 [... sellerKey standardProgram sellerProgram requestedAsset actualAmount <position> exchangeAmount 999]
225+// 1000 [... sellerKey standardProgram sellerProgram requestedAsset actualAmount <position> exchangeAmount 1000]
226+// MULFRACTION [... sellerKey standardProgram sellerProgram requestedAsset actualAmount <position> receiveAmount]
227+// 3 [... sellerKey standardProgram sellerProgram requestedAsset actualAmount <position> receiveAmount 3]
228+// ROLL [... sellerKey standardProgram sellerProgram actualAmount <position> receiveAmount requestedAsset]
229+// 1 [... sellerKey standardProgram sellerProgram actualAmount <position> receiveAmount requestedAsset 1]
230+// 5 [... sellerKey standardProgram sellerProgram actualAmount <position> receiveAmount requestedAsset 1 5]
231+// ROLL [... sellerKey standardProgram actualAmount <position> receiveAmount requestedAsset 1 sellerProgram]
232+// CHECKOUTPUT [... sellerKey standardProgram actualAmount checkOutput(receiveAmount, requestedAsset, sellerProgram)]
233233 // VERIFY [... sellerKey standardProgram actualAmount]
234234 // FROMALTSTACK [... sellerKey standardProgram actualAmount <position>]
235235 // 1 [... sellerKey standardProgram actualAmount <position> 1]
@@ -308,9 +308,6 @@ func P2MCProgram(magneticContractArgs MagneticContractArgs) ([]byte, error) {
308308 builder.AddOp(vm.OP_3)
309309 builder.AddOp(vm.OP_ROLL)
310310 builder.AddOp(vm.OP_MULFRACTION)
311- builder.AddInt64(999)
312- builder.AddInt64(1000)
313- builder.AddOp(vm.OP_MULFRACTION)
314311 builder.AddOp(vm.OP_AMOUNT)
315312 builder.AddOp(vm.OP_OVER)
316313 builder.AddOp(vm.OP_0)
@@ -326,6 +323,9 @@ func P2MCProgram(magneticContractArgs MagneticContractArgs) ([]byte, error) {
326323 builder.AddOp(vm.OP_TOALTSTACK)
327324 builder.AddOp(vm.OP_6)
328325 builder.AddOp(vm.OP_ROLL)
326+ builder.AddInt64(999)
327+ builder.AddInt64(1000)
328+ builder.AddOp(vm.OP_MULFRACTION)
329329 builder.AddOp(vm.OP_3)
330330 builder.AddOp(vm.OP_ROLL)
331331 builder.AddOp(vm.OP_1)
Show on old repository browser