Class BlockchainEvent.ForkDetectedEvent

java.lang.Object
com.privatechain.core.event.BlockchainEvent
com.privatechain.core.event.BlockchainEvent.ForkDetectedEvent
Enclosing class:
BlockchainEvent

public static final class BlockchainEvent.ForkDetectedEvent extends BlockchainEvent
Fired when the node detects two competing valid blocks at the same chain height.

The Blockchain resolves forks by applying the longest-chain (greatest cumulative difficulty) rule. This event is published before resolution so that observers can log or alert on the fork. Use getBlockA() and getBlockB() to inspect the competing blocks.

Since:
1.0.0
  • Constructor Details

    • ForkDetectedEvent

      public ForkDetectedEvent(Block blockA, Block blockB)
      Constructs a ForkDetectedEvent.
      Parameters:
      blockA - first competing block (non-null)
      blockB - second competing block (non-null)
      Throws:
      NullPointerException - if either block is null
  • Method Details

    • getBlockA

      public Block getBlockA()
      Returns the first competing block.
      Returns:
      non-null Block
    • getBlockB

      public Block getBlockB()
      Returns the second competing block.
      Returns:
      non-null Block
    • toString

      public String toString()
      Overrides:
      toString in class Object