Skip to content

Commit

Permalink
FAB-7652 filterblock
Browse files Browse the repository at this point in the history
PS:
06 Unrelated default enrollment profiles needs to be empty string.

Change-Id: Id9242c40180292f0484d117c2d366cb73a4b23cc
Signed-off-by: rickr <cr22rc@gmail.com>
  • Loading branch information
cr22rc committed Jan 16, 2018
1 parent 41ec4c3 commit ee34177
Show file tree
Hide file tree
Showing 21 changed files with 599 additions and 236 deletions.
6 changes: 5 additions & 1 deletion checkstyle-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="MethodLength"/>
<module name="MethodLength">
<property name="tokens" value="METHOD_DEF"/>
<property name="max" value="200"/>
<property name="countEmpty" value="false"/>
</module>
<module name="ParameterNumber">
<property name="max" value="8"/>
</module>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</scm>
<properties>
<grpc.version>1.8.0</grpc.version><!-- CURRENT_GRPC_VERSION -->
<bouncycastle.version>1.58</bouncycastle.version>
<bouncycastle.version>1.59</bouncycastle.version>
<httpclient.version>4.5.4</httpclient.version>
<skipITs>true</skipITs>
<alpn-boot-version>8.1.7.v20160121</alpn-boot-version>
Expand Down Expand Up @@ -102,7 +102,7 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcpkix-jdk15on -->
<dependency>
Expand Down
56 changes: 31 additions & 25 deletions src/main/java/org/hyperledger/fabric/sdk/BlockEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import com.google.protobuf.InvalidProtocolBufferException;
import org.hyperledger.fabric.protos.common.Common.Block;
import org.hyperledger.fabric.protos.orderer.Ab;
import org.hyperledger.fabric.protos.peer.PeerEvents;
import org.hyperledger.fabric.protos.peer.PeerEvents.Event;
import org.hyperledger.fabric.sdk.exception.InvalidProtocolBufferRuntimeException;

Expand All @@ -29,7 +29,6 @@
* @see Block
*/
public class BlockEvent extends BlockInfo {

// private static final Log logger = LogFactory.getLog(BlockEvent.class);

private final EventHub eventHub;
Expand All @@ -50,9 +49,8 @@ public class BlockEvent extends BlockInfo {
this.event = event;
}

BlockEvent(Peer peer, Ab.DeliverResponse resp) {
super(resp.getBlock());

BlockEvent(Peer peer, PeerEvents.DeliverResponse resp) {
super(resp);
eventHub = null;
this.peer = peer;
this.event = null;
Expand Down Expand Up @@ -89,35 +87,26 @@ public Peer getPeer() {
// }

boolean isBlockEvent() {
if (peer != null) {
return true; //peer always returns Block type events;
}

return event == null || event.getEventCase() == Event.EventCase.BLOCK;
return event != null && event.getEventCase() == PeerEvents.Event.EventCase.BLOCK;
}

TransactionEvent getTransactionEvent(int index) throws InvalidProtocolBufferException {

return new TransactionEvent((TransactionEnvelopeInfo) getEnvelopeInfo(index), index);
return isFiltered() ? new TransactionEvent(getEnvelopeInfo(index).filteredTx) :
new TransactionEvent((TransactionEnvelopeInfo) getEnvelopeInfo(index));
}

List<TransactionEvent> getTransactionEventsList() {

ArrayList<TransactionEvent> ret = new ArrayList<TransactionEvent>(getEnvelopeCount());
for (TransactionEvent transactionEvent : getTransactionEvents()) {
ret.add(transactionEvent);
public class TransactionEvent extends TransactionEnvelopeInfo {
TransactionEvent(TransactionEnvelopeInfo transactionEnvelopeInfo) {
super(transactionEnvelopeInfo.getTransactionDeserializer());
}

return ret;

}

public Iterable<TransactionEvent> getTransactionEvents() {

return new TransactionEventIterable();

}

public class TransactionEvent extends TransactionEnvelopeInfo {
TransactionEvent(TransactionEnvelopeInfo transactionEnvelopeInfo, int index) {
super(transactionEnvelopeInfo.getTransactionDeserializer(), index);
TransactionEvent(PeerEvents.FilteredTransaction filteredTransaction) {
super(filteredTransaction);
}

/**
Expand All @@ -144,6 +133,23 @@ public Peer getPeer() {
}
}

List<TransactionEvent> getTransactionEventsList() {

ArrayList<TransactionEvent> ret = new ArrayList<TransactionEvent>(getEnvelopeCount());
for (TransactionEvent transactionEvent : getTransactionEvents()) {
ret.add(transactionEvent);
}

return ret;

}

public Iterable<TransactionEvent> getTransactionEvents() {

return new TransactionEventIterable();

}

class TransactionEventIterator implements Iterator<TransactionEvent> {
final int max;
int ci = 0;
Expand Down
Loading

0 comments on commit ee34177

Please sign in to comment.