Search in sources :

Example 1 with LedgerCacheService

use of io.nuls.ledger.service.impl.LedgerCacheService in project nuls by nuls-io.

the class UtxoInput method parse.

@Override
public void parse(NulsByteBuffer byteBuffer) throws NulsException {
    index = (int) byteBuffer.readVarInt();
    fromHash = byteBuffer.readNulsData(new NulsDigestData());
    fromIndex = (int) byteBuffer.readVarInt();
    LedgerCacheService ledgerCacheService = LedgerCacheService.getInstance();
    UtxoOutput output = ledgerCacheService.getUtxo(this.getKey());
    if (output == null) {
        UtxoOutputDataService utxoOutputDataService = NulsContext.getServiceBean(UtxoOutputDataService.class);
        Map<String, Object> map = new HashMap<>();
        map.put("txHash", this.fromHash.getDigestHex());
        map.put("outIndex", this.fromIndex);
        UtxoOutputPo outputPo = utxoOutputDataService.get(map);
        if (outputPo != null) {
            output = UtxoTransferTool.toOutput(outputPo);
        }
    }
    from = output;
}
Also used : LedgerCacheService(io.nuls.ledger.service.impl.LedgerCacheService) HashMap(java.util.HashMap) UtxoOutputDataService(io.nuls.db.dao.UtxoOutputDataService) NulsDigestData(io.nuls.core.chain.entity.NulsDigestData) UtxoOutputPo(io.nuls.db.entity.UtxoOutputPo)

Aggregations

NulsDigestData (io.nuls.core.chain.entity.NulsDigestData)1 UtxoOutputDataService (io.nuls.db.dao.UtxoOutputDataService)1 UtxoOutputPo (io.nuls.db.entity.UtxoOutputPo)1 LedgerCacheService (io.nuls.ledger.service.impl.LedgerCacheService)1 HashMap (java.util.HashMap)1