本文整理汇总了Java中nxt.db.DbIterator类的典型用法代码示例。如果您正苦于以下问题:Java DbIterator类的具体用法?Java DbIterator怎么用?Java DbIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbIterator类属于nxt.db包,在下文中一共展示了DbIterator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAccountAssetTransfers
import nxt.db.DbIterator; //导入依赖的package包/类
public static DbIterator<AssetTransfer> getAccountAssetTransfers(long accountId, long assetId, int from, int to) {
Connection con = null;
try {
con = Db.getConnection();
PreparedStatement pstmt = con.prepareStatement("SELECT * FROM asset_transfer WHERE sender_id = ? AND asset_id = ?"
+ " UNION ALL SELECT * FROM asset_transfer WHERE recipient_id = ? AND sender_id <> ? AND asset_id = ? ORDER BY height DESC"
+ DbUtils.limitsClause(from, to));
int i = 0;
pstmt.setLong(++i, accountId);
pstmt.setLong(++i, assetId);
pstmt.setLong(++i, accountId);
pstmt.setLong(++i, accountId);
pstmt.setLong(++i, assetId);
DbUtils.setLimits(++i, pstmt, from, to);
return assetTransferTable.getManyBy(con, pstmt, false);
} catch (SQLException e) {
DbUtils.close(con);
throw new RuntimeException(e.toString(), e);
}
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:21,代码来源:AssetTransfer.java
示例2: getAccountTrades
import nxt.db.DbIterator; //导入依赖的package包/类
public static DbIterator<Trade> getAccountTrades(long accountId, int from, int to) {
Connection con = null;
try {
con = Db.getConnection();
PreparedStatement pstmt = con.prepareStatement("SELECT * FROM trade WHERE seller_id = ?"
+ " UNION ALL SELECT * FROM trade WHERE buyer_id = ? AND seller_id <> ? ORDER BY height DESC"
+ DbUtils.limitsClause(from, to));
int i = 0;
pstmt.setLong(++i, accountId);
pstmt.setLong(++i, accountId);
pstmt.setLong(++i, accountId);
DbUtils.setLimits(++i, pstmt, from, to);
return tradeTable.getManyBy(con, pstmt, false);
} catch (SQLException e) {
DbUtils.close(con);
throw new RuntimeException(e.toString(), e);
}
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:19,代码来源:Trade.java
示例3: getAccountAssetTrades
import nxt.db.DbIterator; //导入依赖的package包/类
public static DbIterator<Trade> getAccountAssetTrades(long accountId, long assetId, int from, int to) {
Connection con = null;
try {
con = Db.getConnection();
PreparedStatement pstmt = con.prepareStatement("SELECT * FROM trade WHERE seller_id = ? AND asset_id = ?"
+ " UNION ALL SELECT * FROM trade WHERE buyer_id = ? AND seller_id <> ? AND asset_id = ? ORDER BY height DESC"
+ DbUtils.limitsClause(from, to));
int i = 0;
pstmt.setLong(++i, accountId);
pstmt.setLong(++i, assetId);
pstmt.setLong(++i, accountId);
pstmt.setLong(++i, accountId);
pstmt.setLong(++i, assetId);
DbUtils.setLimits(++i, pstmt, from, to);
return tradeTable.getManyBy(con, pstmt, false);
} catch (SQLException e) {
DbUtils.close(con);
throw new RuntimeException(e.toString(), e);
}
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:21,代码来源:Trade.java
示例4: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
JSONArray assetIds = new JSONArray();
try (DbIterator<Asset> assets = Asset.getAllAssets(firstIndex, lastIndex)) {
while (assets.hasNext()) {
assetIds.add(Convert.toUnsignedLong(assets.next().getId()));
}
}
JSONObject response = new JSONObject();
response.put("assetIds", assetIds);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:GetAssetIds.java
示例5: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
JSONArray pollIds = new JSONArray();
try (DbIterator<Poll> polls = Poll.getAllPolls(firstIndex, lastIndex)) {
while (polls.hasNext()) {
pollIds.add(Convert.toUnsignedLong(polls.next().getId()));
}
}
JSONObject response = new JSONObject();
response.put("pollIds", pollIds);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:18,代码来源:GetPollIds.java
示例6: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws ParameterException {
List<Account> accounts = ParameterParser.getAccounts(req);
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
JSONObject response = new JSONObject();
JSONArray accountsJSONArray = new JSONArray();
response.put("assets", accountsJSONArray);
for (Account account : accounts) {
JSONArray assetsJSONArray = new JSONArray();
try (DbIterator<Asset> assets = Asset.getAssetsIssuedBy(account.getId(), firstIndex, lastIndex)) {
while (assets.hasNext()) {
assetsJSONArray.add(JSONData.asset(assets.next()));
}
}
accountsJSONArray.add(assetsJSONArray);
}
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:21,代码来源:GetAssetsByIssuer.java
示例7: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
if (lastIndex < 0 || lastIndex - firstIndex > 99) {
lastIndex = firstIndex + 99;
}
boolean includeTransactions = "true".equalsIgnoreCase(req.getParameter("includeTransactions"));
JSONArray blocks = new JSONArray();
try (DbIterator<? extends Block> iterator = Nxt.getBlockchain().getBlocks(firstIndex, lastIndex)) {
while (iterator.hasNext()) {
Block block = iterator.next();
blocks.add(JSONData.block(block, includeTransactions));
}
}
JSONObject response = new JSONObject();
response.put("blocks", blocks);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:25,代码来源:GetBlocks.java
示例8: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
JSONObject response = new JSONObject();
JSONArray assetsJSONArray = new JSONArray();
response.put("assets", assetsJSONArray);
try (DbIterator<Asset> assets = Asset.getAllAssets(firstIndex, lastIndex)) {
while (assets.hasNext()) {
assetsJSONArray.add(JSONData.asset(assets.next()));
}
}
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:17,代码来源:GetAllAssets.java
示例9: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) {
JSONObject response = new JSONObject();
JSONArray ordersData = new JSONArray();
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
try (DbIterator<Order.Ask> askOrders = Order.Ask.getAll(firstIndex, lastIndex)) {
while (askOrders.hasNext()) {
ordersData.add(JSONData.askOrder(askOrders.next()));
}
}
response.put("openOrders", ordersData);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:19,代码来源:GetAllOpenAskOrders.java
示例10: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
long assetId = ParameterParser.getAsset(req).getId();
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
JSONArray orderIds = new JSONArray();
try (DbIterator<Order.Ask> askOrders = Order.Ask.getSortedOrders(assetId, firstIndex, lastIndex)) {
while (askOrders.hasNext()) {
orderIds.add(Convert.toUnsignedLong(askOrders.next().getId()));
}
}
JSONObject response = new JSONObject();
response.put("askOrderIds", orderIds);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:20,代码来源:GetAskOrderIds.java
示例11: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
long assetId = ParameterParser.getAsset(req).getId();
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
JSONArray orderIds = new JSONArray();
try (DbIterator<Order.Bid> bidOrders = Order.Bid.getSortedOrders(assetId, firstIndex, lastIndex)) {
while (bidOrders.hasNext()) {
orderIds.add(Convert.toUnsignedLong(bidOrders.next().getId()));
}
}
JSONObject response = new JSONObject();
response.put("bidOrderIds", orderIds);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:18,代码来源:GetBidOrderIds.java
示例12: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
long assetId = ParameterParser.getAsset(req).getId();
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
JSONArray orders = new JSONArray();
try (DbIterator<Order.Bid> bidOrders = Order.Bid.getSortedOrders(assetId, firstIndex, lastIndex)) {
while (bidOrders.hasNext()) {
orders.add(JSONData.bidOrder(bidOrders.next()));
}
}
JSONObject response = new JSONObject();
response.put("bidOrders", orders);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:18,代码来源:GetBidOrders.java
示例13: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
Account account = ParameterParser.getAccount(req);
int timestamp = ParameterParser.getTimestamp(req);
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
JSONArray blockIds = new JSONArray();
try (DbIterator<? extends Block> iterator = Nxt.getBlockchain().getBlocks(account, timestamp, firstIndex, lastIndex)) {
while (iterator.hasNext()) {
Block block = iterator.next();
blockIds.add(block.getStringId());
}
}
JSONObject response = new JSONObject();
response.put("blockIds", blockIds);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:22,代码来源:GetAccountBlockIds.java
示例14: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
long assetId = ParameterParser.getAsset(req).getId();
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
JSONArray orders = new JSONArray();
try (DbIterator<Order.Ask> askOrders = Order.Ask.getSortedOrders(assetId, firstIndex, lastIndex)) {
while (askOrders.hasNext()) {
orders.add(JSONData.askOrder(askOrders.next()));
}
}
JSONObject response = new JSONObject();
response.put("askOrders", orders);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:20,代码来源:GetAskOrders.java
示例15: applyUnconfirmed
import nxt.db.DbIterator; //导入依赖的package包/类
@SuppressWarnings("static-access")
public static long applyUnconfirmed(int timestamp) {
appliedSubscriptions.clear();
long totalFees = 0;
DbIterator<Subscription> updateSubscriptions = subscriptionTable.getManyBy(getUpdateOnBlockClause(timestamp), 0, -1);
for(Subscription subscription : updateSubscriptions) {
if(removeSubscriptions.contains(subscription.getId())) {
continue;
}
if(subscription.applyUnconfirmed()) {
appliedSubscriptions.add(subscription);
totalFees += subscription.getFee();
}
else {
removeSubscriptions.add(subscription.getId());
}
}
return totalFees;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:20,代码来源:Subscription.java
示例16: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
Account account = ParameterParser.getAccount(req);
int timestamp = ParameterParser.getTimestamp(req);
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
boolean includeTransactions = "true".equalsIgnoreCase(req.getParameter("includeTransactions"));
JSONArray blocks = new JSONArray();
try (DbIterator<? extends Block> iterator = Nxt.getBlockchain().getBlocks(account, timestamp, firstIndex, lastIndex)) {
while (iterator.hasNext()) {
Block block = iterator.next();
blocks.add(JSONData.block(block, includeTransactions));
}
}
JSONObject response = new JSONObject();
response.put("blocks", blocks);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:24,代码来源:GetAccountBlocks.java
示例17: processRequest
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
Asset asset = ParameterParser.getAsset(req);
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
int height = ParameterParser.getHeight(req);
JSONArray accountAssets = new JSONArray();
try (DbIterator<Account.AccountAsset> iterator = asset.getAccounts(height, firstIndex, lastIndex)) {
while (iterator.hasNext()) {
Account.AccountAsset accountAsset = iterator.next();
accountAssets.add(JSONData.accountAsset(accountAsset));
}
}
JSONObject response = new JSONObject();
response.put("accountAssets", accountAssets);
return response;
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:22,代码来源:GetAssetAccounts.java
示例18: getBlocks
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
public DbIterator<BlockImpl> getBlocks(Account account, int timestamp, int from, int to) {
Connection con = null;
try {
con = Db.getConnection();
PreparedStatement pstmt = con.prepareStatement("SELECT * FROM block WHERE generator_id = ? "
+ (timestamp > 0 ? " AND timestamp >= ? " : " ") + "ORDER BY db_id DESC"
+ DbUtils.limitsClause(from, to));
int i = 0;
pstmt.setLong(++i, account.getId());
if (timestamp > 0) {
pstmt.setInt(++i, timestamp);
}
DbUtils.setLimits(++i, pstmt, from, to);
return getBlocks(con, pstmt);
} catch (SQLException e) {
DbUtils.close(con);
throw new RuntimeException(e.toString(), e);
}
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:21,代码来源:BlockchainImpl.java
示例19: TransactionProcessorImpl
import nxt.db.DbIterator; //导入依赖的package包/类
private TransactionProcessorImpl() {
ThreadPool.scheduleThread("ProcessTransactions", processTransactionsThread, 5);
ThreadPool.scheduleThread("RemoveUnconfirmedTransactions", removeUnconfirmedTransactionsThread, 1);
if (enableTransactionRebroadcasting) {
ThreadPool.scheduleThread("RebroadcastTransactions", rebroadcastTransactionsThread, 60);
ThreadPool.runAfterStart(new Runnable() {
@Override
public void run() {
try (DbIterator<TransactionImpl> oldNonBroadcastedTransactions = getAllUnconfirmedTransactions()) {
for (TransactionImpl transaction : oldNonBroadcastedTransactions) {
nonBroadcastedTransactions.add(transaction);
}
}
}
});
}
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:18,代码来源:TransactionProcessorImpl.java
示例20: clearUnconfirmedTransactions
import nxt.db.DbIterator; //导入依赖的package包/类
@Override
public void clearUnconfirmedTransactions() {
synchronized (BlockchainImpl.getInstance()) {
List<Transaction> removed = new ArrayList<>();
try {
Db.beginTransaction();
try (DbIterator<TransactionImpl> unconfirmedTransactions = getAllUnconfirmedTransactions()) {
for (TransactionImpl transaction : unconfirmedTransactions) {
transaction.undoUnconfirmed();
removed.add(transaction);
}
}
unconfirmedTransactionTable.truncate();
Account.flushAccountTable();
Db.commitTransaction();
} catch (Exception e) {
Logger.logErrorMessage(e.toString(), e);
Db.rollbackTransaction();
throw e;
} finally {
Db.endTransaction();
}
lostTransactions.clear();
transactionListeners.notify(removed, Event.REMOVED_UNCONFIRMED_TRANSACTIONS);
}
}
开发者ID:muhatzg,项目名称:burstcoin,代码行数:27,代码来源:TransactionProcessorImpl.java
注:本文中的nxt.db.DbIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论