Search in sources :

Example 1 with AionBlockStore

use of org.aion.zero.impl.db.AionBlockStore in project aion by aionnetwork.

the class ApiWeb3Aion method debug_getBlocksByNumber.

/* -------------------------------------------------------------------------
     * debug
     */
public Object debug_getBlocksByNumber(String _bnOrId, boolean _fullTransactions) {
    Long bn = parseBnOrId(_bnOrId);
    if (bn == null || bn < 0)
        return null;
    List<Map.Entry<AionBlock, Map.Entry<BigInteger, Boolean>>> blocks = ((AionBlockStore) this.ac.getAionHub().getBlockchain().getBlockStore()).getBlocksByNumber(bn);
    if (blocks == null) {
        LOG.debug("<get-block bn={} err=not-found>");
        return null;
    }
    JSONArray response = new JSONArray();
    for (Map.Entry<AionBlock, Map.Entry<BigInteger, Boolean>> block : blocks) {
        JSONObject b = (JSONObject) Blk.AionBlockToJson(block.getKey(), block.getValue().getKey(), _fullTransactions);
        b.put("mainchain", block.getValue().getValue());
        response.put(b);
    }
    return response;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) BigInteger(java.math.BigInteger) AionBlockStore(org.aion.zero.impl.db.AionBlockStore) LRUMap(org.apache.commons.collections4.map.LRUMap) HashMap(java.util.HashMap) Map(java.util.Map) AionBlock(org.aion.zero.impl.types.AionBlock)

Aggregations

BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AionBlockStore (org.aion.zero.impl.db.AionBlockStore)1 AionBlock (org.aion.zero.impl.types.AionBlock)1 LRUMap (org.apache.commons.collections4.map.LRUMap)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1