Class VersionTally

java.lang.Object
org.bitcoinj.utils.VersionTally

public class VersionTally extends Object
Caching counter for the block versions within a moving window. This class is NOT thread safe (as if two threads are trying to use it concurrently, there's risk of getting versions out of sequence).
See Also:
  • Constructor Details

  • Method Details

    • add

      public void add(long version)
      Add a new block version to the tally, and return the count for that version within the window.
      Parameters:
      version - the block version to add.
    • getCountAtOrAbove

      public Integer getCountAtOrAbove(long version)
      Get the count of blocks at or above the given version, within the window.
      Parameters:
      version - the block version to query.
      Returns:
      the count for the block version, or null if the window is not yet full.
    • initialize

      public void initialize(BlockStore blockStore, StoredBlock chainHead) throws BlockStoreException
      Initialize the version tally from the block store. Note this does not search backwards past the start of the block store, so if starting from a checkpoint this may not fill the window.
      Parameters:
      blockStore - block store to load blocks from.
      chainHead - current chain tip.
      Throws:
      BlockStoreException
    • size

      public int size()
      Get the size of the version window.