private synchronized void setLastBlockSeen(BlockEvent lastBlockSeen) { long newLastBlockNumber = lastBlockSeen.getBlockNumber(); // overkill but make sure. if (lastBlockNumber < newLastBlockNumber) { lastBlockNumber = newLastBlockNumber; this.lastBlockEvent = lastBlockSeen; if (IS_TRACE_LEVEL) { logger.trace(toString() + " last block seen: " + lastBlockNumber); } } }
TransactionEvent getTransactionEvent(int index) throws InvalidProtocolBufferException { TransactionEvent ret = null; EnvelopeInfo envelopeInfo = getEnvelopeInfo(index); if (envelopeInfo.getType() == EnvelopeType.TRANSACTION_ENVELOPE) { if (isFiltered()) { ret = new TransactionEvent(getEnvelopeInfo(index).filteredTx); } else { ret = new TransactionEvent((TransactionEnvelopeInfo) getEnvelopeInfo(index)); } } return ret; }
/** * The event hub that received this event. * * @return May return null if peer eventing service detected the event. * @deprecated use new peer eventing services {@link #getPeer()} */ public EventHub getEventHub() { return BlockEvent.this.getEventHub(); }
List<TransactionEvent> getTransactionEventsList() { ArrayList<TransactionEvent> ret = new ArrayList<TransactionEvent>(getTransactionCount()); for (TransactionEvent transactionEvent : getTransactionEvents()) { ret.add(transactionEvent); } return ret; }
@Override public void onNext(PeerEvents.Event event) { logger.debug(format("%s got event type: %s", EventHub.this.toString(), event.getEventCase().name())); if (event.getEventCase() == PeerEvents.Event.EventCase.BLOCK) { try { BlockEvent blockEvent = new BlockEvent(EventHub.this, event); logger.trace(format("%s got block number: %d", EventHub.this.toString(), blockEvent.getBlockNumber())); setLastBlockSeen(blockEvent); eventQue.addBEvent(blockEvent); //add to channel queue } catch (InvalidProtocolBufferException e) { EventHubException eventHubException = new EventHubException(format("%s onNext error %s", this, e.getMessage()), e); logger.error(eventHubException.getMessage()); threw.add(eventHubException); } } else if (event.getEventCase() == PeerEvents.Event.EventCase.REGISTER) { if (reconnectCount > 1) { logger.info(format("%s has reconnecting after %d attempts", EventHub.this.toString(), reconnectCount)); } connected = true; connectedTime = System.currentTimeMillis(); reconnectCount = 0L; finishLatch.countDown(); } else { logger.error(format("%s got a unexpected block type: %s", EventHub.this.toString(), event.getEventCase().name())); } }
BlockEvent blockEvent = new BlockEvent(peer, resp); peer.setLastBlockSeen(blockEvent);
TransactionEventIterator() { max = getTransactionCount(); }
/** * The peer that received this event. * * @return May return null if deprecated eventhubs are still being used, otherwise return the peer. */ public Peer getPeer() { return BlockEvent.this.getPeer(); } }
@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); } ++returned; return ret; } }
List<TransactionEvent> getTransactionEventsList() { ArrayList<TransactionEvent> ret = new ArrayList<TransactionEvent>(getTransactionCount()); for (TransactionEvent transactionEvent : getTransactionEvents()) { ret.add(transactionEvent); } return ret; }
@Override public void onNext(PeerEvents.Event event) { logger.debug(format("%s got event type: %s", EventHub.this.toString(), event.getEventCase().name())); if (event.getEventCase() == PeerEvents.Event.EventCase.BLOCK) { try { BlockEvent blockEvent = new BlockEvent(EventHub.this, event); logger.trace(format("%s got block number: %d", EventHub.this.toString(), blockEvent.getBlockNumber())); setLastBlockSeen(blockEvent); eventQue.addBEvent(blockEvent); //add to channel queue } catch (InvalidProtocolBufferException e) { EventHubException eventHubException = new EventHubException(format("%s onNext error %s", this, e.getMessage()), e); logger.error(eventHubException.getMessage()); threw.add(eventHubException); } } else if (event.getEventCase() == PeerEvents.Event.EventCase.REGISTER) { if (reconnectCount > 1) { logger.info(format("%s has reconnecting after %d attempts", EventHub.this.toString(), reconnectCount)); } connected = true; connectedTime = System.currentTimeMillis(); reconnectCount = 0L; finishLatch.countDown(); } else { logger.error(format("%s got a unexpected block type: %s", EventHub.this.toString(), event.getEventCase().name())); } }
@Override public void onNext(PeerEvents.Event event) { logger.debug(format("EventHub %s got event type: %s", EventHub.this.name, event.getEventCase().name())); if (event.getEventCase() == PeerEvents.Event.EventCase.BLOCK) { try { BlockEvent blockEvent = new BlockEvent(EventHub.this, event); setLastBlockSeen(blockEvent); eventQue.addBEvent(blockEvent); //add to channel queue } catch (InvalidProtocolBufferException e) { EventHubException eventHubException = new EventHubException(format("%s onNext error %s", this, e.getMessage()), e); logger.error(eventHubException.getMessage()); threw.add(eventHubException); } } else if (event.getEventCase() == PeerEvents.Event.EventCase.REGISTER) { if (reconnectCount > 1) { logger.info(format("Eventhub %s has reconnecting after %d attempts", name, reconnectCount)); } connected = true; connectedTime = System.currentTimeMillis(); reconnectCount = 0L; finishLatch.countDown(); } }
TransactionEventIterator() { max = getTransactionCount(); }
/** * The peer that received this event. * * @return May return null if deprecated eventhubs are still being used, otherwise return the peer. */ public Peer getPeer() { return BlockEvent.this.getPeer(); } }
@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); } ++returned; return ret; } }
TransactionEvent getTransactionEvent(int index) throws InvalidProtocolBufferException { TransactionEvent ret = null; EnvelopeInfo envelopeInfo = getEnvelopeInfo(index); if (envelopeInfo.getType() == EnvelopeType.TRANSACTION_ENVELOPE) { if (isFiltered()) { ret = new TransactionEvent(getEnvelopeInfo(index).filteredTx); } else { ret = new TransactionEvent((TransactionEnvelopeInfo) getEnvelopeInfo(index)); } } return ret; }
List<TransactionEvent> getTransactionEventsList() { ArrayList<TransactionEvent> ret = new ArrayList<TransactionEvent>(getTransactionCount()); for (TransactionEvent transactionEvent : getTransactionEvents()) { ret.add(transactionEvent); } return ret; }
synchronized void setLastBlockSeen(BlockEvent lastBlockSeen) { connected = true; long newLastBlockNumber = lastBlockSeen.getBlockNumber(); // overkill but make sure. if (lastBlockNumber < newLastBlockNumber) { lastBlockNumber = newLastBlockNumber; this.lastBlockEvent = lastBlockSeen; if (IS_TRACE_LEVEL) { logger.trace(toString() + " last block seen: " + lastBlockNumber); } } }
BlockEvent blockEvent = new BlockEvent(peer, resp); peer.setLastBlockSeen(blockEvent);
/** * The event hub that received this event. * * @return May return null if peer eventing service detected the event. * @deprecated use new peer eventing services {@link #getPeer()} */ public EventHub getEventHub() { return BlockEvent.this.getEventHub(); }