当前位置: 首页>>代码示例>>Java>>正文


Java DbIterator类代码示例

本文整理汇总了Java中nxt.util.DbIterator的典型用法代码示例。如果您正苦于以下问题:Java DbIterator类的具体用法?Java DbIterator怎么用?Java DbIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DbIterator类属于nxt.util包,在下文中一共展示了DbIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTransactionIterator

import nxt.util.DbIterator; //导入依赖的package包/类
public static DbIterator<? extends Transaction> getTransactionIterator(
    Long accountId, TransactionType[] recipientTypes,
    TransactionType[] senderTypes, int timestamp, Boolean orderAscending,
    Object referencedTransaction) {
  Connection con = null;
  try {
    con = Db.getConnection();
    PreparedStatement pstmt = createTransactionStatement(con, accountId,
        recipientTypes, senderTypes, timestamp, orderAscending,
        referencedTransaction, false);

    DbIterator<? extends Transaction> iterator = Nxt.getBlockchain()
        .getTransactions(con, pstmt);
    return iterator;
  }
  catch (SQLException e) {
    logger.error("SQL Error", e);
    if (con != null) {
      DbUtils.close(con);
    }
  }
  return null;
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:24,代码来源:TransactionDB.java

示例2: getGeneratedBlocks

import nxt.util.DbIterator; //导入依赖的package包/类
public static List<Block> getGeneratedBlocks(Long accountId) {
  Connection con = null;
  try {
    con = Db.getConnection();
    PreparedStatement pstmt = con
        .prepareStatement("SELECT * FROM block WHERE generator_id = ? ORDER BY db_id ASC");
    pstmt.setLong(1, accountId);

    List<Block> result = new ArrayList<Block>();
    DbIterator<? extends Block> iterator = Nxt.getBlockchain().getBlocks(con,
        pstmt);
    while (iterator.hasNext()) {
      result.add(iterator.next());
    }
    return result;
  }
  catch (SQLException e) {
    DbUtils.close(con);
    throw new RuntimeException(e.toString(), e);
  }
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:22,代码来源:BlockDB.java

示例3: calculateTransactionsChecksum

import nxt.util.DbIterator; //导入依赖的package包/类
private byte[] calculateTransactionsChecksum() {
    PriorityQueue<Transaction> sortedTransactions = new PriorityQueue<>(blockchain.getTransactionCount(), new Comparator<Transaction>() {
        @Override
        public int compare(Transaction o1, Transaction o2) {
            long id1 = o1.getId();
            long id2 = o2.getId();
            return id1 < id2 ? -1 : (id1 > id2 ? 1 : (o1.getTimestamp() < o2.getTimestamp() ? -1 : (o1.getTimestamp() > o2.getTimestamp() ? 1 : 0)));
        }
    });
    try (DbIterator<TransactionImpl> iterator = blockchain.getAllTransactions()) {
        while (iterator.hasNext()) {
            sortedTransactions.add(iterator.next());
        }
    }
    MessageDigest digest = Crypto.sha256();
    while (! sortedTransactions.isEmpty()) {
        digest.update(sortedTransactions.poll().getBytes());
    }
    return digest.digest();
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:21,代码来源:BlockchainProcessorImpl.java

示例4: getAllBlocks

import nxt.util.DbIterator; //导入依赖的package包/类
public DbIterator<BlockImpl> getAllBlocks()
{
  Connection localConnection = null;
  try
  {
    localConnection = Db.getConnection();
    PreparedStatement localPreparedStatement = localConnection.prepareStatement("SELECT * FROM block ORDER BY db_id ASC");
    new DbIterator(localConnection, localPreparedStatement, new DbIterator.ResultSetReader()
    {
      public BlockImpl get(Connection paramAnonymousConnection, ResultSet paramAnonymousResultSet)
        throws NxtException.ValidationException
      {
        return BlockDb.findBlock(paramAnonymousConnection, paramAnonymousResultSet);
      }
    });
  }
  catch (SQLException localSQLException)
  {
    DbUtils.close(new AutoCloseable[] { localConnection });
    throw new RuntimeException(localSQLException.toString(), localSQLException);
  }
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:23,代码来源:BlockchainImpl.java

示例5: getAllTransactions

import nxt.util.DbIterator; //导入依赖的package包/类
public DbIterator<TransactionImpl> getAllTransactions()
{
  Connection localConnection = null;
  try
  {
    localConnection = Db.getConnection();
    PreparedStatement localPreparedStatement = localConnection.prepareStatement("SELECT * FROM transaction ORDER BY db_id ASC");
    new DbIterator(localConnection, localPreparedStatement, new DbIterator.ResultSetReader()
    {
      public TransactionImpl get(Connection paramAnonymousConnection, ResultSet paramAnonymousResultSet)
        throws NxtException.ValidationException
      {
        return TransactionDb.findTransaction(paramAnonymousConnection, paramAnonymousResultSet);
      }
    });
  }
  catch (SQLException localSQLException)
  {
    DbUtils.close(new AutoCloseable[] { localConnection });
    throw new RuntimeException(localSQLException.toString(), localSQLException);
  }
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:23,代码来源:BlockchainImpl.java

示例6: scan

import nxt.util.DbIterator; //导入依赖的package包/类
public void scan() {
  /* Scan the database */
  TransactionType[] types = { TransactionType.Messaging.ARBITRARY_MESSAGE };
  DbIterator<? extends Transaction> iterator = TransactionDB
      .getTransactionIterator(account.getId(), types, types, 0, Boolean.TRUE,
          null);
  while (iterator.hasNext()) {
    processTransaction(iterator.next());
  }

  /* Add all pending transactions not yet in the database */
  addPendingTransactions();
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:14,代码来源:MessageScanner.java

示例7: testListGenesisTransactions

import nxt.util.DbIterator; //导入依赖的package包/类
@Test
public void testListGenesisTransactions() {
  Account account = getGenesisAccount();
  DbIterator<? extends Transaction> iter = Nxt.getBlockchain()
      .getTransactions(account, (byte) -1, (byte) -1, 0);

  int totalAmount = 0;
  while (iter.hasNext()) {
    Transaction txn = iter.next();
    String recipient = Convert.toUnsignedLong(txn.getRecipientId());
    totalAmount += txn.getAmount();
    System.out.println(recipient + " => " + txn.getAmount() + "("
        + totalAmount + ")");
  }
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:16,代码来源:TestGenesisTransactions.java

示例8: getAll

import nxt.util.DbIterator; //导入依赖的package包/类
private void getAll(DbIterator<? extends Transaction> iterator,
    List<Transaction> output, ITransactionFilter filter) {
  Transaction transation;
  while (iterator.hasNext()) {
    transation = iterator.next();
    if (filter.accept(transation))
      output.add(transation);
  }
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:10,代码来源:NxtDB.java

示例9: getTransactions

import nxt.util.DbIterator; //导入依赖的package包/类
public static LazyList getTransactions(Boolean orderAscending, INxtService nxt) {
  Connection con = null;

  /* Count number of records */
  int available = Nxt.getBlockchain().getTransactionCount();

  /* Create the record iterator */
  try {
    con = Db.getConnection();
    StringBuilder buf = new StringBuilder();
    buf.append("SELECT * FROM transaction ");
    if (orderAscending != null) {
      if (Boolean.TRUE.equals(orderAscending)) {
        buf.append("ORDER BY db_id ASC");
      }
      else if (Boolean.FALSE.equals(orderAscending)) {
        buf.append("ORDER BY db_id DESC");
      }
    }
    PreparedStatement pstmt = con.prepareStatement(buf.toString());
    DbIterator<? extends Transaction> iterator = Nxt.getBlockchain()
        .getTransactions(con, pstmt);
    LazyList lazyList = new LazyList(iterator, available, nxt);
    return lazyList;
  }
  catch (SQLException e) {
    logger.error("SQL Error", e);
    if (con != null) {
      DbUtils.close(con);
    }
  }
  return null;
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:34,代码来源:TransactionDB.java

示例10: getForgedBlocks

import nxt.util.DbIterator; //导入依赖的package包/类
@Override
public List<Block> getForgedBlocks() {
  logger.warn("getForgedBlocks()");

  List<Block> result = new ArrayList<Block>();
  Account a = getNative();
  if (a != null) {
    DbIterator<? extends Block> iter = Nxt.getBlockchain().getBlocks(a, 0);
    while (iter.hasNext()) {
      result.add(iter.next());
    }
  }
  return result;
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:15,代码来源:AccountHelper.java

示例11: getForgedFee

import nxt.util.DbIterator; //导入依赖的package包/类
@Override
public int getForgedFee() {
  int fee = 0;
  Account a = getNative();
  if (a != null) {
    DbIterator<? extends Block> iter = Nxt.getBlockchain().getBlocks(a, 0);
    while (iter.hasNext()) {
      fee += iter.next().getTotalFee();
    }
  }
  return fee;
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:13,代码来源:AccountHelper.java

示例12: getBlocks

import nxt.util.DbIterator; //导入依赖的package包/类
public static LazyList getBlocks(Boolean orderAscending, INxtService nxt) {
  Connection con = null;

  /* Count number of records */
  // int available = nxt.getSmartBlockCount();
  int available = Nxt.getBlockchain().getBlockCount();

  /* Create the record iterator */
  try {
    con = Db.getConnection();
    StringBuilder buf = new StringBuilder();
    buf.append("SELECT * FROM block ");
    if (orderAscending != null) {
      if (Boolean.TRUE.equals(orderAscending)) {
        buf.append("ORDER BY db_id ASC");
      }
      else if (Boolean.FALSE.equals(orderAscending)) {
        buf.append("ORDER BY db_id DESC");
      }
    }
    PreparedStatement pstmt = con.prepareStatement(buf.toString());
    DbIterator<? extends Block> iterator = Nxt.getBlockchain().getBlocks(con,
        pstmt);
    LazyList lazyList = new LazyList(iterator, available);
    return lazyList;
  }
  catch (SQLException e) {
    logger.error("SQL Error", e);
    if (con != null) {
      DbUtils.close(con);
    }
  }
  return null;
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:35,代码来源:BlockDB.java

示例13: getAllBlocks

import nxt.util.DbIterator; //导入依赖的package包/类
@Override
public DbIterator<BlockImpl> getAllBlocks() {
    Connection con = null;
    try {
        con = Db.getConnection();
        PreparedStatement pstmt = con.prepareStatement("SELECT * FROM block ORDER BY db_id ASC");
        return getBlocks(con, pstmt);
    } catch (SQLException e) {
        DbUtils.close(con);
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:13,代码来源:BlockchainImpl.java

示例14: getBlocks

import nxt.util.DbIterator; //导入依赖的package包/类
@Override
public DbIterator<BlockImpl> getBlocks(Account account, int timestamp) {
    Connection con = null;
    try {
        con = Db.getConnection();
        PreparedStatement pstmt = con.prepareStatement("SELECT * FROM block WHERE timestamp >= ? AND generator_id = ? ORDER BY db_id ASC");
        pstmt.setInt(1, timestamp);
        pstmt.setLong(2, account.getId());
        return getBlocks(con, pstmt);
    } catch (SQLException e) {
        DbUtils.close(con);
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:15,代码来源:BlockchainImpl.java

示例15: getAllTransactions

import nxt.util.DbIterator; //导入依赖的package包/类
@Override
public DbIterator<TransactionImpl> getAllTransactions() {
    Connection con = null;
    try {
        con = Db.getConnection();
        PreparedStatement pstmt = con.prepareStatement("SELECT * FROM transaction ORDER BY db_id ASC");
        return getTransactions(con, pstmt);
    } catch (SQLException e) {
        DbUtils.close(con);
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:13,代码来源:BlockchainImpl.java


注:本文中的nxt.util.DbIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。