1. Introduction
...
crcPath
is used to store the CRC of the on-disk storage file. As CRC is a linear function, it is possible to recompute CRC after changing a part of the file by xoring the old value of CRC with the old part of the file and the new part of the file (i.e. newCrc = oldCrc ⊕ crc(oldPart) ⊕ crc(newPart)
). The file can be updated atomically by writing the new CRC value to a temporary file and replacing the old CRC file with a new one since renaming is an atomic operation. CRC file is used to detect corrupted data after a system crash.
...
As both publickey and blockhash are invariable in size, the proposed method of storing latest messages data structure on disk is to consequently write out the publickey-blockhash pairs byte-by-byte (i.e. 32 bytes of publickey followed by 32 bytes of blockhash).
This data will be stored in the file specified by LatestMessagesFileStorage.Config.dataPath
and the CRC value will be stored in the file specified by LatestMessagesFileStorage.Config.crcPath.
The configuration for latest messages storage will be added to the existing node configuration coop.rchain.node.configuration.Configuration:
Code Block | ||||
---|---|---|---|---|
| ||||
final class Configuration(
val command: Command,
val server: Server,
val grpcServer: GrpcServer,
val tls: Tls,
val casper: CasperConf,
val blockstorage: LMDBBlockStore.Config,
val latestMessagesStorage: LatestMessagesFileStorage.Config,
private val options: commandline.Options
) |
The default value for latestMessagesStorage
is defined by using dataDir
(which defaults to $HOME/.rnode
) as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
val latestMessagesStorage = LatestMessagesFileStorage.Config(
dataDir.resolve("casper-latest-messages-file-storage"),
dataDir.resolve("casper-latest-messages-crc")
) |
The default values can be redefined by adding the following command-line options to coop.rchain.node.configuration.commandline.Options
:
Code Block | ||||
---|---|---|---|---|
| ||||
val casperLatestMessagesData =
opt[Path](required = false, descr = "Path to latest messages data file") // --casper-latest-messages-data
val casperLatestMessagesCrc =
opt[Path](required = false, descr = "Path to latest messages crc file") // --casper-latest-messages-crc |
LatestMessagesFileStorage
will be initialized in NodeRuntime.main
using the provided configuration. As SafetyOracle
depends on latest messages data structure, it will have to be initialized after LatestMessagesFileStorage
.
3.5 Global software control
...