vm: deduplicate checkMultisigPar

Make its logic more clear.
This commit is contained in:
Roman Khimov 2020-01-08 13:03:55 +03:00 committed by Evgenii Stratonikov
parent d93d060010
commit 02a5e036fc

View file

@ -1467,8 +1467,12 @@ func checkMultisigPar(v *VM, pkeys [][]byte, sigs [][]byte) bool {
loop: loop:
for r := range results { for r := range results {
goingForward := true
taskCount-- taskCount--
if r.signum == s1 { if r.signum == s2 {
goingForward = false
}
if k1+1 == k2 { if k1+1 == k2 {
sigok = r.ok && s1+1 == s2 sigok = r.ok && s1+1 == s2
if taskCount != 0 && sigok { if taskCount != 0 && sigok {
@ -1482,31 +1486,25 @@ loop:
} }
break loop break loop
} }
if goingForward {
s1++ s1++
}
k1++
taskCount++
tasks <- task{pub: v.bytesToPublicKey(pkeys[k1]), signum: s1}
} else { } else {
if k1+1 == k2 {
sigok = r.ok && s1+1 == s2
if taskCount != 0 && sigok {
continue
}
break loop
} else if r.ok {
if s1+1 == s2 {
if taskCount != 0 && sigok {
continue
}
break loop
}
s2-- s2--
} }
k2--
taskCount++
tasks <- task{pub: v.bytesToPublicKey(pkeys[k2]), signum: s2}
} }
var nextSig, nextKey int
if goingForward {
k1++
nextSig = s1
nextKey = k1
} else {
k2--
nextSig = s2
nextKey = k2
}
taskCount++
tasks <- task{pub: v.bytesToPublicKey(pkeys[nextKey]), signum: nextSig}
} }
close(tasks) close(tasks)