java.lang.Object
dev.hloth.zgztransport.TransactionLog
The ring of six blocks a card keeps its last transactions in: block 5 holds
the newest record, and the five before it live in the archive blocks, each in
the slot its sequence byte picks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe blocks holding the five records before the newest, indexed by sequence byte.The six slots, in the orderdecode(byte[][])expects.static final intThe block holding the newest record. -
Method Summary
Modifier and TypeMethodDescriptionstatic OptionalIntarchiveBlock(int sequence) The block a record moves to when a newer one replaces it.static List<Transaction> decode(byte[][] slots) Decodes the six slots of the ring, oldest record first.
-
Field Details
-
LIVE_BLOCK
public static final int LIVE_BLOCKThe block holding the newest record.- See Also:
-
ARCHIVE_BLOCKS
The blocks holding the five records before the newest, indexed by sequence byte. -
BLOCKS
The six slots, in the orderdecode(byte[][])expects.
-
-
Method Details
-
archiveBlock
The block a record moves to when a newer one replaces it.- Parameters:
sequence- the sequence byte of the record- Returns:
- the block number, or empty when the byte is not one the ring uses
-
decode
Decodes the six slots of the ring, oldest record first. Slots whose first byte is zero hold no record and are skipped; records that share a timestamp keep the order of the slots.- Parameters:
slots- the six blocks, in the order ofBLOCKS- Returns:
- the records the ring holds
- Throws:
CardFormatException- if there are not six slots or an occupied one does not decode
-