Package org.bitcoinj.utils
Class VersionTally
java.lang.Object
org.bitcoinj.utils.VersionTally
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).
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long version) Add a new block version to the tally, and return the count for that version within the window.getCountAtOrAbove
(long version) Get the count of blocks at or above the given version, within the window.void
initialize
(BlockStore blockStore, StoredBlock chainHead) Initialize the version tally from the block store.int
size()
Get the size of the version window.
-
Constructor Details
-
VersionTally
-
-
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
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
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.
-