Search in sources :

Example 1 with BlockchainProcessor

use of org.xel.BlockchainProcessor in project elastic-core-maven by OrdinaryDude.

the class GetBlockchainStatus method processRequest.

@Override
protected JSONObject processRequest(HttpServletRequest req) {
    JSONObject response = new JSONObject();
    response.put("application", Nxt.APPLICATION);
    response.put("version", Nxt.VERSION);
    response.put("time", Nxt.getEpochTime());
    Block lastBlock = Nxt.getBlockchain().getLastBlock();
    response.put("lastBlock", lastBlock.getStringId());
    response.put("cumulativeDifficulty", lastBlock.getCumulativeDifficulty().toString());
    response.put("numberOfBlocks", lastBlock.getHeight() + 1);
    BlockchainProcessor blockchainProcessor = Nxt.getBlockchainProcessor();
    Peer lastBlockchainFeeder = blockchainProcessor.getLastBlockchainFeeder();
    response.put("lastBlockchainFeeder", lastBlockchainFeeder == null ? null : lastBlockchainFeeder.getAnnouncedAddress());
    response.put("lastBlockchainFeederHeight", blockchainProcessor.getLastBlockchainFeederHeight());
    response.put("isScanning", blockchainProcessor.isScanning());
    response.put("isDownloading", blockchainProcessor.isDownloading());
    response.put("maxRollback", Constants.MAX_ROLLBACK);
    response.put("currentMinRollbackHeight", Nxt.getBlockchainProcessor().getMinRollbackHeight());
    response.put("isTestnet", Constants.isTestnet);
    response.put("maxPrunableLifetime", Constants.MAX_PRUNABLE_LIFETIME);
    response.put("includeExpiredPrunable", Constants.INCLUDE_EXPIRED_PRUNABLE);
    response.put("correctInvalidFees", Constants.correctInvalidFees);
    response.put("ledgerTrimKeep", AccountLedger.trimKeep);
    JSONArray servicesArray = new JSONArray();
    Peers.getServices().forEach(service -> servicesArray.add(service.name()));
    response.put("services", servicesArray);
    if (APIProxy.isActivated()) {
        String servingPeer = APIProxy.getInstance().getMainPeerAnnouncedAddress();
        response.put("apiProxy", true);
        response.put("apiProxyPeer", servingPeer);
    } else {
        response.put("apiProxy", false);
    }
    response.put("isLightClient", Constants.isLightClient);
    response.put("maxAPIRecords", API.maxRecords);
    response.put("blockchainState", Peers.getMyBlockchainState());
    return response;
}
Also used : JSONObject(org.json.simple.JSONObject) BlockchainProcessor(org.xel.BlockchainProcessor) Peer(org.xel.peer.Peer) JSONArray(org.json.simple.JSONArray) Block(org.xel.Block)

Aggregations

JSONArray (org.json.simple.JSONArray)1 JSONObject (org.json.simple.JSONObject)1 Block (org.xel.Block)1 BlockchainProcessor (org.xel.BlockchainProcessor)1 Peer (org.xel.peer.Peer)1