Skip to content

Commit

Permalink
chore(ln): add sync warning to ln common client getinfo response
Browse files Browse the repository at this point in the history
  • Loading branch information
theborakompanioni committed Dec 2, 2023
1 parent aa03279 commit e537ea5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.util.HexFormat;
import java.util.List;
import java.util.Optional;

/**
* See: <a href="https://docs.corelightning.org/reference">CLN API Docs</a>
Expand Down Expand Up @@ -41,6 +42,10 @@ public Mono<CommonInfoResponse> info(CommonInfoRequest request) {
.setNetwork(response.getNetwork())
.build())
.setBlockheight(response.getBlockheight())
.setWarningBlockSync(Optional.of(response.getWarningBitcoindSync())
.filter(it -> !it.isBlank())
.or(() -> Optional.of(response.getWarningLightningdSync()).filter(it -> !it.isBlank()))
.orElse(""))
.build();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ message CommonInfoResponse {
// A list of active chains the node is connected to
repeated Chain chain = 9 [json_name = "chains"];
uint32 blockheight = 10 [json_name = "blockheight"];
// a warning if either bitcoin or lightning node is not yet synced to chain; can be empty.
string warning_block_sync = 11 [json_name = "warning_block_sync"];
}

message Chain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public Mono<CommonInfoResponse> info(CommonInfoRequest request) {
.build())
.toList())
.setBlockheight(response.getBlockHeight())
.setWarningBlockSync(response.getSyncedToChain() ? "" : "Node is not synced to chain")
.build();
});
}
Expand Down

0 comments on commit e537ea5

Please sign in to comment.