ipfs-locations
This lets you poll locations from IPFS very easily. This is used by ipfs-stats
to manage hundreds of location lookups. It looks up locations sequentially to improve the performance and avoid too many requests at once.
Install
In Node.js through npm
$ npm install --save ipfs-locations
Browser: Browserify, Webpack, other bundlers
The code published to npm that gets loaded on require is in fact an ES5 transpiled version with the right shims added. This means that you can require it and use with your favorite bundler without having to adjust asset management process.
const LocationsPoller =
<script>
tag
In the Browser through Loading this module through a script tag will make the IpfsLocations
obj available in the global namespace.
<script src="https://unpkg.com/ipfs-locations/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/ipfs-locations/dist/index.js"></script>
API
LocationsPoller
Class new LocationsPoller(ipfs)
ipfs
Object. IPFS API Object.
Methods
locations.get(addr)
obtains the location for a certain address. It will return a Promise.locations.getImmediate(addr)
does the same as the previous but returns immediatelly. If there is no value in cache, returns a location with 'Unknown'.