Search in sources :

Example 1 with EventProcessorOnDispatch

use of com.radixdlt.environment.EventProcessorOnDispatch in project radixdlt by radixdlt.

the class MockedSyncServiceModule method ledgerUpdateEventProcessor.

@Singleton
@ProvidesIntoSet
private EventProcessorOnDispatch<?> ledgerUpdateEventProcessor() {
    return new EventProcessorOnDispatch<>(LedgerUpdate.class, update -> {
        final LedgerProof headerAndProof = update.getTail();
        long stateVersion = headerAndProof.getAccumulatorState().getStateVersion();
        long firstVersion = stateVersion - update.getNewTxns().size() + 1;
        for (int i = 0; i < update.getNewTxns().size(); i++) {
            sharedCommittedCommands.put(firstVersion + i, update.getNewTxns().get(i));
        }
        if (update.getTail().isEndOfEpoch()) {
            logger.info("Epoch Proof: " + (update.getTail().getEpoch() + 1));
            sharedEpochProofs.put(update.getTail().getEpoch() + 1, update.getTail());
        }
    });
}
Also used : EventProcessorOnDispatch(com.radixdlt.environment.EventProcessorOnDispatch) LedgerProof(com.radixdlt.hotstuff.LedgerProof) Singleton(com.google.inject.Singleton) ProvidesIntoSet(com.google.inject.multibindings.ProvidesIntoSet)

Aggregations

Singleton (com.google.inject.Singleton)1 ProvidesIntoSet (com.google.inject.multibindings.ProvidesIntoSet)1 EventProcessorOnDispatch (com.radixdlt.environment.EventProcessorOnDispatch)1 LedgerProof (com.radixdlt.hotstuff.LedgerProof)1