org.hyperledger.fabric.client.ChaincodeEventIterator 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 2021 IBM All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.client;
import java.util.Collections;
import java.util.Iterator;
import org.hyperledger.fabric.protos.gateway.ChaincodeEventsResponse;
final class ChaincodeEventIterator implements CloseableIterator {
private final CloseableIterator responseIter;
private Iterator eventIter = Collections.emptyIterator();
private long blockNumber;
ChaincodeEventIterator(final CloseableIterator responseIter) {
this.responseIter = responseIter;
}
@Override
public boolean hasNext() {
return eventIter.hasNext() || responseIter.hasNext();
}
@Override
public ChaincodeEvent next() {
while (!eventIter.hasNext()) {
ChaincodeEventsResponse response = responseIter.next();
eventIter = response.getEventsList().iterator();
blockNumber = response.getBlockNumber();
}
return new ChaincodeEventImpl(blockNumber, eventIter.next());
}
@Override
public void close() {
responseIter.close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy