Explorer: display message when block rewards not found for interval (#17943)
* fix: disable block not found error message and give feedback for rewards not found * feat: add lowest available epochs for rewards * feat: make sure current epoch is not fetched
This commit is contained in:
@ -61,8 +61,8 @@ export function RewardsCard({ pubkey }: { pubkey: PublicKey }) {
|
|||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
const rewardsFound = rewardsList.some((r) => r);
|
||||||
const { foundOldest } = rewards.data;
|
const { foundOldest, lowestFetchedEpoch, highestFetchedEpoch } = rewards.data;
|
||||||
const fetching = rewards.status === FetchStatus.Fetching;
|
const fetching = rewards.status === FetchStatus.Fetching;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -76,6 +76,7 @@ export function RewardsCard({ pubkey }: { pubkey: PublicKey }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{rewardsFound ? (
|
||||||
<div className="table-responsive mb-0">
|
<div className="table-responsive mb-0">
|
||||||
<table className="table table-sm table-nowrap card-table">
|
<table className="table table-sm table-nowrap card-table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -89,6 +90,12 @@ export function RewardsCard({ pubkey }: { pubkey: PublicKey }) {
|
|||||||
<tbody className="list">{rewardsList}</tbody>
|
<tbody className="list">{rewardsList}</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="card-body">
|
||||||
|
No rewards issued between epochs {lowestFetchedEpoch} and{" "}
|
||||||
|
{highestFetchedEpoch}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="card-footer">
|
<div className="card-footer">
|
||||||
{foundOldest ? (
|
{foundOldest ? (
|
||||||
|
@ -6,6 +6,11 @@ import { ActionType } from "providers/block";
|
|||||||
import { FetchStatus } from "providers/cache";
|
import { FetchStatus } from "providers/cache";
|
||||||
import { reportError } from "utils/sentry";
|
import { reportError } from "utils/sentry";
|
||||||
|
|
||||||
|
const REWARDS_AVAILABLE_EPOCH = new Map<Cluster, number>([
|
||||||
|
[Cluster.MainnetBeta, 132],
|
||||||
|
[Cluster.Testnet, 43],
|
||||||
|
]);
|
||||||
|
|
||||||
const PAGE_SIZE = 15;
|
const PAGE_SIZE = 15;
|
||||||
|
|
||||||
export type Rewards = {
|
export type Rewards = {
|
||||||
@ -17,6 +22,8 @@ export type Rewards = {
|
|||||||
|
|
||||||
export type RewardsUpdate = {
|
export type RewardsUpdate = {
|
||||||
rewards: (InflationReward | null)[];
|
rewards: (InflationReward | null)[];
|
||||||
|
highestFetchedEpoch: number;
|
||||||
|
lowestFetchedEpoch: number;
|
||||||
foundOldest?: boolean;
|
foundOldest?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,8 +46,9 @@ function reconcile(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
rewards: combined,
|
rewards: combined,
|
||||||
highestFetchedEpoch: combined[0]?.epoch,
|
highestFetchedEpoch:
|
||||||
lowestFetchedEpoch: combined[combined.length - 1]?.epoch,
|
rewards?.highestFetchedEpoch || update.highestFetchedEpoch,
|
||||||
|
lowestFetchedEpoch: update.lowestFetchedEpoch,
|
||||||
foundOldest,
|
foundOldest,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -84,12 +92,9 @@ async function fetchRewards(
|
|||||||
url,
|
url,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const lowestAvailableEpoch = REWARDS_AVAILABLE_EPOCH.get(cluster) || 0;
|
||||||
const connection = new Connection(url);
|
const connection = new Connection(url);
|
||||||
|
|
||||||
if (!fromEpoch && highestEpoch) {
|
|
||||||
fromEpoch = highestEpoch;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fromEpoch) {
|
if (!fromEpoch) {
|
||||||
try {
|
try {
|
||||||
const epochInfo = await connection.getEpochInfo();
|
const epochInfo = await connection.getEpochInfo();
|
||||||
@ -106,6 +111,10 @@ async function fetchRewards(
|
|||||||
url,
|
url,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (highestEpoch && highestEpoch < fromEpoch) {
|
||||||
|
fromEpoch = highestEpoch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getInflationReward = async (epoch: number) => {
|
const getInflationReward = async (epoch: number) => {
|
||||||
@ -128,7 +137,7 @@ async function fetchRewards(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const results = await Promise.all(requests);
|
const results = await Promise.all(requests);
|
||||||
fromEpoch = fromEpoch - requests.length;
|
const lowestFetchedEpoch = fromEpoch - requests.length;
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ActionType.Update,
|
type: ActionType.Update,
|
||||||
@ -137,7 +146,9 @@ async function fetchRewards(
|
|||||||
status: FetchStatus.Fetched,
|
status: FetchStatus.Fetched,
|
||||||
data: {
|
data: {
|
||||||
rewards: results || [],
|
rewards: results || [],
|
||||||
foundOldest: fromEpoch <= 0,
|
foundOldest: lowestFetchedEpoch <= lowestAvailableEpoch,
|
||||||
|
highestFetchedEpoch: fromEpoch,
|
||||||
|
lowestFetchedEpoch,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user