Skip to content

Commit

Permalink
Make some BakerPoolStatus fields optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Radiokot committed Aug 28, 2024
1 parent d1467a0 commit 597563c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- Added `ProtocolVersion.V7` corresponding to Protocol version 7
- Added `cooldowns` list to `AccountInfo`
- Added `availableBalance` to `AccountInfo`
- Made optional the following `BakerPoolStatus` fields:
`bakerEquityCapital`, `delegatedCapital`, `delegatedCapitalCap`, `poolInfo`

## 7.2.0
- Added `MessageSigningDigest` class to generate digests for message signing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1243,14 +1243,24 @@ static BakerPoolStatus to(PoolInfoResponse grpcOutput) {
return BakerPoolStatus.builder()
.bakerId(to(grpcOutput.getBaker()))
.bakerAddress(to(grpcOutput.getAddress()))
.bakerEquityCapital(to(grpcOutput.getEquityCapital()))
.delegatedCapital(to(grpcOutput.getDelegatedCapital()))
.delegatedCapitalCap(to(grpcOutput.getDelegatedCapitalCap()))
.poolInfo(to(grpcOutput.getPoolInfo()))
.bakerEquityCapital(grpcOutput.hasEquityCapital()
? to(grpcOutput.getEquityCapital())
: null)
.delegatedCapital(grpcOutput.hasDelegatedCapital()
? to(grpcOutput.getDelegatedCapital())
: null)
.delegatedCapitalCap(grpcOutput.hasDelegatedCapitalCap()
? to(grpcOutput.getDelegatedCapitalCap())
: null)
.poolInfo(grpcOutput.hasPoolInfo()
? to(grpcOutput.getPoolInfo())
: null)
.bakerStakePendingChange(grpcOutput.hasEquityPendingChange()
? to(grpcOutput.getEquityPendingChange())
: null)
.currentPaydayStatus(grpcOutput.hasCurrentPaydayInfo() ? to(grpcOutput.getCurrentPaydayInfo()) : null)
.currentPaydayStatus(grpcOutput.hasCurrentPaydayInfo()
? to(grpcOutput.getCurrentPaydayInfo())
: null)
.allPoolTotalCapital(to(grpcOutput.getAllPoolTotalCapital()))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class BakerPoolStatus {

/**
* Any pending change to the baker's stake.
* This is not used from protocol version 7 onwards, as stake changes are immediate.
*/
private final PendingChange bakerStakePendingChange;

Expand All @@ -60,6 +61,22 @@ public class BakerPoolStatus {
*/
private final CCDAmount allPoolTotalCapital;

public Optional<CCDAmount> getBakerEquityCapital() {
return Optional.ofNullable(bakerEquityCapital);
}

public Optional<CCDAmount> getDelegatedCapital() {
return Optional.ofNullable(delegatedCapital);
}

public Optional<CCDAmount> getDelegatedCapitalCap() {
return Optional.ofNullable(delegatedCapitalCap);
}

public Optional<BakerPoolInfo> getPoolInfo() {
return Optional.ofNullable(poolInfo);
}

public Optional<PendingChange> getBakerStakePendingChange() {
return Optional.ofNullable(bakerStakePendingChange);
}
Expand Down

0 comments on commit 597563c

Please sign in to comment.