Skip to content

Commit

Permalink
added peer and latestBlock support for op-node
Browse files Browse the repository at this point in the history
  • Loading branch information
corn-potage committed Sep 6, 2024
1 parent e726c85 commit 3ba7772
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/renderer/Presentational/NodeScreen/NodeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const NodeScreen = () => {
{
rpcTranslation: selectedNode?.spec.rpcTranslation,
httpPort: selectedNode?.config?.configValuesMap?.httpPort,
specId: selectedNode?.spec.specId,
},
{ pollingInterval },
);
Expand All @@ -75,6 +76,7 @@ const NodeScreen = () => {
{
rpcTranslation: selectedNode?.spec.rpcTranslation,
httpPort: selectedNode?.config?.configValuesMap?.httpPort,
specId: selectedNode?.spec.specId,
},
{ pollingInterval },
);
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/state/rpcExecuteTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,19 @@ export const executeTranslation = async ({
}
}
if (rpcCall === 'peers') {
if (specId === 'op-node') {
const resp = await provider.send('opp2p_peers', [true]);
return resp?.totalConnected || 0;
}
const resp = await provider.send('net_peerCount');
if (resp) {
return hexToDecimal(resp);
}
} else if (rpcCall === 'latestBlock') {
if (specId === 'op-node') {
const resp = await provider.send('optimism_syncStatus', []);
return resp?.unsafe_l2.number || 0;
}
const resp = await provider.send('eth_getBlockByNumber', [
'latest',
true,
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/state/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const RtkqExecutionWs: any = createApi({
},
}),
getExecutionPeers: builder.query<ProviderResponse, QueryArg>({
queryFn: async ({ rpcTranslation, httpPort }) => {
queryFn: async ({ rpcTranslation, httpPort, specId }) => {
let data;
// let error;
try {
Expand All @@ -116,6 +116,7 @@ export const RtkqExecutionWs: any = createApi({
rpcCall: 'peers',
rpcTranslation,
httpPort,
specId,
});
console.log('peers data', data);

Expand Down

0 comments on commit 3ba7772

Please sign in to comment.