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,46 +1467,44 @@ 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 {
if k1+1 == k2 { goingForward = false
sigok = r.ok && s1+1 == s2 }
if taskCount != 0 && sigok { if k1+1 == k2 {
continue sigok = r.ok && s1+1 == s2
} if taskCount != 0 && sigok {
break loop continue
} else if r.ok {
if s1+1 == s2 {
if taskCount != 0 && sigok {
continue
}
break loop
}
s1++
} }
k1++ break loop
taskCount++ } else if r.ok {
tasks <- task{pub: v.bytesToPublicKey(pkeys[k1]), signum: s1} if s1+1 == s2 {
} else {
if k1+1 == k2 {
sigok = r.ok && s1+1 == s2
if taskCount != 0 && sigok { if taskCount != 0 && sigok {
continue continue
} }
break loop break loop
} else if r.ok { }
if s1+1 == s2 { if goingForward {
if taskCount != 0 && sigok { s1++
continue } else {
}
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)