Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 572d329

Browse files
Switch from showing number of blocks to approximate time for force closed chan detail.
1 parent 7ba9524 commit 572d329

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/action/channel.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class ChannelAction {
160160
limboBalance: pfcc.limboBalance,
161161
maturityHeight: pfcc.maturityHeight,
162162
blocksTilMaturity: pfcc.blocksTilMaturity,
163+
timeTilAvailable: this._formatTimeTilMaturity(pfcc.blocksTilMaturity),
163164
status: 'pending-force-closing',
164165
}));
165166
const wccs = response.waitingCloseChannels.map(wcc => ({
@@ -346,6 +347,12 @@ class ChannelAction {
346347
const channel = pc.find(c => c.channelPoint === channelPoint);
347348
if (channel) pc.splice(pc.indexOf(channel));
348349
}
350+
351+
_formatTimeTilMaturity(numBlocks) {
352+
const days = Math.floor(numBlocks / (24 * 6));
353+
const hours = Math.floor((numBlocks % (24 * 6)) / 6);
354+
return `${days} days and ${hours} hours`;
355+
}
349356
}
350357

351358
export default ChannelAction;

src/view/channel-detail.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const ChannelDetailView = ({ store, nav }) => (
4343
</DetailField>
4444
) : null}
4545
{store.selectedChannel.blocksTilMaturity ? (
46-
<DetailField name="Blocks Until Maturity">
47-
{store.selectedChannel.blocksTilMaturity}
46+
<DetailField name="Time Til Available">
47+
{store.selectedChannel.timeTilAvailable}
4848
</DetailField>
4949
) : null}
5050
<DetailField name="Remote Node Public Key">

test/unit/action/channel.spec.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ describe('Action Channels Unit Tests', () => {
146146
grpc.sendCommand.withArgs('pendingChannels').resolves({
147147
pendingOpenChannels: [{ channel: { ...pendingChannel } }],
148148
pendingClosingChannels: [{ channel: { ...pendingChannel } }],
149-
pendingForceClosingChannels: [{ channel: { ...pendingChannel } }],
149+
pendingForceClosingChannels: [
150+
{
151+
channel: { ...pendingChannel },
152+
blocksTilMaturity: 463,
153+
},
154+
],
150155
waitingCloseChannels: [{ channel: { ...pendingChannel } }],
151156
totalLimboBalance: 1,
152157
});
@@ -156,6 +161,9 @@ describe('Action Channels Unit Tests', () => {
156161
remotePubkey: 'some-key',
157162
fundingTxId: 'FFFF',
158163
});
164+
expect(store.pendingChannels[2], 'to satisfy', {
165+
timeTilAvailable: '3 days and 5 hours',
166+
});
159167
});
160168

161169
it('should log error on failure', async () => {

0 commit comments

Comments
 (0)