use of io.nuls.ledger.util.LedgerUtil.asString in project nuls by nuls-io.
the class ContractServiceImpl method rollbackToMapAndContractUsedCoinMap.
private void rollbackToMapAndContractUsedCoinMap(Transaction tx, Map<String, Coin> toMaps, Map<String, Coin> contractUsedCoinMap) {
if (tx == null || tx.getCoinData() == null || contractUsedCoinMap == null) {
return;
}
CoinData coinData = tx.getCoinData();
List<Coin> froms = coinData.getFrom();
List<Coin> tos = coinData.getTo();
String key;
for (Coin from : froms) {
key = from.getKey();
if (key != null) {
contractUsedCoinMap.remove(from.getKey());
}
}
try {
byte[] txHashBytes = tx.getHash().serialize();
for (int i = 0, size = tos.size(); i < size; i++) {
toMaps.remove(LedgerUtil.asString(ArraysTool.concatenate(txHashBytes, new VarInt(i).encode())));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations