Package com.privatechain.spring
Class BlockchainProperties
java.lang.Object
com.privatechain.spring.BlockchainProperties
Configuration properties for the private-blockchain Spring Boot autoconfiguration.
All properties are bound to the blockchain.* prefix in
application.yml / application.properties. Every field has a
production-ready default so that zero configuration is required to start a working
in-memory PoW chain (FR-CFG-02, AC-10).
Minimal YAML
blockchain:
enabled: true # default; omit to keep the node active
Full YAML reference
blockchain:
enabled: true
chain-id: my-chain
network-port: 8545
block-time-seconds: 10
difficulty: 4
max-peers: 25
mempool:
ttl: 30m # Duration — supports 30m, PT30M, 1800s, etc.
max-size: 10000
IDE autocomplete for all properties is generated at compile time by the
spring-boot-configuration-processor annotation processor, which produces
META-INF/spring-configuration-metadata.json (T-071).
- Since:
- 1.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMempool configuration properties, bound toblockchain.mempool.*. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the target block time in seconds.Returns the chain identifier embedded in the genesis block.intReturns the Proof-of-Work difficulty (leading zero bit count).intReturns the maximum number of simultaneous peer connections.Returns the mempool configuration.intReturns the TCP port for the P2P node server.booleanReturns whether blockchain autoconfiguration is enabled.voidsetBlockTimeSeconds(int blockTimeSeconds) Sets the target block time in seconds.voidsetChainId(String chainId) Sets the chain identifier.voidsetDifficulty(int difficulty) Sets the Proof-of-Work difficulty.voidsetEnabled(boolean enabled) Sets whether blockchain autoconfiguration is enabled.voidsetMaxPeers(int maxPeers) Sets the maximum number of simultaneous peer connections.voidsetMempool(BlockchainProperties.Mempool mempool) Sets the mempool configuration.voidsetNetworkPort(int networkPort) Sets the TCP port for the P2P node server.
-
Constructor Details
-
BlockchainProperties
public BlockchainProperties()
-
-
Method Details
-
isEnabled
public boolean isEnabled()Returns whether blockchain autoconfiguration is enabled.- Returns:
trueif theBlockchainNodebean should be created
-
setEnabled
public void setEnabled(boolean enabled) Sets whether blockchain autoconfiguration is enabled.- Parameters:
enabled-falseto suppressBlockchainNodebean creation
-
getChainId
Returns the chain identifier embedded in the genesis block.- Returns:
- non-null, non-blank chain ID
-
setChainId
Sets the chain identifier.- Parameters:
chainId- non-null, non-blank identifier- Throws:
NullPointerException- ifchainIdis null
-
getNetworkPort
public int getNetworkPort()Returns the TCP port for the P2P node server.- Returns:
- port number in [1024, 65535]
-
setNetworkPort
public void setNetworkPort(int networkPort) Sets the TCP port for the P2P node server.- Parameters:
networkPort- port number in [1024, 65535]
-
getBlockTimeSeconds
public int getBlockTimeSeconds()Returns the target block time in seconds.- Returns:
- block time (≥ 1)
-
setBlockTimeSeconds
public void setBlockTimeSeconds(int blockTimeSeconds) Sets the target block time in seconds.- Parameters:
blockTimeSeconds- block time (≥ 1)
-
getDifficulty
public int getDifficulty()Returns the Proof-of-Work difficulty (leading zero bit count).- Returns:
- difficulty (≥ 1)
-
setDifficulty
public void setDifficulty(int difficulty) Sets the Proof-of-Work difficulty.- Parameters:
difficulty- leading zero bit count (≥ 1)
-
getMaxPeers
public int getMaxPeers()Returns the maximum number of simultaneous peer connections.- Returns:
- max peers (≥ 1)
-
setMaxPeers
public void setMaxPeers(int maxPeers) Sets the maximum number of simultaneous peer connections.- Parameters:
maxPeers- max peers (≥ 1)
-
getMempool
Returns the mempool configuration.- Returns:
- non-null
BlockchainProperties.Mempoolproperties
-
setMempool
Sets the mempool configuration.- Parameters:
mempool- non-null mempool properties- Throws:
NullPointerException- ifmempoolis null
-