public final class LandmarkSequence
extends java.lang.Object
A LandmarkSequence captures the num_active_landmarks + 1
most recent landmarks (numbered last_landmark - num_active_landmarks
through last_landmark), with each landmark's tree size. Landmark 0
always has tree size 0; subsequent landmarks are strictly monotonically
increasing in tree size and consecutive in landmark number.
The published wire format (Section 6.3.3) is plain UTF-8 text:
<last_landmark> <num_active_landmarks> tree_size of landmark last_landmark tree_size of landmark last_landmark - 1 ... tree_size of landmark last_landmark - num_active_landmarks
Each line is terminated with U+000A. Tree sizes within the sequence MUST be strictly monotonically decreasing reading from line 1 to line N.
| Constructor and Description |
|---|
LandmarkSequence(long lastLandmark,
long[] treeSizesNewestFirst) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<long[]> |
activeLandmarkSubtrees()
Returns the landmark subtree intervals determined by this sequence per
Section 6.3.1: between consecutive landmarks (excluding landmark 0) the
interval
[prev_tree_size, tree_size) is covered by one or two
subtrees from MerkleTreePrimitives.findCoveringSubtrees(long, long). |
java.lang.String |
format()
Serializes the landmark sequence in the format defined by Section 6.3.3
(each line terminated with U+000A).
|
long |
getLastLandmark() |
int |
getNumActiveLandmarks() |
long |
getTreeSize(long landmarkNumber) |
static LandmarkSequence |
parse(java.lang.String text)
Parses a landmark sequence from its published text form (Section 6.3.3).
|
public LandmarkSequence(long lastLandmark,
long[] treeSizesNewestFirst)
lastLandmark - the landmark number of the newest landmarktreeSizesNewestFirst - tree sizes for landmarks
lastLandmark down to
lastLandmark - treeSizes.length + 1;
must be strictly monotonically decreasingpublic static LandmarkSequence parse(java.lang.String text) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String format()
public long getLastLandmark()
public int getNumActiveLandmarks()
num_active_landmarks as published (one less than the tree size count).public long getTreeSize(long landmarkNumber)
public java.util.List<long[]> activeLandmarkSubtrees()
[prev_tree_size, tree_size) is covered by one or two
subtrees from MerkleTreePrimitives.findCoveringSubtrees(long, long). The
returned list is ordered oldest-first.