implicit val verifier ErgoInterpreter ErgoInterpreter us stateContext

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
implicit val verifier: ErgoInterpreter = ErgoInterpreter(us.stateContext.currentParameters)
// check validity and calculate transaction cost
us.validateWithCost(tx, Some(upcomingContext), maxTransactionComplexity) match {
case Success(costConsumed) =>
val newTxs = fixTxsConflicts(CostedTransaction(tx, costConsumed) +: acc)
val newBoxes = newTxs.flatMap(_.tx.outputs)
val emissionRules = us.constants.settings.chainSettings.emissionRules
ErgoMiner.collectFees(us.stateContext.currentHeight, newTxs.map(_.tx), minerPk, emissionRules) match {
case Some(feeTx) =>
val boxesToSpend = feeTx.inputs.flatMap(i => newBoxes.find(b => java.util.Arrays.equals(b.id, i.boxId)))
feeTx.statefulValidity(boxesToSpend, IndexedSeq(), upcomingContext) match {
case Success(cost) =>
val blockTxs: Seq[CostedTransaction] = CostedTransaction(feeTx, cost) +: newTxs
if (correctLimits(blockTxs)) {
loop(mempoolTxs.tail, newTxs, Some(CostedTransaction(feeTx, cost)), invalidTxs)
} else {
current -> invalidTxs
}
case Failure(e) =>
log.debug(s"Fee collecting tx is invalid, return current: ${e.getMessage} from ${us.stateContext}")
current -> invalidTxs
}
case None =>
log.debug(s"No fee proposition found in txs ${newTxs.map(_.tx.id)} ")
val blockTxs: Seq[CostedTransaction] = newTxs ++ lastFeeTx.toSeq
if (correctLimits(blockTxs)) {
loop(mempoolTxs.tail, blockTxs, lastFeeTx, invalidTxs)
} else {
current -> invalidTxs
}
}
case Failure(e) =>
log.debug(s"Do not include transaction ${tx.id} due to ${e.getMessage}")
loop(mempoolTxs.tail, acc, lastFeeTx, invalidTxs :+ tx.id)
}