forked from TrueCloudLab/neoneo-go
vm: deduplicate checkMultisigPar
Make its logic more clear.
This commit is contained in:
parent
d93d060010
commit
02a5e036fc
1 changed files with 29 additions and 31 deletions
40
pkg/vm/vm.go
40
pkg/vm/vm.go
|
@ -1467,8 +1467,12 @@ func checkMultisigPar(v *VM, pkeys [][]byte, sigs [][]byte) bool {
|
|||
|
||||
loop:
|
||||
for r := range results {
|
||||
goingForward := true
|
||||
|
||||
taskCount--
|
||||
if r.signum == s1 {
|
||||
if r.signum == s2 {
|
||||
goingForward = false
|
||||
}
|
||||
if k1+1 == k2 {
|
||||
sigok = r.ok && s1+1 == s2
|
||||
if taskCount != 0 && sigok {
|
||||
|
@ -1482,31 +1486,25 @@ loop:
|
|||
}
|
||||
break loop
|
||||
}
|
||||
if goingForward {
|
||||
s1++
|
||||
}
|
||||
k1++
|
||||
taskCount++
|
||||
tasks <- task{pub: v.bytesToPublicKey(pkeys[k1]), signum: s1}
|
||||
} 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--
|
||||
}
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue