Skip to content

Commit

Permalink
improved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed May 21, 2024
1 parent 4181afa commit f5f5144
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ case class Header(override val version: Header.Version,
override val extensionRoot: Digest32,
powSolution: AutolykosSolution,
override val votes: Array[Byte], //3 bytes
override val sizeOpt: Option[Int] = None) extends
HeaderWithoutPow(version, parentId, ADProofsRoot, stateRoot, transactionsRoot, timestamp,
nBits, height, extensionRoot, votes)
with PreHeader with BlockSection {
override val sizeOpt: Option[Int] = None) extends HeaderWithoutPow(version, parentId, ADProofsRoot, stateRoot, transactionsRoot, timestamp,
nBits, height, extensionRoot, votes) with PreHeader with BlockSection {

override def serializedId: Array[Header.Version] = Algos.hash(bytes)

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ergo {
mempoolCapacity = 1000

# Interval for mempool transaction re-check. We check transaction when it is entering the mempool, and then
# re-check it every interval value
# re-check it every interval value (but only on new block arrival)
mempoolCleanupDuration = 30s

# Mempool transaction sorting scheme ("random", "bySize", or "byExecutionCost")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ErgoMemPool private[mempool](private[mempool] val pool: OrderedTxPool,
}

/**
* Remove transaction from the pool
* Remove transaction from the pool along with its double-spends
*/
def removeTxAndDoubleSpends(tx: ErgoTransaction): ErgoMemPool = {
def removeTx(mp: ErgoMemPool, tx: ErgoTransaction): ErgoMemPool = {
Expand All @@ -126,9 +126,12 @@ class ErgoMemPool private[mempool](private[mempool] val pool: OrderedTxPool,
}
}

/**
* Remove provided transactions and their doublespends from the pool
*/
def removeWithDoubleSpends(txs: TraversableOnce[ErgoTransaction]): ErgoMemPool = {
txs.foldLeft(this) { case (memPool, tx) =>
if (memPool.contains(tx.id)) {
if (memPool.contains(tx.id)) { // tx could be removed earlier in this loop as double-spend of another tx
memPool.removeTxAndDoubleSpends(tx)
} else {
memPool
Expand Down

0 comments on commit f5f5144

Please sign in to comment.