Skip to content

Commit

Permalink
UTXOSetBootstrapped flag added to ModePeerFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Aug 14, 2023
1 parent a73d077 commit 4443af5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/main/scala/org/ergoplatform/network/ModePeerFeature.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ case class ModePeerFeature(stateType: StateType,
override val featureId: Id = PeerFeatureDescriptors.ModeFeatureId

override def serializer: ErgoSerializer[ModePeerFeature] = ModeFeatureSerializer

def allBlocksAvailable: Boolean = blocksToKeep == ModePeerFeature.AllBlocksKept
}

object ModePeerFeature {
Expand All @@ -35,18 +37,27 @@ object ModePeerFeature {

val NiPoPoWNormalFlag = 1

val AllBlocksKept = -1
val UTXOSetBootstrapped = -2

def apply(nodeSettings: NodeConfigurationSettings): ModePeerFeature = {
val popowSuffix = if (nodeSettings.nipopowSettings.nipopowBootstrap) {
val popowBootstrapped = if (nodeSettings.nipopowSettings.nipopowBootstrap) {
Some(NiPoPoWNormalFlag)
} else {
None
}

val blocksKept = if (nodeSettings.utxoSettings.utxoBootstrap) {
UTXOSetBootstrapped
} else {
nodeSettings.blocksToKeep
}

new ModePeerFeature(
nodeSettings.stateType,
nodeSettings.verifyTransactions,
popowSuffix,
nodeSettings.blocksToKeep
popowBootstrapped,
blocksKept
)
}

Expand Down Expand Up @@ -79,7 +90,7 @@ object ModeFeatureSerializer extends ErgoSerializer[ModePeerFeature] {
w.put(mf.stateType.stateTypeCode)
w.put(booleanToByte(mf.verifyingTransactions))
w.putOption(mf.nipopowBootstrapped)(_.putInt(_))
w.putInt(mf.blocksToKeep) // todo: put -2 if bootstrapped via utxo set snapshot? https://github.com/ergoplatform/ergo/issues/2014
w.putInt(mf.blocksToKeep)
}

override def parse(r: Reader): ModePeerFeature = {
Expand Down

0 comments on commit 4443af5

Please sign in to comment.