Multi-threaded DLC CET signature verification (#3176)

This commit is contained in:
Nadav Kohen 2021-05-27 13:26:09 -05:00 committed by GitHub
parent 604194293c
commit 4b42b90784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,19 +59,18 @@ case class DLCSignatureVerifier(builder: DLCTxBuilder, isInitiator: Boolean) {
val correctNumberOfSigs =
sigs.size >= builder.contractInfo.allOutcomes.length
def runVerify(
outcomeSigs: Vector[
(Indexed[ECPublicKey], ECAdaptorSignature)]): Future[Boolean] = {
Future {
outcomeSigs.foldLeft(true) { case (ret, (outcome, sig)) =>
ret && verifyCETSig(outcome, sig)
val verifyFn: Vector[(Indexed[ECPublicKey], ECAdaptorSignature)] => Future[
Boolean] = { outcomeSigs =>
FutureUtil.makeAsync { () =>
outcomeSigs.forall { case (outcome, sig) =>
verifyCETSig(outcome, sig)
}
}
}
if (correctNumberOfSigs) {
FutureUtil
.batchAndParallelExecute(sigs, runVerify, 25)
.batchAndParallelExecute(sigs, verifyFn)
.map(_.forall(res => res))
} else Future.successful(false)
}