Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to ipfs-geoip v9 #2061

Merged
merged 15 commits into from
Nov 9, 2022
176 changes: 143 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"intl-messageformat": "^9.11.3",
"ip": "^1.1.5",
"ipfs-css": "^1.4.0",
"ipfs-geoip": "^8.0.0",
"ipfs-geoip": "^9.0.0",
"ipfs-http-client": "49.0.2",
"ipfs-provider": "^2.1.0",
"ipld-explorer-components": "^2.4.1",
Expand Down
10 changes: 4 additions & 6 deletions src/bundles/peer-locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ function createPeersLocations (opts) {
const bundle = createAsyncResourceBundle({
name: 'peerLocations',
actionBaseType: 'PEER_LOCATIONS',
getPromise: async ({ store, getIpfs }) => {
const peers = store.selectPeers()
return peerLocResolver.findLocations(peers, getIpfs)
},
getPromise: ({ store }) => peerLocResolver.findLocations(
store.selectAvailableGatewayUrl(), store.selectPeers()),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now we can just pull the list the gateway urls active and pass the peers.

staleAfter: UPDATE_EVERY,
retryAfter: UPDATE_EVERY,
persist: false,
Expand Down Expand Up @@ -227,7 +225,7 @@ class PeerLocationResolver {
this.pass = 0
}

async findLocations (peers, getIpfs) {
async findLocations (gatewayUrls, peers) {
const res = {}

for (const p of this.optimizedPeerSet(peers)) {
Expand Down Expand Up @@ -257,7 +255,7 @@ class PeerLocationResolver {

this.geoipLookupPromises.set(ipv4Addr, this.queue.add(async () => {
try {
const data = await geoip.lookup(getIpfs(), ipv4Addr)
const data = await geoip.lookup(gatewayUrls, ipv4Addr)
await this.geoipCache.set(ipv4Addr, data)
} catch (e) {
// mark this one as failed so we don't retry again
Expand Down
2 changes: 1 addition & 1 deletion src/peers/PeersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import AddConnection from './AddConnection/AddConnection'
import CliTutorMode from '../components/cli-tutor-mode/CliTutorMode'
import { cliCmdKeys, cliCommandList } from '../bundles/files/consts'

const PeersPage = ({ t, toursEnabled, handleJoyrideCallback, isCliTutorModeEnabled }) => (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused assignment.

const PeersPage = ({ t, toursEnabled, handleJoyrideCallback }) => (
<div data-id='PeersPage' className='overflow-hidden'>
<Helmet>
<title>{t('title')} | IPFS</title>
Expand Down