19
19
20
20
import com .google .protobuf .InvalidProtocolBufferException ;
21
21
import org .hyperledger .fabric .protos .common .Common .Block ;
22
- import org .hyperledger .fabric .protos .orderer . Ab ;
22
+ import org .hyperledger .fabric .protos .peer . PeerEvents ;
23
23
import org .hyperledger .fabric .protos .peer .PeerEvents .Event ;
24
24
import org .hyperledger .fabric .sdk .exception .InvalidProtocolBufferRuntimeException ;
25
25
29
29
* @see Block
30
30
*/
31
31
public class BlockEvent extends BlockInfo {
32
-
33
32
// private static final Log logger = LogFactory.getLog(BlockEvent.class);
34
33
35
34
private final EventHub eventHub ;
@@ -50,9 +49,8 @@ public class BlockEvent extends BlockInfo {
50
49
this .event = event ;
51
50
}
52
51
53
- BlockEvent (Peer peer , Ab .DeliverResponse resp ) {
54
- super (resp .getBlock ());
55
-
52
+ BlockEvent (Peer peer , PeerEvents .DeliverResponse resp ) {
53
+ super (resp );
56
54
eventHub = null ;
57
55
this .peer = peer ;
58
56
this .event = null ;
@@ -89,35 +87,26 @@ public Peer getPeer() {
89
87
// }
90
88
91
89
boolean isBlockEvent () {
90
+ if (peer != null ) {
91
+ return true ; //peer always returns Block type events;
92
+ }
92
93
93
- return event == null || event .getEventCase () == Event .EventCase .BLOCK ;
94
+ return event != null && event .getEventCase () == PeerEvents . Event .EventCase .BLOCK ;
94
95
}
95
96
96
97
TransactionEvent getTransactionEvent (int index ) throws InvalidProtocolBufferException {
97
98
98
- return new TransactionEvent ((TransactionEnvelopeInfo ) getEnvelopeInfo (index ), index );
99
+ return isFiltered () ? new TransactionEvent (getEnvelopeInfo (index ).filteredTx ) :
100
+ new TransactionEvent ((TransactionEnvelopeInfo ) getEnvelopeInfo (index ));
99
101
}
100
102
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 ());
106
106
}
107
107
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 );
121
110
}
122
111
123
112
/**
@@ -144,6 +133,23 @@ public Peer getPeer() {
144
133
}
145
134
}
146
135
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
+
147
153
class TransactionEventIterator implements Iterator <TransactionEvent > {
148
154
final int max ;
149
155
int ci = 0 ;
0 commit comments