org.hyperledger.fabric.client.InMemoryCheckpointer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fabric-gateway Show documentation
Show all versions of fabric-gateway Show documentation
Hyperledger Fabric Gateway client API for Java
/*
* Copyright 2022 IBM All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.client;
import java.util.Optional;
import java.util.OptionalLong;
/**
* A non-persistent Checkpointer implementation.
* It can be used to checkpoint progress after successfully processing events, allowing eventing to be resumed from this point.
*/
public final class InMemoryCheckpointer implements Checkpointer {
private OptionalLong blockNumber = OptionalLong.empty();
private String transactionId;
@Override
public void checkpointBlock(final long blockNumber) {
checkpointTransaction(blockNumber + 1, null);
}
@Override
public void checkpointTransaction(final long blockNumber, final String transactionId) {
this.blockNumber = OptionalLong.of(blockNumber);
this.transactionId = transactionId;
}
@Override
public void checkpointChaincodeEvent(final ChaincodeEvent event) {
checkpointTransaction(event.getBlockNumber(), event.getTransactionId());
}
@Override
public OptionalLong getBlockNumber() {
return blockNumber;
}
@Override
public Optional getTransactionId() {
return Optional.ofNullable(transactionId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy