1919
2020import com .google .protobuf .InvalidProtocolBufferException ;
2121import org .hyperledger .fabric .protos .common .Common .Block ;
22- import org .hyperledger .fabric .protos .orderer . Ab ;
22+ import org .hyperledger .fabric .protos .peer . PeerEvents ;
2323import org .hyperledger .fabric .protos .peer .PeerEvents .Event ;
2424import org .hyperledger .fabric .sdk .exception .InvalidProtocolBufferRuntimeException ;
2525
2929 * @see Block
3030 */
3131public class BlockEvent extends BlockInfo {
32-
3332// private static final Log logger = LogFactory.getLog(BlockEvent.class);
3433
3534 private final EventHub eventHub ;
@@ -50,9 +49,8 @@ public class BlockEvent extends BlockInfo {
5049 this .event = event ;
5150 }
5251
53- BlockEvent (Peer peer , Ab .DeliverResponse resp ) {
54- super (resp .getBlock ());
55-
52+ BlockEvent (Peer peer , PeerEvents .DeliverResponse resp ) {
53+ super (resp );
5654 eventHub = null ;
5755 this .peer = peer ;
5856 this .event = null ;
@@ -89,35 +87,26 @@ public Peer getPeer() {
8987// }
9088
9189 boolean isBlockEvent () {
90+ if (peer != null ) {
91+ return true ; //peer always returns Block type events;
92+ }
9293
93- return event == null || event .getEventCase () == Event .EventCase .BLOCK ;
94+ return event != null && event .getEventCase () == PeerEvents . Event .EventCase .BLOCK ;
9495 }
9596
9697 TransactionEvent getTransactionEvent (int index ) throws InvalidProtocolBufferException {
9798
98- return new TransactionEvent ((TransactionEnvelopeInfo ) getEnvelopeInfo (index ), index );
99+ return isFiltered () ? new TransactionEvent (getEnvelopeInfo (index ).filteredTx ) :
100+ new TransactionEvent ((TransactionEnvelopeInfo ) getEnvelopeInfo (index ));
99101 }
100102
101- List <TransactionEvent > getTransactionEventsList () {
102-
103- ArrayList <TransactionEvent > ret = new ArrayList <TransactionEvent >(getEnvelopeCount ());
104- for (TransactionEvent transactionEvent : getTransactionEvents ()) {
105- ret .add (transactionEvent );
103+ public class TransactionEvent extends TransactionEnvelopeInfo {
104+ TransactionEvent (TransactionEnvelopeInfo transactionEnvelopeInfo ) {
105+ super (transactionEnvelopeInfo .getTransactionDeserializer ());
106106 }
107107
108- return ret ;
109-
110- }
111-
112- public Iterable <TransactionEvent > getTransactionEvents () {
113-
114- return new TransactionEventIterable ();
115-
116- }
117-
118- public class TransactionEvent extends TransactionEnvelopeInfo {
119- TransactionEvent (TransactionEnvelopeInfo transactionEnvelopeInfo , int index ) {
120- super (transactionEnvelopeInfo .getTransactionDeserializer (), index );
108+ TransactionEvent (PeerEvents .FilteredTransaction filteredTransaction ) {
109+ super (filteredTransaction );
121110 }
122111
123112 /**
@@ -144,6 +133,23 @@ public Peer getPeer() {
144133 }
145134 }
146135
136+ List <TransactionEvent > getTransactionEventsList () {
137+
138+ ArrayList <TransactionEvent > ret = new ArrayList <TransactionEvent >(getEnvelopeCount ());
139+ for (TransactionEvent transactionEvent : getTransactionEvents ()) {
140+ ret .add (transactionEvent );
141+ }
142+
143+ return ret ;
144+
145+ }
146+
147+ public Iterable <TransactionEvent > getTransactionEvents () {
148+
149+ return new TransactionEventIterable ();
150+
151+ }
152+
147153 class TransactionEventIterator implements Iterator <TransactionEvent > {
148154 final int max ;
149155 int ci = 0 ;
0 commit comments