Skip to content

Commit e83c89d

Browse files
committed
pool+stats: display node tier in the stats bar
1 parent ede5020 commit e83c89d

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

app/src/components/pool/batches/BatchStats.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { observer } from 'mobx-react-lite';
33
import { usePrefixedTranslation } from 'hooks';
44
import { useStore } from 'store';
55
import { BarChart, List } from 'components/base';
6+
import LoaderLines from 'components/common/LoaderLines';
67
import Stat from 'components/common/Stat';
78
import Unit from 'components/common/Unit';
89
import { styled } from 'components/theme';
@@ -19,7 +20,11 @@ const StyledStat = styled.div`
1920
margin: 0 10px;
2021
2122
> div {
22-
font-size: ${props => props.theme.sizes.l};
23+
font-size: ${props => props.theme.sizes.m};
24+
}
25+
26+
> h4 {
27+
font-size: ${props => props.theme.sizes.xxs};
2328
}
2429
}
2530
`;
@@ -48,6 +53,12 @@ const Styled = {
4853
opacity: 1;
4954
}
5055
`,
56+
LoaderLines: styled(LoaderLines)`
57+
.line {
58+
margin: 10px 1px;
59+
height: 10px;
60+
}
61+
`,
5162
};
5263

5364
const BatchStats: React.FC = () => {
@@ -59,7 +70,7 @@ const BatchStats: React.FC = () => {
5970

6071
const tipProps = { tipPlacement: 'bottom', tipCapitalize: false };
6172

62-
const { Wrapper, Stat, BatchCountdown, ViewMode } = Styled;
73+
const { Wrapper, Stat, BatchCountdown, ViewMode, LoaderLines } = Styled;
6374
return (
6475
<Wrapper>
6576
<div>
@@ -90,6 +101,7 @@ const BatchStats: React.FC = () => {
90101
/>
91102
</div>
92103
<div>
104+
<Stat label={l('tier')} value={batchesView.tier || <LoaderLines />} />
93105
<Stat
94106
label={l('earned')}
95107
value={<Unit sats={batchesView.earnedSats} suffix={false} />}

app/src/i18n/locales/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
"cmps.pool.batches.BatchStats.prevRateTip": "The rate cleared in the previous batch ({{fixedRate}} per block)",
157157
"cmps.pool.batches.BatchStats.rateChange": "Change",
158158
"cmps.pool.batches.BatchStats.rateChangeTip": "The percentage change in rate between the previous batch and the one prior",
159+
"cmps.pool.batches.BatchStats.tier": "Node Tier",
159160
"cmps.pool.batches.BatchStats.earned": "Earned",
160161
"cmps.pool.batches.BatchStats.paid": "Paid",
161162
"cmps.pool.orders.OrdersList.emptyMsg": "You do not have any {{filter}} orders.",

app/src/store/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export class Store {
106106
async init() {
107107
this.settingsStore.init();
108108
this.swapStore.init();
109+
this.batchStore.init();
109110
await this.authStore.init();
110111
runInAction(() => {
111112
this.initialized = true;

app/src/store/views/batchesView.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { makeAutoObservable } from 'mobx';
2+
import { NodeTier } from 'types/generated/auctioneer_pb';
23
import { toPercent } from 'util/bigmath';
34
import { Store } from 'store';
45

@@ -51,6 +52,19 @@ export default class BatchesView {
5152
return this.batches.length ? this.batches[0].feeLabel : 0;
5253
}
5354

55+
/** the tier of the current LND node as a user-friendly string */
56+
get tier() {
57+
switch (this._store.batchStore.nodeTier) {
58+
case NodeTier.TIER_1:
59+
return 'T1';
60+
case NodeTier.TIER_0:
61+
case NodeTier.TIER_DEFAULT:
62+
return 'T0';
63+
default:
64+
return '';
65+
}
66+
}
67+
5468
/** that amount earned from sold leases */
5569
get earnedSats() {
5670
return this._store.orderStore.earnedSats;

app/src/util/tests/sampleData.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,15 @@ export const poolNextBatchInfo: POOL.NextBatchInfoResponse.AsObject = {
599599
feeRateSatPerKw: 12500,
600600
};
601601

602+
export const poolNodeRatings: POOL.NodeRatingResponse.AsObject = {
603+
nodeRatingsList: [
604+
{
605+
nodePubkey: b64(lndGetInfo.identityPubkey),
606+
nodeTier: AUCT.NodeTier.TIER_1,
607+
},
608+
],
609+
};
610+
602611
const stringToChannelPoint = (cp: string) => ({
603612
txid: b64(cp.split(':')[0], true),
604613
outputIndex: parseInt(cp.split(':')[1]),
@@ -713,5 +722,6 @@ export const sampleApiResponses: Record<string, any> = {
713722
'poolrpc.Trader.BatchSnapshot': poolBatchSnapshot,
714723
'poolrpc.Trader.BatchSnapshots': poolBatchSnapshots,
715724
'poolrpc.Trader.NextBatchInfo': poolNextBatchInfo,
725+
'poolrpc.Trader.NodeRatings': poolNodeRatings,
716726
'poolrpc.Trader.Leases': poolLeases,
717727
};

0 commit comments

Comments
 (0)