Skip to content

Commit b67d267

Browse files
committed
Some additions + new logging
1 parent a18152b commit b67d267

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class Planner(settings: Settings) extends CommonActor {
119119
s"${schedule.map(EncodingUtils.encode2Base16).mkString(",")}")
120120
publisher ! RequestForNewBlock(epoch.full, schedule)
121121
epoch = epoch.dropNextPublisherPublicKey
122+
nextPeriod = Period(nextPeriod, settings)
122123
}
123124
logger.info(s"${epoch.full} && ${lastBlock.height}")
124125
logger.info(s"Epoch after checkMyTurn is: $epoch")

src/main/scala/mvp2/data/Block.scala

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,33 @@ object KeyBlock {
4949
new KeyBlock(height, timestamp, previousKeyBlockHash, currentBlockHash, transactions, data, signature, scheduler, publicKey)
5050
}
5151

52-
def toProtobuf(block: KeyBlock): KeyBlockProtobuf = KeyBlockProtobuf()
53-
.withCurrentBlockHash(pByteString.copyFrom(block.currentBlockHash.toByteBuffer))
54-
.withHeight(block.height)
55-
.withTimestamp(block.timestamp)
56-
.withTransactions(block.transactions.map(Transaction.toProtobuf))
57-
.withData(pByteString.copyFrom(block.data.toByteBuffer))
58-
.withSignature(pByteString.copyFrom(block.signature.toByteBuffer))
59-
.withScheduler(block.scheduler.map(publicKey => pByteString.copyFrom(publicKey.toByteBuffer)))
60-
.withPreviousKeyBlockHash(pByteString.copyFrom(block.previousKeyBlockHash.toByteBuffer))
61-
.withPublicKey(pByteString.copyFrom(block.publicKey.toByteBuffer))
52+
def toProtobuf(block: KeyBlock): KeyBlockProtobuf = {
53+
KeyBlockProtobuf()
54+
.withCurrentBlockHash(pByteString.copyFrom(block.currentBlockHash.toByteBuffer))
55+
.withHeight(block.height)
56+
.withTimestamp(block.timestamp)
57+
.withTransactions(block.transactions.map(Transaction.toProtobuf))
58+
.withData(pByteString.copyFrom(block.data.toByteBuffer))
59+
.withSignature(pByteString.copyFrom(block.signature.toByteBuffer))
60+
.withScheduler(block.scheduler.map(publicKey => pByteString.copyFrom(publicKey.toByteBuffer)))
61+
.withPreviousKeyBlockHash(pByteString.copyFrom(block.previousKeyBlockHash.toByteBuffer))
62+
.withPublicKey(pByteString.copyFrom(block.publicKey.toByteBuffer))
63+
}
6264

6365

64-
def fromProtobuf(blockProtobuf: KeyBlockProtobuf): KeyBlock = KeyBlock(
65-
blockProtobuf.height,
66-
blockProtobuf.timestamp,
67-
ByteString(blockProtobuf.previousKeyBlockHash.toByteArray),
68-
ByteString(blockProtobuf.currentBlockHash.toByteArray),
69-
blockProtobuf.transactions.map(Transaction.fromProtobuf).toList,
70-
ByteString(blockProtobuf.data.toByteArray),
71-
ByteString(blockProtobuf.signature.toByteArray),
72-
blockProtobuf.scheduler.map(protKey => ByteString(protKey.toByteArray)).toList,
73-
ByteString(blockProtobuf.publicKey.toByteArray)
74-
)
66+
def fromProtobuf(blockProtobuf: KeyBlockProtobuf): KeyBlock = {
67+
KeyBlock(
68+
blockProtobuf.height,
69+
blockProtobuf.timestamp,
70+
ByteString(blockProtobuf.previousKeyBlockHash.toByteArray),
71+
ByteString(blockProtobuf.currentBlockHash.toByteArray),
72+
blockProtobuf.transactions.map(Transaction.fromProtobuf).toList,
73+
ByteString(blockProtobuf.data.toByteArray),
74+
ByteString(blockProtobuf.signature.toByteArray),
75+
blockProtobuf.scheduler.map(protKey => ByteString(protKey.toByteArray)).toList,
76+
ByteString(blockProtobuf.publicKey.toByteArray)
77+
)
78+
}
7579
}
7680

7781
final case class MicroBlock(height: Long,

0 commit comments

Comments
 (0)