Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

List offline validators

node v14.20.1
version: 1.0.0
endpointsharetweet
const axios = require('axios') exports.endpoint = async (request, response) => { const d = await axios.get('https://api.xrpscan.com/api/v1/validatorregistry') const mapped = d.data.filter(r => r.chain === 'main' && r.unl && r.unl.length > 0).map(r => { return { domain: r.domain || r.domain_legacy, last_seen: Math.abs((Number(new Date(r.last_seen)) - Number(new Date())) / 1000) } }) const offlineValidators = mapped.filter(d => d.last_seen > 6).map(d => d.domain) response.end(JSON.stringify({ offlineValidators, onlineValidators: mapped.filter(m => offlineValidators.indexOf(m.domain) < 0).map(d => d.domain) })) }
Loading…

no comments

    sign in to comment