Skip to content

Commit 6eaa14a

Browse files
committed
Merge branch 'pr/216' of github.com:ScorexFoundation/Scorex into pr/216
2 parents e63038a + 9b86b16 commit 6eaa14a

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

examples/src/main/scala/examples/hybrid/history/HistoryStorage.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class HistoryStorage(storage: LSMStore,
7272
storage.update(version, Seq(), Seq(validityKey(b) -> ByteArrayWrapper(Array(status.code))))
7373
}
7474

75-
def update(b: HybridBlock, difficulty: Option[(BigInt, Long)], isBest: Boolean) {
75+
def update(b: HybridBlock, difficulty: Option[(BigInt, BigInt)], isBest: Boolean) {
7676
log.debug(s"Write new best=$isBest block ${b.encodedId}")
7777
val typeByte = b match {
7878
case _: PowBlock =>
@@ -86,7 +86,7 @@ class HistoryStorage(storage: LSMStore,
8686

8787
val blockDiff: Iterable[(ByteArrayWrapper, ByteArrayWrapper)] = difficulty.map { d =>
8888
Seq(blockDiffKey(b.id, isPos = false) -> ByteArrayWrapper(d._1.toByteArray),
89-
blockDiffKey(b.id, isPos = true) -> ByteArrayWrapper(Longs.toByteArray(d._2)))
89+
blockDiffKey(b.id, isPos = true) -> ByteArrayWrapper(d._2.toByteArray))
9090
}.getOrElse(Seq())
9191

9292
val bestBlockSeq: Iterable[(ByteArrayWrapper, ByteArrayWrapper)] = b match {
@@ -119,10 +119,10 @@ class HistoryStorage(storage: LSMStore,
119119
}
120120
}
121121

122-
def getPoSDifficulty(id: ModifierId): Long = if (id sameElements settings.GenesisParentId) {
122+
def getPoSDifficulty(id: ModifierId): BigInt = if (id sameElements settings.GenesisParentId) {
123123
PosForger.InitialDifficuly
124124
} else {
125-
Longs.fromByteArray(storage.get(blockDiffKey(id, isPos = true)).get.data)
125+
BigInt(storage.get(blockDiffKey(id, isPos = true)).get.data)
126126
}
127127

128128
def parentHeight(b: HybridBlock): Long = heightOf(parentId(b)).getOrElse(0L)

examples/src/main/scala/examples/hybrid/history/HybridHistory.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class HybridHistory(val storage: HistoryStorage,
213213
}
214214
}
215215

216-
private def calcDifficultiesForNewBlock(posBlock: PosBlock): (BigInt, Long) = {
216+
private def calcDifficultiesForNewBlock(posBlock: PosBlock): (BigInt, BigInt) = {
217217
def bounded(newVal: BigInt, oldVal: BigInt): BigInt = if (newVal > oldVal * 2) oldVal * 2 else newVal
218218

219219
val powHeight = storage.parentHeight(posBlock) / 2 + 1

examples/src/main/scala/examples/hybrid/mining/PosForger.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ object PosForger extends ScorexLogging {
6161

6262
import scorex.core.NodeViewHolder.ReceivableMessages.GetDataFromCurrentView
6363

64-
val InitialDifficuly = 15000000000L
64+
val InitialDifficuly = 1500000000L
6565

6666
object ReceivableMessages {
6767
case object StartForging
6868
case object StopForging
6969
case class PosForgingInfo(pairCompleted: Boolean,
7070
bestPowBlock: PowBlock,
71-
diff: Long,
71+
diff: BigInt,
7272
boxKeys: Seq[(PublicKey25519NoncedBox, PrivateKey25519)],
7373
txsToInclude: Seq[SimpleBoxTransaction])
7474
}
7575

7676
import ReceivableMessages.PosForgingInfo
7777

78-
def hit(pwb: PowBlock)(box: PublicKey25519NoncedBox): Long = {
78+
def hit(pwb: PowBlock)(box: PublicKey25519NoncedBox): BigInt = {
7979
val h = Blake2b256(pwb.bytes ++ box.bytes)
80-
Longs.fromByteArray((0: Byte) +: h.take(7))
80+
BigInt(1, h)
8181
}
8282

8383
def posIteration(powBlock: PowBlock,

0 commit comments

Comments
 (0)