public class StateLog
extends java.lang.Object
Constructor and Description |
---|
StateLog(int id,
byte[] initialState,
byte[] initialHash) |
StateLog(int id,
int k)
Constructs a State log
|
StateLog(int id,
int k,
byte[] initialState,
byte[] initialHash)
Constructs a State log
|
Modifier and Type | Method and Description |
---|---|
void |
addMessageBatch(byte[][] commands,
MessageContext[] msgCtx,
int lastConsensusId)
Adds a message batch to the log.
|
DefaultApplicationState |
getApplicationState(int cid,
boolean setState)
Constructs a TransferableState using this log information
|
int |
getLastCheckpointCID()
Retrieves the consensus ID for the last checkpoint
|
int |
getLastCID()
Retrieves the consensus ID for the last messages batch delivered to the application
|
CommandsInfo |
getMessageBatch(int cid)
Returns a batch of messages, given its correspondent consensus ID
|
CommandsInfo[] |
getMessageBatches()
Retrieves all the stored batches kept since the last checkpoint
|
int |
getNumBatches()
Retrieves the total number of stored batches kept since the last checkpoint
|
byte[] |
getState()
Retrieves the state associated with the last checkpoint
|
byte[] |
getStateHash()
Retrieves the hash of the state associated with the last checkpoint
|
void |
newCheckpoint(byte[] state,
byte[] stateHash,
int lastConsensusId)
Sets the state associated with the last checkpoint, and updates the consensus ID associated with it
|
void |
setLastCheckpointCID(int lastCheckpointCID)
Sets the consensus ID for the last checkpoint
|
void |
setLastCID(int lastCID)
Sets the consensus ID for the last messages batch delivered to the application
|
void |
update(DefaultApplicationState transState)
Updates this log, according to the information contained in the TransferableState object
|
public StateLog(int id, int k, byte[] initialState, byte[] initialHash)
id
- k
- The checkpoint periodinitialState
- initialHash
- public StateLog(int id, int k)
id
- k
- The checkpoint periodpublic StateLog(int id, byte[] initialState, byte[] initialHash)
public void newCheckpoint(byte[] state, byte[] stateHash, int lastConsensusId)
state
- State associated with the last checkpointstateHash
- lastConsensusId
- public void setLastCheckpointCID(int lastCheckpointCID)
lastCheckpointCID
- Consensus ID for the last checkpointpublic int getLastCheckpointCID()
public void setLastCID(int lastCID)
lastCID
- the consensus ID for the last messages batch delivered to the applicationpublic int getLastCID()
public byte[] getState()
public byte[] getStateHash()
public void addMessageBatch(byte[][] commands, MessageContext[] msgCtx, int lastConsensusId)
commands
- The batch of messages to be kept.msgCtx
- The message contexts related to the commandslastConsensusId
- public CommandsInfo getMessageBatch(int cid)
cid
- Consensus ID associated with the batch to be fetchedpublic CommandsInfo[] getMessageBatches()
public int getNumBatches()
public DefaultApplicationState getApplicationState(int cid, boolean setState)
cid
- Consensus ID correspondent to desired statesetState
- public void update(DefaultApplicationState transState)
transState
- TransferableState object containing the information which is used to updated this log