Skip to content

Commit

Permalink
Update to latest protobufs from fabric-protos
Browse files Browse the repository at this point in the history
Change-Id: I5660e25ac20faf872cd44cc5405294c12cc92b4a
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
  • Loading branch information
bestbeforetoday committed Sep 4, 2019
1 parent 2e7eb12 commit 10d2358
Show file tree
Hide file tree
Showing 83 changed files with 1,455 additions and 2,028 deletions.
35 changes: 33 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
protobuf-java directly, you will be transitively depending on the
protobuf-java version that grpc depends on.
-->
<protocArtifact>com.google.protobuf:protoc:3.0.0:exe:${os.detected.classifier}</protocArtifact>
<protocArtifact>com.google.protobuf:protoc:3.7.1:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
</pluginArtifact>
Expand All @@ -321,7 +321,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -331,6 +331,37 @@
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
<executions>
<execution> <!-- Default Maven execution for generated code with warnings and linting disabled -->
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>org/hyperledger/fabric/protos/**/*.java</include>
</includes>
</configuration>
</execution>
<execution> <!-- Additional execution for all other code with warnings and linting enabled -->
<id>compile-main</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<excludes>
<exclude>org/hyperledger/fabric/protos/**/*.java</exclude>
</excludes>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
22 changes: 3 additions & 19 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.peer.PeerEvents;
import org.hyperledger.fabric.protos.peer.EventsPackage;
import org.hyperledger.fabric.sdk.exception.InvalidProtocolBufferRuntimeException;

/**
Expand All @@ -30,7 +30,7 @@
public class BlockEvent extends BlockInfo {
private final Peer peer;

BlockEvent(Peer peer, PeerEvents.DeliverResponse resp) {
BlockEvent(Peer peer, EventsPackage.DeliverResponse resp) {
super(resp);
this.peer = peer;
}
Expand All @@ -44,7 +44,6 @@ public Peer getPeer() {
return peer;
}


TransactionEvent getTransactionEvent(int index) throws InvalidProtocolBufferException {
TransactionEvent ret = null;

Expand All @@ -65,7 +64,7 @@ public class TransactionEvent extends TransactionEnvelopeInfo {
super(transactionEnvelopeInfo.getTransactionDeserializer());
}

TransactionEvent(PeerEvents.FilteredTransaction filteredTransaction) {
TransactionEvent(EventsPackage.FilteredTransaction filteredTransaction) {
super(filteredTransaction);
}

Expand All @@ -74,40 +73,31 @@ public class TransactionEvent extends TransactionEnvelopeInfo {
*
* @return BlockEvent for this transaction.
*/

public BlockEvent getBlockEvent() {

return BlockEvent.this;

}

/**
* The peer that received this event.
*
* @return return peer producing the event.
*/

public Peer getPeer() {

return BlockEvent.this.getPeer();
}
}

List<TransactionEvent> getTransactionEventsList() {

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

return ret;

}

public Iterable<TransactionEvent> getTransactionEvents() {

return new TransactionEventIterable();

}

class TransactionEventIterator implements Iterator<TransactionEvent> {
Expand All @@ -122,22 +112,17 @@ class TransactionEventIterator implements Iterator<TransactionEvent> {
@Override
public boolean hasNext() {
return returned < max;

}

@Override
public TransactionEvent next() {

TransactionEvent ret = null;
// Filter for only transactions but today it's not really needed.
// Blocks with transactions only has transactions or a single pdate.
try {
do {

ret = getTransactionEvent(ci++);

} while (ret == null);

} catch (InvalidProtocolBufferException e) {
throw new InvalidProtocolBufferRuntimeException(e);
}
Expand All @@ -147,7 +132,6 @@ public TransactionEvent next() {
}

class TransactionEventIterable implements Iterable<TransactionEvent> {

@Override
public Iterator<TransactionEvent> iterator() {
return new TransactionEventIterator();
Expand Down
Loading

0 comments on commit 10d2358

Please sign in to comment.