Module convex.peer
Package convex.peer

Class TransactionHandler

java.lang.Object
convex.peer.AThreadedComponent
convex.peer.TransactionHandler

public class TransactionHandler extends AThreadedComponent
Server component for handling client transactions and producing Blocks Main loop for this component handles client transaction messages, validates them and prepares them for inclusion in a Block
  • Field Details

    • txMessageQueue

      protected final ArrayBlockingQueue<Message> txMessageQueue
      Queue for incoming (unverified) transaction messages
    • clientTransactionCount

      public long clientTransactionCount
    • receivedTransactionCount

      public long receivedTransactionCount
    • lastBlockPublishedTime

      protected long lastBlockPublishedTime
      Time at which last Block was published by this Peer
  • Constructor Details

    • TransactionHandler

      public TransactionHandler(Server server)
  • Method Details

    • offerTransaction

      public boolean offerTransaction(Message m)
      Offer a transaction for handling
      Parameters:
      m - Message offered
      Returns:
      True if queued for handling, false otherwise
    • processMessage

      protected void processMessage(Message m) throws InterruptedException
      Throws:
      InterruptedException
    • setRequestObserver

      public void setRequestObserver(Consumer<SignedData<ATransaction>> observer)
      Sets a request observer, which will be called whenever the Peer processes a valid client transaction request
      Parameters:
      observer - Consumer to receive observed transaction
    • maybeReportTransactions

      public void maybeReportTransactions(Peer peer)
    • setResponseObserver

      public void setResponseObserver(BiConsumer<SignedData<ATransaction>,Result> observer)
      Sets a request observer, which will be called whenever the Peer processes a valid client transaction request
      Parameters:
      observer - Consumer to receive observed transaction
    • maybeGenerateBlocks

      protected SignedData<Block>[] maybeGenerateBlocks()
      Gets the next Blocks for publication, or null if nothing to publish Checks for pending transactions, and if found propose them as new Block(s).
      Returns:
      New signed Block, or null if nothing to publish yet
    • start

      public void start()
      Description copied from class: AThreadedComponent
      Start the threaded component
      Overrides:
      start in class AThreadedComponent
    • isAwaitingResults

      public boolean isAwaitingResults()
    • countInterests

      public int countInterests()
    • loop

      protected void loop() throws InterruptedException
      Loops for handling incoming client transactions
      Specified by:
      loop in class AThreadedComponent
      Throws:
      InterruptedException
    • getThreadName

      protected String getThreadName()
      Specified by:
      getThreadName in class AThreadedComponent