Class CSTState
- java.lang.Object
-
- bftsmart.statemanagement.durability.CSTState
-
- All Implemented Interfaces:
ApplicationState,java.io.Serializable
public class CSTState extends java.lang.Object implements ApplicationState
Stores the data used to transfer the state to a recovering replica. This class serves the three different seeders defined in the CST optimized version for f=1. In that version, the newest replica to take the checkpoint is expected to send the hash of the checkpoint plus the upper portion of the log. The replica which took the checkpoint before that, i.e., the middle replica is expected to send the checkpoint it has plus hashes of the lower and upper portions of the log. The oldest replica to take the checkpoint must send the lower portion of the log. This object must be passed to the state manager class which will combine the replies from the seeders, validating the values and updating the state in the leecher.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CSTState(byte[] state, byte[] hashCheckpoint, CommandsInfo[] logLower, byte[] hashLogLower, CommandsInfo[] logUpper, byte[] hashLogUpper, int checkpointCID, int lastCID, int pid)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CertifiedDecisiongetCertifiedDecision(ServerViewController controller)Retrieves the certified decision for the last consensus present in this objectintgetCheckpointCID()byte[]getHashCheckpoint()byte[]getHashLogLower()byte[]getHashLogUpper()intgetLastCID()The consensus of the last batch of commands which the application was givenCommandsInfo[]getLogLower()CommandsInfo[]getLogUpper()CommandsInfogetMessageBatch(int cid)Retrieves the specified batch of messagesbyte[]getSerializedState()Byte array that must be a representation of the application statebyte[]getStateHash()Gets an secure hash of the application statebooleanhasState()Indicates if the sender replica had the state requested by the recovering replicavoidsetSerializedState(byte[] state)Sets a byte array that must be a representation of the application state-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface bftsmart.statemanagement.ApplicationState
equals, hashCode
-
-
-
-
Constructor Detail
-
CSTState
public CSTState(byte[] state, byte[] hashCheckpoint, CommandsInfo[] logLower, byte[] hashLogLower, CommandsInfo[] logUpper, byte[] hashLogUpper, int checkpointCID, int lastCID, int pid)
-
-
Method Detail
-
hasState
public boolean hasState()
Description copied from interface:ApplicationStateIndicates if the sender replica had the state requested by the recovering replica- Specified by:
hasStatein interfaceApplicationState- Returns:
- true if the sender replica had the state requested by the recovering replica, false otherwise
-
getSerializedState
public byte[] getSerializedState()
Description copied from interface:ApplicationStateByte array that must be a representation of the application state- Specified by:
getSerializedStatein interfaceApplicationState- Returns:
- A byte array that must be a representation of the application state
-
getStateHash
public byte[] getStateHash()
Description copied from interface:ApplicationStateGets an secure hash of the application state- Specified by:
getStateHashin interfaceApplicationState- Returns:
- Secure hash of the application state
-
setSerializedState
public void setSerializedState(byte[] state)
Description copied from interface:ApplicationStateSets a byte array that must be a representation of the application state- Specified by:
setSerializedStatein interfaceApplicationState- Parameters:
state- a byte array that must be a representation of the application state
-
getLastCID
public int getLastCID()
Description copied from interface:ApplicationStateThe consensus of the last batch of commands which the application was given- Specified by:
getLastCIDin interfaceApplicationState- Returns:
- consensus of the last batch of commands which the application was given
-
getCertifiedDecision
public CertifiedDecision getCertifiedDecision(ServerViewController controller)
Retrieves the certified decision for the last consensus present in this object- Specified by:
getCertifiedDecisionin interfaceApplicationState- Parameters:
controller-- Returns:
- The certified decision for the last consensus present in this object
-
getCheckpointCID
public int getCheckpointCID()
-
getMessageBatch
public CommandsInfo getMessageBatch(int cid)
Retrieves the specified batch of messages- Parameters:
cid- Consensus ID associated with the batch to be fetched- Returns:
- The batch of messages associated with the batch correspondent consensus ID
-
getHashLogUpper
public byte[] getHashLogUpper()
-
getHashLogLower
public byte[] getHashLogLower()
-
getLogUpper
public CommandsInfo[] getLogUpper()
-
getLogLower
public CommandsInfo[] getLogLower()
-
getHashCheckpoint
public byte[] getHashCheckpoint()
-
-