-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a page that shows the network's version infos
- Loading branch information
1 parent
4c2d7f5
commit 84c1472
Showing
7 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
import * as sol from '@solana/web3.js'; | ||
import { netToURL } from '../common/strings'; | ||
import { NodeInfo, ValidatorNetworkInfoRequest, ValidatorNetworkInfoResponse } from '../types/types'; | ||
|
||
const fetchValidatorNetworkInfo = async (msg: ValidatorNetworkInfoRequest) => { | ||
const url = netToURL(msg.net); | ||
const solConn = new sol.Connection(url); | ||
const contactInfo = await solConn.getClusterNodes(); | ||
const nodeVersion = await solConn.getVersion(); | ||
|
||
const nodeInfos: NodeInfo[] = contactInfo.map( | ||
(info: sol.ContactInfo) => { | ||
const newInfo: NodeInfo = { | ||
pubkey: info.pubkey, | ||
version: info.version, | ||
rpc: info.rpc, | ||
gossip: info.gossip, | ||
// featureSet: info.featureSet, | ||
// shredVersion: info.shredVersion, | ||
}; | ||
|
||
return newInfo; | ||
}); | ||
|
||
let response: ValidatorNetworkInfoResponse = { | ||
nodes: nodeInfos, | ||
version: nodeVersion['solana-core'], | ||
} | ||
|
||
return response; | ||
}; | ||
|
||
export default fetchValidatorNetworkInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { RootState } from 'renderer/slices/mainSlice'; | ||
import { ValidatorNetworkInfoResponse } from '../../types/types'; | ||
|
||
import 'react-bootstrap-table-next/dist/react-bootstrap-table2.min.css'; | ||
import 'react-bootstrap-table2-paginator/dist/react-bootstrap-table2-paginator.min.css'; | ||
import BootstrapTable from 'react-bootstrap-table-next'; | ||
import paginationFactory from 'react-bootstrap-table2-paginator'; | ||
|
||
const ValidatorNetworkInfo = () => { | ||
const validator = useSelector((state: RootState) => state.validator); | ||
|
||
const columns = [ | ||
{ | ||
text: 'Pub Key', | ||
dataField: 'pubkey', | ||
}, | ||
{ | ||
text: 'Version', | ||
dataField: 'version', | ||
}, | ||
]; | ||
|
||
const [data, setData] = useState<ValidatorNetworkInfoResponse>({ | ||
version: "unknown", | ||
nodes: [] | ||
}); | ||
|
||
useEffect(() => { | ||
const { net } = validator; | ||
window.electron.ipcRenderer.fetchValidatorNetworkInfo({ | ||
net: net, | ||
}); | ||
}, [validator]); | ||
|
||
useEffect(() => { | ||
const listener = (resp: any) => { | ||
const { method, res } = resp; | ||
|
||
switch (method) { | ||
case 'get-validator-network-info': | ||
console.log('ValidatorNetworkInfo', { res }); | ||
if (res) { | ||
setData(res); | ||
} | ||
break; | ||
default: | ||
} | ||
}; | ||
window.electron.ipcRenderer.on('main', listener); | ||
return () => { | ||
window.electron.ipcRenderer.removeListener('main', listener); | ||
}; | ||
}, []); | ||
|
||
|
||
// TODO: maybe show te version spread as a histogram and feature info ala | ||
// solana --url mainnet-beta feature status | ||
return ( | ||
<div className="col"> | ||
<div className="row"> | ||
<span className='column'>Current Network: {validator.net}</span> | ||
<span className='column'>Current Version: {data.version}</span> | ||
</div> | ||
<div className="row"> | ||
<BootstrapTable keyField='id' | ||
data={data.nodes} | ||
columns={columns} | ||
pagination={paginationFactory({ | ||
paginationSize: 25, | ||
})} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ValidatorNetworkInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters