Skip to content

Commit

Permalink
reworked LocallyGeneratedInputBlock signature
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Oct 18, 2024
1 parent ac824a4 commit 4fc43c5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ergoplatform.nodeView

import org.ergoplatform.modifiers.ErgoFullBlock
import org.ergoplatform.network.message.subblocks.SubBlockTransactionsData
import org.ergoplatform.subblocks.SubBlockInfo

case class LocallyGeneratedInputBlock(efb: ErgoFullBlock)
case class LocallyGeneratedInputBlock(sbi: SubBlockInfo, sbt: SubBlockTransactionsData)
12 changes: 8 additions & 4 deletions src/main/scala/org/ergoplatform/mining/CandidateGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.ergoplatform.modifiers.history.header.{Header, HeaderWithoutPow}
import org.ergoplatform.modifiers.history.popow.NipopowAlgos
import org.ergoplatform.modifiers.mempool.{ErgoTransaction, UnconfirmedTransaction}
import org.ergoplatform.network.ErgoNodeViewSynchronizerMessages._
import org.ergoplatform.network.message.subblocks.SubBlockTransactionsData
import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages.EliminateTransactions
import org.ergoplatform.nodeView.ErgoReadersHolder.{GetReaders, Readers}
import org.ergoplatform.nodeView.{LocallyGeneratedInputBlock, LocallyGeneratedOrderingBlock}
Expand Down Expand Up @@ -66,11 +67,11 @@ class CandidateGenerator(
}

/** Send solved input block to processing */
private def sendInputToNodeView(newBlock: ErgoFullBlock): Unit = {
private def sendInputToNodeView(sbi: SubBlockInfo, sbt: SubBlockTransactionsData): Unit = {
log.info(
s"New input block ${newBlock.id} w. nonce ${Longs.fromByteArray(newBlock.header.powSolution.n)}"
s"New input block ${sbi.subBlock.id} w. nonce ${Longs.fromByteArray(sbi.subBlock.powSolution.n)}"
)
viewHolderRef ! LocallyGeneratedInputBlock(newBlock)
viewHolderRef ! LocallyGeneratedInputBlock(sbi, sbt)
}

override def receive: Receive = {
Expand Down Expand Up @@ -209,7 +210,10 @@ class CandidateGenerator(
val powValid = SubBlockAlgos.checkInputBlockPoW(newBlock.header)
// todo: check links?
// todo: update candidate generator state
sendInputToNodeView(newBlock)
// todo: form and send real data
val sbi: SubBlockInfo = null
val sbt : SubBlockTransactionsData = null
sendInputToNodeView(sbi, sbt)
StatusReply.error(
new Exception(s"Input block found! PoW valid: $powValid")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,11 @@ abstract class ErgoNodeViewHolder[State <: ErgoState[State]](settings: ErgoSetti
sectionsToApply.foreach { section =>
pmodModify(section, local = true)
}
case LocallyGeneratedInputBlock(efb) =>
log.info(s"Got locally generated input block ${efb.id}")
// todo: real processing
case LocallyGeneratedInputBlock(sbi, sbt) =>
log.info(s"Got locally generated input block ${sbi.subBlock.id}")
history().applySubBlockHeader(sbi)
history().applySubBlockTransactions(sbi.subBlock.id, sbt.transactions)
// todo: finish processing
}

protected def getCurrentInfo: Receive = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import scala.collection.mutable

trait SubBlocksProcessor extends ScorexLogging {

/**
* Pointer to a best input-block known
*/
var _bestSubblock: Option[SubBlockInfo] = None

val subBlockRecords = mutable.Map[ModifierId, SubBlockInfo]()
val subBlockTransactions = mutable.Map[ModifierId, Seq[ErgoTransaction]]()

Expand Down

0 comments on commit 4fc43c5

Please sign in to comment.