Skip to content

Commit d3c4046

Browse files
committed
fixed epoch
1 parent 85ada5d commit d3c4046

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/main/scala/mvp2/actors/Blockchainer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Blockchainer(settings: Settings) extends PersistentActor with StrictLoggin
7575
blockchain += block
7676
blockCache -= block
7777
planner ! block
78+
logger.info(s"Blockchainer sent new bloch to a planner with height ${block.height}")
7879
informator ! CurrentBlockchainInfo(
7980
blockchain.chain.lastOption.map(block => block.height).getOrElse(0),
8081
blockchain.chain.lastOption,

src/main/scala/mvp2/actors/Planner.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Planner(settings: Settings) extends CommonActor {
3131
var scheduleForWriting: List[ByteString] = List()
3232
var hasWritten: Boolean = false
3333
var needToCheckTimeToPublish: Boolean = true
34+
var isRemoved: Boolean = false
3435

3536
override def specialBehavior: Receive = {
3637
case SyncingDone =>
@@ -61,6 +62,7 @@ class Planner(settings: Settings) extends CommonActor {
6162
nextPeriod = Period(keyBlock, settings)
6263
needToCheckTimeToPublish = true
6364
lastBlock = keyBlock
65+
if (!isRemoved) epoch.dropNextPublisherPublicKey
6466
if (lastBlock.scheduler.nonEmpty) hasWritten = true
6567
logger.info(s"Last block was updated. Height of last block is: ${lastBlock.height}. Period was updated. " +
6668
s"New period is: $nextPeriod.")
@@ -86,13 +88,15 @@ class Planner(settings: Settings) extends CommonActor {
8688
logger.info(s"Current public keys: ${allPublicKeys.map(EncodingUtils.encode2Base16).mkString(",")}")
8789
scheduleForWriting = epoch.schedule
8890
checkMyTurn(scheduleForWriting)
91+
isRemoved = true
8992
case Tick if nextPeriod.timeToPublish && needToCheckTimeToPublish =>
93+
logger.info(s"nextPeriod.timeToPublish. Height of last block is: ${lastBlock.height}")
9094
checkMyTurn(scheduleForWriting)
9195
needToCheckTimeToPublish = false
96+
isRemoved = true
9297
logger.info(s"Current epoch is: $epoch. Height of last block is: ${lastBlock.height}")
9398
logger.info(s"Current public keys: ${allPublicKeys.map(EncodingUtils.encode2Base16).mkString(",")}")
9499
checkScheduleUpdateTime()
95-
logger.info(s"nextPeriod.timeToPublish. Height of last block is: ${lastBlock.height}")
96100
case Tick if nextPeriod.noBlocksInTime =>
97101
logger.info(s"nextPeriod.noBlocksInTime. Height of last block is: ${lastBlock.height}")
98102
//epoch = epoch.dropNextPublisherPublicKey
@@ -104,6 +108,7 @@ class Planner(settings: Settings) extends CommonActor {
104108
context.parent ! nextPeriod
105109
needToCheckTimeToPublish = true
106110
checkScheduleUpdateTime()
111+
isRemoved = true
107112
case Tick =>
108113
logger.info("123")
109114
// logger.info(s"Current epoch is: $epoch. Height of last block is: ${lastBlock.height}")

src/main/scala/mvp2/actors/Zombie.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class Zombie extends CommonActor {
1111
}
1212

1313
override def specialBehavior: Receive = {
14-
case deadMessage: DeadLetter => logger.info(s"Dead letter: ${deadMessage.toString}.")
15-
case unhandled: UnhandledMessage => logger.info(s"Unhandled message ${unhandled.toString}")
14+
case deadMessage: DeadLetter => println(s"Dead letter: ${deadMessage.toString}.")
15+
case unhandled: UnhandledMessage => println(s"Unhandled message ${unhandled.toString}")
1616
}
1717

1818
}

0 commit comments

Comments
 (0)