hiero-ledger / hiero-ledger/hiero-consensus-node
Possibly consolidate SingletonState(s) to a single KVStore pair
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
### Problem
We have a number of single values that must be stored in state (e.g. a single hash). These are often stored in SingletonState via an entire ReadableStore/WritableStore combination.
This appears to be excessive and creates added code and maintenance that is not strictly necessary.
### Solution
There may be value in consolidating these singular values into a single Store implementation that implements multiple interfaces defined by the various services (much as SingleTransactionRecordBuilderImpl does) to reduce the repeated code and simplify the maintenance of singleton values.
Example
```java
public class SingletonReadableStore implements StakingRewardsStore, UpgradeHashStore, RunningLeafHashStore {
@Override
@NonNull
public Bytes updateFileHash() {...}
@Override
@NonNull
public Hash getRunningHash() {...}
@Override
@NonNull
public Hash getNMinusThreeRunningHash() {...}
@Override
@NonNull
public NetworkStakingRewards getStakingRewards() {...}
@Override
@NonNull
public boolean isStakingRewardsActivated() {...}
@Override
@NonNull
public long pendingStakingRewards() {...}
@Override
@NonNull
public long totalStakeRewardStart() {...}
@Override
@NonNull
public long totalStakedStart() {...}
}
```
### Alternatives
continue with the current practice of creating a new ReadbleStore and WritableStore pair for each individual singleton value, possibly creating a new VirtualMap for each individual value as well.
Contributor guide
Assessment
This issue has not been assessed yet.