use of neo.model.bytes.UInt16 in project neo-java by coranos.
the class BlockDbMapDbImpl method getUnspentTransactionOutputListMap.
@Override
public Map<UInt256, Map<TransactionOutput, CoinReference>> getUnspentTransactionOutputListMap(final UInt160 account) {
final List<Transaction> transactionList = getTransactionWithAccountList(account);
final BTreeMap<byte[], Boolean> transactionOutputSpentStateMap = getTransactionOutputSpentStateMap();
final Map<UInt256, Map<TransactionOutput, CoinReference>> assetIdTxoMap = new TreeMap<>();
final BTreeMap<byte[], byte[]> txKeyByHashMap = getTransactionKeyByTransactionHashMap();
for (final Transaction transaction : transactionList) {
final byte[] hashBa = transaction.getHash().toByteArray();
final byte[] txKeyBa = txKeyByHashMap.get(hashBa);
for (final TransactionOutput to : transaction.outputs) {
if (to.scriptHash.equals(account)) {
final byte[] toBa = to.toByteArray();
if (transactionOutputSpentStateMap.containsKey(toBa)) {
if (transactionOutputSpentStateMap.get(toBa) == true) {
if (!assetIdTxoMap.containsKey(to.assetId)) {
assetIdTxoMap.put(to.assetId, new TreeMap<>());
}
final int txIx = getTransactionIndexInBlockFromTransactionKey(txKeyBa);
final CoinReference cr = new CoinReference(transaction.getHash(), new UInt16(txIx));
assetIdTxoMap.get(to.assetId).put(to, cr);
}
}
}
}
}
return assetIdTxoMap;
}
use of neo.model.bytes.UInt16 in project neo-java by coranos.
the class CoinReferenceFactory method toObject.
@Override
public CoinReference toObject(final ByteBuffer bb) {
bb.getLong();
final byte[] prevHashBa = ModelUtil.getVariableLengthByteArray(bb);
final byte[] prevIndexBa = ModelUtil.getVariableLengthByteArray(bb);
final UInt256 prevHash = new UInt256(ByteBuffer.wrap(prevHashBa));
final UInt16 prevIndex = new UInt16(prevIndexBa);
final CoinReference coinReference = new CoinReference(prevHash, prevIndex);
return coinReference;
}
Aggregations