Java Code Examples for net.bither.bitherj.core.Address#VANITY_LEN_NO_EXSITS

The following examples show how to use net.bither.bitherj.core.Address#VANITY_LEN_NO_EXSITS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public int getVanityLen(String address) {
    int vanityLen = Address.VANITY_LEN_NO_EXSITS;

    try {
        PreparedStatement statement = this.mDb.getPreparedStatement("select vanity_len from vanity_address where address=?", new String[]{address});
        ResultSet c = statement.executeQuery();
        if (c.next()) {
            int idColumn = c.findColumn(AbstractDb.VanityAddressColumns.VANITY_LEN);
            if (idColumn != -1) {
                vanityLen = c.getInt(idColumn);
            }
        }
        c.close();
        statement.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }

    return vanityLen;
}
 
Example 2
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public int getVanityLen(String address) {
    int vanityLen = Address.VANITY_LEN_NO_EXSITS;

    try {
        PreparedStatement statement = this.mDb.getPreparedStatement("select vanity_len from vanity_address where address=?", new String[]{address});
        ResultSet c = statement.executeQuery();
        if (c.next()) {
            int idColumn = c.findColumn(AbstractDb.VanityAddressColumns.VANITY_LEN);
            if (idColumn != -1) {
                vanityLen = c.getInt(idColumn);
            }
        }
        c.close();
        statement.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }

    return vanityLen;
}
 
Example 3
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Integer> getVanitylens() {
    Map<String, Integer> stringMap = new HashMap<String, Integer>();
    try {
        PreparedStatement statement = this.mDb.getPreparedStatement("select * from vanity_address", null);
        ResultSet c = statement.executeQuery();
        while (c.next()) {
            int idColumn = c.findColumn(AbstractDb.VanityAddressColumns.ADDRESS);
            String address = null;
            int vanityLen = Address.VANITY_LEN_NO_EXSITS;
            if (idColumn > -1) {
                address = c.getString(idColumn);
            }
            idColumn = c.findColumn(AbstractDb.VanityAddressColumns.VANITY_LEN);
            if (idColumn > -1) {
                vanityLen = c.getInt(idColumn);
            }
            stringMap.put(address, vanityLen);

        }
        c.close();
        statement.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return stringMap;
}
 
Example 4
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public void updateVaitylen(String address, int vanitylen) {
    if (vanitylen == Address.VANITY_LEN_NO_EXSITS) {
        this.mDb.executeUpdate("delete from vanity_address where address=?", new String[]{
                address
        });

    } else {
        this.mDb.executeUpdate("insert or replace into vanity_address(address,vanity_len) values(?,?)",
                new String[]{address, Integer.toString(vanitylen)});

    }
}
 
Example 5
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Integer> getVanitylens() {
    Map<String, Integer> stringMap = new HashMap<String, Integer>();
    try {
        PreparedStatement statement = this.mDb.getPreparedStatement("select * from vanity_address", null);
        ResultSet c = statement.executeQuery();
        while (c.next()) {
            int idColumn = c.findColumn(AbstractDb.VanityAddressColumns.ADDRESS);
            String address = null;
            int vanityLen = Address.VANITY_LEN_NO_EXSITS;
            if (idColumn > -1) {
                address = c.getString(idColumn);
            }
            idColumn = c.findColumn(AbstractDb.VanityAddressColumns.VANITY_LEN);
            if (idColumn > -1) {
                vanityLen = c.getInt(idColumn);
            }
            stringMap.put(address, vanityLen);

        }
        c.close();
        statement.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return stringMap;
}
 
Example 6
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public void updateVaitylen(String address, int vanitylen) {
    if (vanitylen == Address.VANITY_LEN_NO_EXSITS) {
        this.mDb.executeUpdate("delete from vanity_address where address=?", new String[]{
                address
        });

    } else {
        this.mDb.executeUpdate("insert or replace into vanity_address(address,vanity_len) values(?,?)",
                new String[]{address, Integer.toString(vanitylen)});

    }
}