add fee report model

This commit is contained in:
Carsten Otto
2021-11-30 13:49:38 +01:00
parent beca0a2aaa
commit e42a106a35
12 changed files with 102 additions and 74 deletions

View File

@@ -126,9 +126,7 @@ public class ChannelController {
}
private FeeReportDto getFeeReportDto(ChannelId channelId) {
Coins earned = feeService.getEarnedFeesForChannel(channelId);
Coins sourced = feeService.getSourcedFeesForChannel(channelId);
return new FeeReportDto(earned, sourced);
return FeeReportDto.createFrom(feeService.getFeeReportForChannel(channelId));
}
private PoliciesDto getPoliciesForChannel(@Nullable LocalChannel channel) {

View File

@@ -110,7 +110,7 @@ public class NodeController {
}
private FeeReportDto getFeeReportDto(Pubkey pubkey) {
return new FeeReportDto(feeService.getEarnedFeesForPeer(pubkey), feeService.getSourcedFeesForPeer(pubkey));
return FeeReportDto.createFrom(feeService.getFeeReportForPeer(pubkey));
}
private List<ChannelId> toSortedList(Set<? extends Channel> channels) {

View File

@@ -1,6 +1,7 @@
package de.cotto.lndmanagej.controller.dto;
import de.cotto.lndmanagej.model.Coins;
import de.cotto.lndmanagej.model.FeeReport;
public record FeeReportDto(String earned, String sourced) {
public FeeReportDto(Coins earned, Coins sourced) {
@@ -9,4 +10,8 @@ public record FeeReportDto(String earned, String sourced) {
String.valueOf(sourced.milliSatoshis())
);
}
public static FeeReportDto createFrom(FeeReport feeReport) {
return new FeeReportDto(feeReport.earned(), feeReport.sourced());
}
}