use of neo.model.bytes.UInt256 in project neo-java by coranos.
the class BlockDbH2Impl method getAssetValueMap.
@Override
public Map<UInt256, Fixed8> getAssetValueMap(final UInt160 account) {
final JdbcTemplate jdbcOperations = new JdbcTemplate(ds);
final String sql = getSql("getAssetValueMap");
final List<Map<String, Object>> mapList = jdbcOperations.queryForList(sql, account);
final Map<UInt256, Fixed8> assetValueMap = new TreeMap<>();
final TransactionOutputMapToObject mapToObject = new TransactionOutputMapToObject();
for (final Map<String, Object> map : mapList) {
final TransactionOutput output = mapToObject.toObject(map);
assetValueMap.put(output.assetId, output.value);
}
return assetValueMap;
}
use of neo.model.bytes.UInt256 in project neo-java by coranos.
the class TransactionOutputFactory method toObject.
@Override
public TransactionOutput toObject(final ByteBuffer bb) {
bb.getLong();
final byte[] assetIdBa = ModelUtil.getVariableLengthByteArray(bb);
final byte[] valueBa = ModelUtil.getVariableLengthByteArray(bb);
ArrayUtils.reverse(valueBa);
final byte[] scriptHashBa = ModelUtil.getVariableLengthByteArray(bb);
final UInt256 assetId = new UInt256(ByteBuffer.wrap(assetIdBa));
final Fixed8 value = new Fixed8(ByteBuffer.wrap(valueBa));
final UInt160 scriptHash = new UInt160(scriptHashBa);
final TransactionOutput transactionOutput = new TransactionOutput(assetId, value, scriptHash);
return transactionOutput;
}
use of neo.model.bytes.UInt256 in project neo-java by coranos.
the class InvPayload method toJSONObject.
@Override
public JSONObject toJSONObject() {
final JSONObject json = new JSONObject();
json.put("type", type);
final JSONArray hashesJson = new JSONArray();
json.put("hashes", hashesJson);
for (final UInt256 hash : hashes) {
hashesJson.put(hash.toHexString());
}
return json;
}
use of neo.model.bytes.UInt256 in project neo-java by coranos.
the class ModelUtil method getTransactionOutput.
/**
* returns the transaction output for this coin reference.
*
* @param blockDb
* the block database to ues.
* @param coinReference
* the coin reference to use.
* @return the TransactionOutput.
*/
public static TransactionOutput getTransactionOutput(final BlockDb blockDb, final CoinReference coinReference) {
final UInt256 prevHashReversed = coinReference.prevHash.reverse();
final Transaction tiTx = blockDb.getTransactionWithHash(prevHashReversed);
final int prevIndex = coinReference.prevIndex.asInt();
final TransactionOutput ti = tiTx.outputs.get(prevIndex);
return ti;
}
use of neo.model.bytes.UInt256 in project neo-java by coranos.
the class BlockDbH2Impl method getAccountAssetValueMap.
@Override
public Map<UInt160, Map<UInt256, Fixed8>> getAccountAssetValueMap() {
final JdbcTemplate jdbcOperations = new JdbcTemplate(ds);
final String sql = getSql("getAccountAssetValueMap");
final List<Map<String, Object>> mapList = jdbcOperations.queryForList(sql);
final Map<UInt160, Map<UInt256, Fixed8>> accountAssetValueMap = new TreeMap<>();
final TransactionOutputMapToObject mapToObject = new TransactionOutputMapToObject();
for (final Map<String, Object> map : mapList) {
final TransactionOutput output = mapToObject.toObject(map);
if (!accountAssetValueMap.containsKey(output.scriptHash)) {
accountAssetValueMap.put(output.scriptHash, new TreeMap<>());
}
final Map<UInt256, Fixed8> assetValueMap = accountAssetValueMap.get(output.scriptHash);
assetValueMap.put(output.assetId, output.value);
}
return accountAssetValueMap;
}
Aggregations