| 92 | } |
| 93 | |
| 94 | func opMerge(vm *VM) { |
| 95 | a := vm.popValue() |
| 96 | b := vm.popValue() |
| 97 | |
| 98 | if !bytes.Equal(a.assetID, b.assetID) { |
| 99 | panic(errors.WithData(ErrMergeAsset, "a.asset", a.assetID, "b.asset", b.assetID)) |
| 100 | } |
| 101 | |
| 102 | anchor := VMHash("Merge", append(a.anchor, b.anchor...)) |
| 103 | sum, ok := checked.AddInt64(a.amount, b.amount) |
| 104 | if !ok { |
| 105 | panic(errors.Wrap(errors.WithData(ErrIntOverflow, "a.amount", a.amount, "b.amount", b.amount), "merge")) |
| 106 | } |
| 107 | val := vm.createValue(sum, a.assetID, anchor[:]) |
| 108 | vm.push(val) |
| 109 | } |
| 110 | |
| 111 | func opRetire(vm *VM) { |
| 112 | val := vm.popValue() |