throws Exception {
TreeSet localTreeSet1 = (TreeSet) sortedAskOrders.get(Long.valueOf(paramLong));
TreeSet localTreeSet2 = (TreeSet) sortedBidOrders.get(Long.valueOf(paramLong));
synchronized (askOrders) {
synchronized (bidOrders) {
do {
Nxt.AskOrder localAskOrder = (Nxt.AskOrder) localTreeSet1.first();
Nxt.BidOrder localBidOrder = (Nxt.BidOrder) localTreeSet2.first();
if (localAskOrder.price > localBidOrder.price) {
break;
}
int i = localAskOrder.quantity < localBidOrder.quantity ? localAskOrder.quantity : localBidOrder.quantity;
long l = (localAskOrder.height < localBidOrder.height) || ((localAskOrder.height == localBidOrder.height) && (localAskOrder.id < localBidOrder.id)) ? localAskOrder.price : localBidOrder.price;
if (localAskOrder.quantity -= i == 0) {
askOrders.remove(Long.valueOf(localAskOrder.id));
localTreeSet1.remove(localAskOrder);
}
synchronized (localAskOrder.account) {
localAskOrder.account.setBalance(localAskOrder.account.balance + i * l);
localAskOrder.account.setUnconfirmedBalance(localAskOrder.account.unconfirmedBalance + i * l);
}
if (localBidOrder.quantity -= i == 0) {
bidOrders.remove(Long.valueOf(localBidOrder.id));
localTreeSet2.remove(localBidOrder);
}
synchronized (localBidOrder.account) {
Integer localInteger = (Integer) localBidOrder.account.assetBalances.get(Long.valueOf(paramLong));
if (localInteger == null) {
localBidOrder.account.assetBalances.put(Long.valueOf(paramLong), Integer.valueOf(i));
localBidOrder.account.unconfirmedAssetBalances.put(Long.valueOf(paramLong), Integer.valueOf(i));
} else {
localBidOrder.account.assetBalances.put(Long.valueOf(paramLong), Integer.valueOf(localInteger.intValue() + i));
localBidOrder.account.unconfirmedAssetBalances.put(Long.valueOf(paramLong), Integer.valueOf(((Integer) localBidOrder.account.unconfirmedAssetBalances.get(Long.valueOf(paramLong))).intValue() + i));
}
}
if (localTreeSet1.isEmpty()) {
break;
}
} while (!localTreeSet2.isEmpty());
}
}
}