MCPcopy Create free account
hub / github.com/chain/txvm / opMerge

Function opMerge

protocol/txvm/values.go:94–109  ·  view source on GitHub ↗
(vm *VM)

Source from the content-addressed store, hash-verified

92}
93
94func 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
111func opRetire(vm *VM) {
112 val := vm.popValue()

Callers

nothing calls this directly

Calls 8

WithDataFunction · 0.92
AddInt64Function · 0.92
WrapFunction · 0.92
VMHashFunction · 0.85
popValueMethod · 0.80
EqualMethod · 0.80
createValueMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected