class TxValidatorNonceRangeValidator implements  TxValidatorStep {

    @Override
    public boolean validate(Transaction tx, @Nullable AccountState state, BigInteger gasLimit, Coin minimumGasPrice, long bestBlockNumber, boolean isFreeTx) {
        BigInteger nonce = tx.getNonceAsInteger();
        BigInteger stateNonce = state == null ? BigInteger.ZERO : state.getNonce();
        BigInteger maxNumberOfTxsPerAddress = BigInteger.valueOf(4);
        return stateNonce.compareTo(nonce) <= 0 && stateNonce.add(maxNumberOfTxsPerAddress).compareTo(nonce) >= 0;
    }

}