Search in sources :

Example 1 with UtxoOutputDataService

use of io.nuls.db.dao.UtxoOutputDataService 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)

Example 2 with UtxoOutputDataService

use of io.nuls.db.dao.UtxoOutputDataService in project nuls by nuls-io.

the class UtxoLedgerModuleBootstrap method init.

@Override
public void init() {
    EventManager.putEvent(BalanceChangeNotice.class);
    registerService();
    ledgerService = NulsContext.getServiceBean(LedgerService.class);
    UtxoOutputDataService outputDataService = NulsContext.getServiceBean(UtxoOutputDataService.class);
    coinManager = UtxoCoinManager.getInstance();
    coinManager.setOutputDataService(outputDataService);
    cacheService = LedgerCacheService.getInstance();
    addNormalTxValidator();
}
Also used : UtxoOutputDataService(io.nuls.db.dao.UtxoOutputDataService) LedgerService(io.nuls.ledger.service.intf.LedgerService)

Aggregations

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