Skip to content

Commit

Permalink
Fixing blocktree storage
Browse files Browse the repository at this point in the history
  • Loading branch information
catena2w committed Jun 6, 2016
1 parent 7efde7e commit 0e33365
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scorex-basics/src/main/scala/scorex/block/Block.scala
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ object Block extends ScorexLogging {

override val versionField: ByteBlockField = ByteBlockField("version", 1)
override val transactionDataField: BlockField[TDT] = transactionModule.genesisData
override val referenceField: BlockIdField = BlockIdField("reference", Array.fill(BlockIdLength)(0: Byte))
override val referenceField: BlockIdField = BlockIdField("reference", Array.fill(BlockIdLength)(-1: Byte))
override val consensusDataField: BlockField[CDT] = consensusModule.genesisData
override val uniqueId: BlockId = Array.fill(BlockIdLength)(0: Byte)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class HistorySynchronizer(application: Application) extends ViewSynchronizer wit
val localScore = history.score()
if (networkScore > localScore) {
log.info(s"networkScore=$networkScore > localScore=$localScore")
val lastIds = history.lastBlocks(100).map(_.uniqueId)
val lastIds = history.lastBlockIds(100)
val msg = Message(GetSignaturesSpec, Right(lastIds), None)
networkControllerRef ! NetworkController.SendToNetwork(msg, SendToChosen(witnesses))
gotoGettingExtension(networkScore, witnesses)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ class StoredBlockTree(dataFolderOpt: Option[String], MaxRollback: Int)
case Success(v) =>
Some(v)
case Failure(e) =>
log.debug("Enable readBlock for key: " + Base58.encode(key))
log.debug("Unable readBlock for key: " + Base58.encode(key))
None
}
}

private val blockStorage: BlockTreePersistence = dataFolderOpt match {
case Some(dataFolder) =>
new File(dataFolder).mkdirs()
val file = new File(dataFolder + "blocktree.mapDB")
val file = new File(dataFolder + "/blocktree.mapDB")
val db = DBMaker.appendFileDB(file).fileMmapEnableIfSupported().closeOnJvmShutdown().checksumEnable().make()
new MapDBBlockTreePersistence(db)
case _ => new MapDBBlockTreePersistence(DBMaker.memoryDB().make())
Expand Down Expand Up @@ -242,7 +242,7 @@ class StoredBlockTree(dataFolderOpt: Option[String], MaxRollback: Int)
case _ => acc
}
}
loop(block, howMany)
loop(block, howMany, Seq(block))
}

override def lastBlocks(howMany: Int): Seq[Block] = {
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/settings-local2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"p2p": {
"fuzzingDelay": 1000,
"nodeName": "Node2",
"localOnly": true,
"bindAddress": "127.0.0.2",
Expand All @@ -23,6 +22,7 @@
],
"maxRollback": 100,
"offlineGeneration": false,
"history": "blocktree",
"perma": {
"treeDir": "/tmp/scorex/data2/tree/",
"authDataStorage": "authDataStorage2.mapDB"
Expand Down

0 comments on commit 0e33365

Please sign in to comment.