@@ -90,31 +90,6 @@ public int getEnvelopeCount() {
9090 return block .getData ().getDataCount ();
9191 }
9292
93- // /**
94- // * Get transaction info on a specific transaction.
95- // *
96- // * @param index index into the block.
97- // * @return Transaction Info
98- // * @throws InvalidProtocolBufferException
99- // */
100-
101- // public TransactionEnvelopeInfo getEnvelopeInfo(int index) throws InvalidProtocolBufferException {
102- //
103- // try {
104- // // block.getData(0).getEnvelope().getSignature();
105- //
106- // EnvelopeDeserializer.newInstance(block.getBlock().getData().getData(index));
107- //
108- // final PayloadDeserializer payload = block.getData(index).getPayload();
109- //
110- // return new TransactionEnvelopeInfo(null, payload.getHeader());
111- // } catch (InvalidProtocolBufferRuntimeException e) {
112- // throw (InvalidProtocolBufferException) e.getCause();
113- // }
114- //
115- // }
116- //
117-
11893 public class EnvelopeInfo {
11994 private final EnvelopeDeserializer envelopeDeserializer ;
12095 HeaderDeserializer headerDeserializer ;
@@ -175,21 +150,28 @@ public EnvelopeType getType() {
175150
176151 }
177152
178- public EnvelopeInfo getEnvelopeInfo (int blockIndex ) throws InvalidProtocolBufferException {
153+ /**
154+ * Return a specific envelope in the block by it's index.
155+ *
156+ * @param envelopeIndex
157+ * @return EnvelopeInfo that contains information on the envelope.
158+ * @throws InvalidProtocolBufferException
159+ */
160+
161+ public EnvelopeInfo getEnvelopeInfo (int envelopeIndex ) throws InvalidProtocolBufferException {
179162
180163 try {
181- // block.getData(0).getEnvelope().getSignature();
182164
183165 EnvelopeInfo ret ;
184166
185- EnvelopeDeserializer ed = EnvelopeDeserializer .newInstance (block .getBlock ().getData ().getData (blockIndex ), block .getTransActionsMetaData ()[blockIndex ]);
167+ EnvelopeDeserializer ed = EnvelopeDeserializer .newInstance (block .getBlock ().getData ().getData (envelopeIndex ), block .getTransActionsMetaData ()[envelopeIndex ]);
186168
187169 switch (ed .getType ()) {
188170 case 3 :
189- ret = new TransactionEnvelopeInfo ((EndorserTransactionEnvDeserializer ) ed , blockIndex );
171+ ret = new TransactionEnvelopeInfo ((EndorserTransactionEnvDeserializer ) ed , envelopeIndex );
190172 break ;
191173 default : //just assume base properties.
192- ret = new EnvelopeInfo (ed , blockIndex );
174+ ret = new EnvelopeInfo (ed , envelopeIndex );
193175 break ;
194176
195177 }
@@ -201,9 +183,15 @@ public EnvelopeInfo getEnvelopeInfo(int blockIndex) throws InvalidProtocolBuffer
201183
202184 }
203185
186+ /**
187+ * Return and iterable EnvelopeInfo over each Envelope contained in the Block
188+ *
189+ * @return
190+ */
191+
204192 public Iterable <EnvelopeInfo > getEnvelopeInfos () {
205193
206- return new TransactionInfoIterable ();
194+ return new EnvelopeInfoIterable ();
207195 }
208196
209197 public class TransactionEnvelopeInfo extends EnvelopeInfo {
@@ -392,23 +380,11 @@ public Iterator<TransactionActionInfo> iterator() {
392380
393381 }
394382
395- /**
396- * Iterable interface over transaction info in the block.
397- *
398- * @return iterator
399- */
400-
401- public Iterable <EnvelopeInfo > getTransactionActionInfos () {
402-
403- return new TransactionInfoIterable ();
404-
405- }
406-
407- class TransactionInfoIterator implements Iterator <EnvelopeInfo > {
383+ class EnvelopeInfoIterator implements Iterator <EnvelopeInfo > {
408384 int ci = 0 ;
409385 final int max ;
410386
411- TransactionInfoIterator () {
387+ EnvelopeInfoIterator () {
412388 max = block .getData ().getDataCount ();
413389
414390 }
@@ -431,11 +407,11 @@ public EnvelopeInfo next() {
431407 }
432408 }
433409
434- class TransactionInfoIterable implements Iterable <EnvelopeInfo > {
410+ class EnvelopeInfoIterable implements Iterable <EnvelopeInfo > {
435411
436412 @ Override
437413 public Iterator <EnvelopeInfo > iterator () {
438- return new TransactionInfoIterator ();
414+ return new EnvelopeInfoIterator ();
439415 }
440416 }
441417
0 commit comments