mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-21 22:11:37 +01:00
chore: max send and receive
This commit is contained in:
parent
22a909b4d9
commit
831bc44fc5
2 changed files with 22 additions and 0 deletions
|
@ -10,6 +10,12 @@ export const ChannelReportType = new GraphQLObjectType({
|
|||
remote: {
|
||||
type: GraphQLInt,
|
||||
},
|
||||
maxIn: {
|
||||
type: GraphQLInt,
|
||||
},
|
||||
maxOut: {
|
||||
type: GraphQLInt,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -25,6 +25,20 @@ export const getChannelReport = {
|
|||
try {
|
||||
const channels: GetChannelsProps = await getChannels({ lnd });
|
||||
|
||||
const maxOutgoing = Math.max.apply(
|
||||
Math,
|
||||
channels.channels.map(o => {
|
||||
return o.local_balance;
|
||||
}),
|
||||
);
|
||||
|
||||
const maxIncoming = Math.max.apply(
|
||||
Math,
|
||||
channels.channels.map(o => {
|
||||
return o.remote_balance;
|
||||
}),
|
||||
);
|
||||
|
||||
const consolidated = channels.channels.reduce((p, c) => {
|
||||
return {
|
||||
remote_balance: p.remote_balance + c.remote_balance,
|
||||
|
@ -35,6 +49,8 @@ export const getChannelReport = {
|
|||
return {
|
||||
local: consolidated.local_balance,
|
||||
remote: consolidated.remote_balance,
|
||||
maxIn: maxIncoming,
|
||||
maxOut: maxOutgoing,
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error('Error getting channel fees: %o', error);
|
||||
|
|
Loading…
Add table
Reference in a new issue