Skip to content

Commit

Permalink
forming prevInputBlockId
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Dec 24, 2024
1 parent 87a91d5 commit 8e9d526
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
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 @@ -18,6 +18,7 @@ import org.ergoplatform.nodeView.ErgoNodeViewHolder.ReceivableMessages.Eliminate
import org.ergoplatform.nodeView.ErgoReadersHolder.{GetReaders, Readers}
import org.ergoplatform.nodeView.{LocallyGeneratedInputBlock, LocallyGeneratedOrderingBlock}
import org.ergoplatform.nodeView.history.ErgoHistoryUtils.Height
import org.ergoplatform.nodeView.history.storage.modifierprocessors.InputBlocksProcessor
import org.ergoplatform.nodeView.history.{ErgoHistoryReader, ErgoHistoryUtils}
import org.ergoplatform.nodeView.mempool.ErgoMemPoolReader
import org.ergoplatform.nodeView.state.{ErgoState, ErgoStateContext, UtxoStateReader}
Expand All @@ -29,7 +30,7 @@ import org.ergoplatform.{ErgoBox, ErgoBoxCandidate, ErgoTreePredef, Input, Input
import scorex.crypto.authds.merkle.BatchMerkleProof
import scorex.crypto.hash.Digest32
import scorex.util.encode.Base16
import scorex.util.{ModifierId, ScorexLogging}
import scorex.util.{ModifierId, ScorexLogging, idToBytes}
import sigma.data.{Digest32Coll, ProveDlog}
import sigma.crypto.CryptoFacade
import sigma.eval.Extensions.EvalIterableOps
Expand Down Expand Up @@ -207,7 +208,8 @@ class CandidateGenerator(
}
case _: InputSolutionFound =>
log.info("Input-block mined!")
val (sbi, sbt) = completeInputBlock(state.cache.get.candidateBlock, solution)

val (sbi, sbt) = completeInputBlock(state.hr, state.cache.get.candidateBlock, solution)
sendInputToNodeView(sbi, sbt)

StatusReply.error(
Expand Down Expand Up @@ -921,13 +923,15 @@ object CandidateGenerator extends ScorexLogging {
new ErgoFullBlock(header, blockTransactions, extension, Some(adProofs))
}

def completeInputBlock(candidate: CandidateBlock, solution: AutolykosSolution): (InputBlockInfo, InputBlockTransactionsData) = {
def completeInputBlock(inputBlockProcessor: InputBlocksProcessor,
candidate: CandidateBlock,
solution: AutolykosSolution): (InputBlockInfo, InputBlockTransactionsData) = {

// todo: check links?
// todo: update candidate generator state
// todo: form and send real data instead of null

val prevSubBlockId: Option[Array[Byte]] = null
val prevSubBlockId: Option[Array[Byte]] = inputBlockProcessor.bestInputBlock().map(_.header.id).map(idToBytes)
val subblockTransactionsDigest: Digest32 = null
val merkleProof: BatchMerkleProof[Digest32] = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.ergoplatform.nodeView.history.storage.modifierprocessors

import org.ergoplatform.ErgoLikeContext.Height
import org.ergoplatform.modifiers.mempool.ErgoTransaction
import org.ergoplatform.nodeView.history.ErgoHistoryReader
import org.ergoplatform.subblocks.InputBlockInfo
import scorex.util.{ModifierId, ScorexLogging, bytesToId}

Expand All @@ -14,6 +15,11 @@ import scala.collection.mutable
*/
trait InputBlocksProcessor extends ScorexLogging {

/**
* @return interface to read objects from history database
*/
def historyReader: ErgoHistoryReader

/**
* Pointer to a best input-block known
*/
Expand Down Expand Up @@ -85,7 +91,13 @@ trait InputBlocksProcessor extends ScorexLogging {
}

def bestInputBlock(): Option[InputBlockInfo] = {
_bestInputBlock
_bestInputBlock.flatMap{bib =>
if(bib.header.height == historyReader.headersHeight) { // check header id?
Some(bib)
} else {
None
}
}
}

}

0 comments on commit 8e9d526

Please sign in to comment.