Interface BesuEvents


  • public interface BesuEvents
    This service allows plugins to attach to various events during the normal operation of Besu.

    Currently supported events

    • BlockPropagated - Fired when a new block header has been received and validated and is about to be sent out to other peers, but before the body of the block has been evaluated and validated.
    • TransactionAdded - Fired when a new transaction has been added to the node.
    • TransactionDropped - Fired when a new transaction has been dropped from the node.
    • Logs - Fired when a new block containing logs is received.
    • SynchronizerStatus - Fired when the status of the synchronizer changes.
    • Method Detail

      • addBlockPropagatedListener

        long addBlockPropagatedListener​(BesuEvents.BlockPropagatedListener blockPropagatedListener)
        Add a listener watching new blocks propagated.
        Parameters:
        blockPropagatedListener - The listener that will accept a BlockHeader as the event.
        Returns:
        an id to be used as an identifier when de-registering the event.
      • removeBlockPropagatedListener

        void removeBlockPropagatedListener​(long listenerIdentifier)
        Remove the blockAdded listener from besu notifications.
        Parameters:
        listenerIdentifier - The id that was returned from addBlockAddedListener;
      • addTransactionAddedListener

        long addTransactionAddedListener​(BesuEvents.TransactionAddedListener transactionAddedListener)
        Add a listener watching new transactions added to the node.
        Parameters:
        transactionAddedListener - The listener that will accept the Transaction object as the event.
        Returns:
        an id to be used as an identifier when de-registering the event.
      • removeTransactionAddedListener

        void removeTransactionAddedListener​(long listenerIdentifier)
        Remove the blockAdded listener from besu notifications.
        Parameters:
        listenerIdentifier - The id that was returned from addTransactionAddedListener;
      • addTransactionDroppedListener

        long addTransactionDroppedListener​(BesuEvents.TransactionDroppedListener transactionDroppedListener)
        Add a listener watching dropped transactions.
        Parameters:
        transactionDroppedListener - The listener that will accept the Transaction object as the event.
        Returns:
        an id to be used as an identifier when de-registering the event.
      • removeTransactionDroppedListener

        void removeTransactionDroppedListener​(long listenerIdentifier)
        Remove the transactionDropped listener from besu notifications.
        Parameters:
        listenerIdentifier - The id that was returned from addTransactionDroppedListener;
      • addSyncStatusListener

        long addSyncStatusListener​(BesuEvents.SyncStatusListener syncStatusListener)
        Add a listener watching the synchronizer status.
        Parameters:
        syncStatusListener - The listener that will accept the SyncStatus object as the event.
        Returns:
        The id to be used as an identifier when de-registering the event.
      • removeSyncStatusListener

        void removeSyncStatusListener​(long listenerIdentifier)
        Remove the sync status listener from besu notifications.
        Parameters:
        listenerIdentifier - The id that was returned from addTransactionDroppedListener;
      • addLogListener

        long addLogListener​(java.util.List<Address> addresses,
                            java.util.List<java.util.List<org.apache.tuweni.bytes.Bytes32>> topics,
                            BesuEvents.LogListener logListener)
        Add a listener that consumes every log (both added and removed) that matches the filter parameters when a new block is added to the blockchain.
        Parameters:
        addresses - The addresses from which the log filter will be created
        topics - The topics from which the log filter will be created
        logListener - The listener that will accept the log.
        Returns:
        The id of the listener to be referred to used to remove the listener.
      • removeLogListener

        void removeLogListener​(long listenerIdentifier)
        Remove the log listener with the associated id.
        Parameters:
        listenerIdentifier - The id of the listener that was returned when the listener was created.