// Path: src/java/nxt/db/DerivedDbTable.java
// public abstract class DerivedDbTable {
// 
//     protected final String table;
// 
//     protected DerivedDbTable(String table) {
//         this.table = table;
//         Nxt.getBlockchainProcessor().registerDerivedTable(this);
//     }
// 
//     public void rollback(int height) {
//         if (!Db.isInTransaction()) {
//             throw new IllegalStateException("Not in transaction");
//         }
//         try (Connection con = Db.getConnection();
//              PreparedStatement pstmtDelete = con.prepareStatement("DELETE FROM " + table + " WHERE height > ?")) {
//             pstmtDelete.setInt(1, height);
//             pstmtDelete.executeUpdate();
//         } catch (SQLException e) {
//             throw new RuntimeException(e.toString(), e);
//         }
//     }
// 
//     public void truncate() {
//         if (!Db.isInTransaction()) {
//             throw new IllegalStateException("Not in transaction");
//         }
//         try (Connection con = Db.getConnection();
//              Statement stmt = con.createStatement()) {
//             stmt.executeUpdate("TRUNCATE TABLE " + table);
//         } catch (SQLException e) {
//             throw new RuntimeException(e.toString(), e);
//         }
//     }
// 
//     public void trim(int height) {
//         //nothing to trim
//     }
// 
// }


import nxt.db.DerivedDbTable;
import nxt.peer.Peer;
import nxt.util.Observable;
import org.json.simple.JSONObject;
import java.util.List;
package nxt;



public interface BlockchainProcessor extends Observable<Block,BlockchainProcessor.Event> {

    public static enum Event {
        BLOCK_PUSHED, BLOCK_POPPED, BLOCK_GENERATED, BLOCK_SCANNED,
        RESCAN_BEGIN, RESCAN_END,
        BEFORE_BLOCK_ACCEPT,
        BEFORE_BLOCK_APPLY, AFTER_BLOCK_APPLY
    }

    Peer getLastBlockchainFeeder();

    int getLastBlockchainFeederHeight();

    boolean isScanning();

    int getMinRollbackHeight();

    void processPeerBlock(JSONObject request) throws NxtException;

    void fullReset();

    void scan(int height);

    void forceScanAtStart();

    void validateAtNextScan();

    List<? extends Block> popOffTo(int height);

// Path: src/java/nxt/db/DerivedDbTable.java
// public abstract class DerivedDbTable {
// 
//     protected final String table;
// 
//     protected DerivedDbTable(String table) {
//         this.table = table;
//         Nxt.getBlockchainProcessor().registerDerivedTable(this);
//     }
// 
//     public void rollback(int height) {
//         if (!Db.isInTransaction()) {
//             throw new IllegalStateException("Not in transaction");
//         }
//         try (Connection con = Db.getConnection();
//              PreparedStatement pstmtDelete = con.prepareStatement("DELETE FROM " + table + " WHERE height > ?")) {
//             pstmtDelete.setInt(1, height);
//             pstmtDelete.executeUpdate();
//         } catch (SQLException e) {
//             throw new RuntimeException(e.toString(), e);
//         }
//     }
// 
//     public void truncate() {
//         if (!Db.isInTransaction()) {
//             throw new IllegalStateException("Not in transaction");
//         }
//         try (Connection con = Db.getConnection();
//              Statement stmt = con.createStatement()) {
//             stmt.executeUpdate("TRUNCATE TABLE " + table);
//         } catch (SQLException e) {
//             throw new RuntimeException(e.toString(), e);
//         }
//     }
// 
//     public void trim(int height) {
//         //nothing to trim
//     }
// 
// }


// Path: src/java/nxt/BlockchainProcessor.java
import nxt.db.DerivedDbTable;
import nxt.peer.Peer;
import nxt.util.Observable;
import org.json.simple.JSONObject;
import java.util.List;

package nxt;



public interface BlockchainProcessor extends Observable<Block,BlockchainProcessor.Event> {

    public static enum Event {
        BLOCK_PUSHED, BLOCK_POPPED, BLOCK_GENERATED, BLOCK_SCANNED,
        RESCAN_BEGIN, RESCAN_END,
        BEFORE_BLOCK_ACCEPT,
        BEFORE_BLOCK_APPLY, AFTER_BLOCK_APPLY
    }

    Peer getLastBlockchainFeeder();

    int getLastBlockchainFeederHeight();

    boolean isScanning();

    int getMinRollbackHeight();

    void processPeerBlock(JSONObject request) throws NxtException;

    void fullReset();

    void scan(int height);

    void forceScanAtStart();

    void validateAtNextScan();

    List<? extends Block> popOffTo(int height);

    void registerDerivedTable(DerivedDbTable table);