pretty-print channels

This commit is contained in:
Carsten Otto
2021-11-12 16:30:36 +01:00
parent bc55943f9d
commit def458ebbb
5 changed files with 56 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Comparator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -65,6 +66,20 @@ public class LegacyController {
.collect(Collectors.joining(NEWLINE));
}
@GetMapping("/open-channels/pretty")
public String getOpenChannelIdsPretty() {
return channelService.getOpenChannels().stream()
.sorted(Comparator.comparing(LocalChannel::getId))
.map(localChannel -> {
Pubkey pubkey = localChannel.getRemotePubkey();
return localChannel.getId().getCompactForm() +
"\t" + pubkey +
"\t" + localChannel.getCapacity() +
"\t" + nodeService.getAlias(pubkey);
})
.collect(Collectors.joining(NEWLINE));
}
@GetMapping("/peer-pubkeys")
public String getPeerPubkeys() {
return channelService.getOpenChannels().stream()