Skip to content

Commit db204da

Browse files
author
Aurélien Richez
committed
review fixes
rename putBestBlockData to putBestBlockInfo avoid using magic number for block number in test
1 parent e94a518 commit db204da

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

src/it/scala/io/iohk/ethereum/txExecTest/util/DumpChainApp.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ class BlockchainMock(genesisHash: ByteString) extends Blockchain {
196196

197197
def getBestBlockNumber(): BigInt = ???
198198

199-
def saveBestKnownBlocks(bestBlockNumber: BigInt, latestCheckpointNumber: Option[BigInt] = None): Unit = ???
199+
override def saveBestKnownBlocks(
200+
bestBlockhash: ByteString,
201+
bestBlockNumber: BigInt,
202+
latestCheckpointNumber: Option[BigInt] = None
203+
): Unit = ???
200204

201205
def getBestBlock(): Option[Block] = ???
202206

src/main/scala/io/iohk/ethereum/db/storage/AppStateStorage.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AppStateStorage(val dataSource: DataSource) extends TransactionalKeyValueS
3737
getBigInt(Keys.BestBlockNumber)
3838
)
3939

40-
def putBestBlockData(b: BestBlockInfo): DataSourceBatchUpdate =
40+
def putBestBlockInfo(b: BestBlockInfo): DataSourceBatchUpdate =
4141
put(Keys.BestBlockNumber, b.number.toString)
4242
.and(put(Keys.BestBlockHash, Hex.toHexString(b.hash.toArray)))
4343

src/main/scala/io/iohk/ethereum/domain/Blockchain.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ class BlockchainImpl(
144144
}
145145

146146
private def saveBestKnownBlock(bestBlockHash: ByteString, bestBlockNumber: BigInt): Unit =
147-
appStateStorage.putBestBlockData(BestBlockInfo(bestBlockHash, bestBlockNumber)).commit()
147+
appStateStorage.putBestBlockInfo(BestBlockInfo(bestBlockHash, bestBlockNumber)).commit()
148148

149149
private def saveBestKnownBlockAndLatestCheckpointNumber(
150150
bestBlockHash: ByteString,
151151
number: BigInt,
152152
latestCheckpointNumber: BigInt
153153
): Unit =
154154
appStateStorage
155-
.putBestBlockData(BestBlockInfo(bestBlockHash, number))
155+
.putBestBlockInfo(BestBlockInfo(bestBlockHash, number))
156156
.and(appStateStorage.putLatestCheckpointBlockNumber(latestCheckpointNumber))
157157
.commit()
158158

@@ -202,7 +202,7 @@ class BlockchainImpl(
202202
*/
203203
val bestBlockNumberUpdates =
204204
if (appStateStorage.getBestBlockNumber() > potentialNewBestBlockNumber)
205-
appStateStorage.putBestBlockData(BestBlockInfo(potentialNewBestBlockHash, potentialNewBestBlockNumber))
205+
appStateStorage.putBestBlockInfo(BestBlockInfo(potentialNewBestBlockHash, potentialNewBestBlockNumber))
206206
else appStateStorage.emptyBatchUpdate
207207
val latestCheckpointNumberUpdates =
208208
if (appStateStorage.getLatestCheckpointBlockNumber() > newLatestCheckpointNumber)

src/main/scala/io/iohk/ethereum/domain/BlockchainWriter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ class BlockchainWriter(
3232
block.header.number
3333
)
3434
appStateStorage
35-
.putBestBlockData(BestBlockInfo(block.header.hash, block.header.number))
35+
.putBestBlockInfo(BestBlockInfo(block.header.hash, block.header.number))
3636
.and(appStateStorage.putLatestCheckpointBlockNumber(block.header.number))
3737
} else if (saveAsBestBlock) {
3838
log.debug(
3939
"New best known block number - {}",
4040
block.header.number
4141
)
42-
appStateStorage.putBestBlockData(BestBlockInfo(block.header.hash, block.header.number))
42+
appStateStorage.putBestBlockInfo(BestBlockInfo(block.header.hash, block.header.number))
4343
} else {
4444
appStateStorage.emptyBatchUpdate
4545
}

src/test/scala/io/iohk/ethereum/jsonrpc/JsonRpcControllerEthSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ class JsonRpcControllerEthSpec
416416
private val block: Block =
417417
Block(Fixtures.Blocks.Block3125369.header.copy(number = 42), Fixtures.Blocks.Block3125369.body)
418418
blockchainWriter.storeBlock(block).commit()
419-
blockchain.saveBestKnownBlocks(block.hash, 42)
419+
blockchain.saveBestKnownBlocks(block.hash, block.number)
420420

421421
val request: JsonRpcRequest = newJsonRpcRequest("eth_gasPrice")
422422

0 commit comments

Comments
 (0)