Search in sources :

Example 1 with CheckpointManager

use of co.rsk.bitcoinj.core.CheckpointManager in project rskj by rsksmart.

the class BridgeSupport method getLowestBlock.

/**
 * Returns the first bitcoin block we have. It is either a checkpoint or the genesis
 */
private StoredBlock getLowestBlock() throws IOException {
    InputStream checkpoints = this.getCheckPoints();
    if (checkpoints == null) {
        BtcBlock genesis = bridgeConstants.getBtcParams().getGenesisBlock();
        return new StoredBlock(genesis, genesis.getWork(), 0);
    }
    CheckpointManager manager = new CheckpointManager(bridgeConstants.getBtcParams(), checkpoints);
    long time = getActiveFederation().getCreationTime().toEpochMilli();
    // Go back 1 week to match CheckpointManager.checkpoint() behaviour
    time -= 86400 * 7;
    return manager.getCheckpointBefore(time);
}
Also used : StoredBlock(co.rsk.bitcoinj.core.StoredBlock) InputStream(java.io.InputStream) CheckpointManager(co.rsk.bitcoinj.core.CheckpointManager) BtcBlock(co.rsk.bitcoinj.core.BtcBlock)

Aggregations

BtcBlock (co.rsk.bitcoinj.core.BtcBlock)1 CheckpointManager (co.rsk.bitcoinj.core.CheckpointManager)1 StoredBlock (co.rsk.bitcoinj.core.StoredBlock)1 InputStream (java.io.InputStream)1