Interface BesuEvents


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

    Currently supported events

    • BlockAdded - Fired when a new block has been evaluated and validated.
    • BlockReorg - Fired when a block is removed from the chain to change to a different chainhead.
    • 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 addBlockPropagatedListener
      • addBlockAddedListener

        long addBlockAddedListener​(BesuEvents.BlockAddedListener blockAddedListener)
        Add a listener watching for new blocks added.
        Parameters:
        blockAddedListener - The listener that will accept the Block object as the event.
        Returns:
        an id to be used as an identifier when de-registering the event.
      • removeBlockAddedListener

        void removeBlockAddedListener​(long listenerIdentifier)
        Remove the block added listener from besu notifications.
        Parameters:
        listenerIdentifier - The id that was returned from addBlockAddedListener
      • addBlockReorgListener

        long addBlockReorgListener​(BesuEvents.BlockReorgListener blockReorgListener)
        Add a listener watching for new reorg blocks added.
        Parameters:
        blockReorgListener - The listener that will accept the reorg Block object as the event.
        Returns:
        an id to be used as an identifier when de-registering the event.
      • removeBlockReorgListener

        void removeBlockReorgListener​(long listenerIdentifier)
        Remove the block reorg listener from besu notifications.
        Parameters:
        listenerIdentifier - The id that was returned from addBlockReorgListener
      • 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 addSyncStatusListener
      • 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 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 from addLogListener