bftsmart.tom.server.defaultservices

## Class DiskStateLog

- java.lang.Object
- - bftsmart.tom.server.defaultservices.StateLog
  - - bftsmart.tom.server.defaultservices.DiskStateLog

    public class DiskStateLog
    extends StateLog

### Field Summary

Fields
`static java.lang.String` `DEFAULT_DIR`

### Constructor Summary

Constructors
Constructor and Description
`DiskStateLog(int id, byte[] initialState, byte[] initialHash, boolean isToLog, boolean syncLog, boolean syncCkp)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addMessageBatch(byte[][] commands, MessageContext[] msgCtx, int consensusId)` Adds a message batch to the log.
`DefaultApplicationState` `getApplicationState(int cid, boolean sendState)` Constructs a TransferableState using this log information
`protected bftsmart.statemanagement.ApplicationState` `loadDurableState()`
`void` `newCheckpoint(byte[] state, byte[] stateHash, int consensusId)` Sets the state associated with the last checkpoint, and updates the consensus ID associated with it
`void` `setLastCID(int cid, int checkpointPeriod, int checkpointPortion)`
`void` `transferApplicationState(java.nio.channels.SocketChannel sChannel, int cid)`
`void` `update(DefaultApplicationState transState)` Updates this log, according to the information contained in the TransferableState object

### Methods inherited from class bftsmart.tom.server.defaultservices.StateLog

`getLastCheckpointCID, getLastCID, getMessageBatch, getMessageBatches, getNumBatches, getState, getStateHash, setLastCheckpointCID, setLastCID`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DEFAULT_DIR

    public static final java.lang.String DEFAULT_DIR

### Constructor Detail

#### DiskStateLog

    public DiskStateLog(int id,
                        byte[] initialState,
                        byte[] initialHash,
                        boolean isToLog,
                        boolean syncLog,
                        boolean syncCkp)

### Method Detail

#### addMessageBatch

    public void addMessageBatch(byte[][] commands,
                                MessageContext[] msgCtx,
                                int consensusId)

Adds a message batch to the log. This batches should be added to the log in the same order in which they are delivered to the application. Only the 'k' batches received after the last checkpoint are supposed to be kept

Overrides:
  `addMessageBatch` in class `StateLog`
Parameters:
  `commands` - The batch of messages to be kept.
  `consensusId` -
  `msgCtx` - The message contexts related to the commands

#### newCheckpoint

    public void newCheckpoint(byte[] state,
                              byte[] stateHash,
                              int consensusId)

Description copied from class: `StateLog`
Sets the state associated with the last checkpoint, and updates the consensus ID associated with it

Overrides:
  `newCheckpoint` in class `StateLog`
Parameters:
  `state` - State associated with the last checkpoint

#### getApplicationState

    public DefaultApplicationState getApplicationState(int cid,
                                                       boolean sendState)

Constructs a TransferableState using this log information

Overrides:
  `getApplicationState` in class `StateLog`
Parameters:
  `cid` - Consensus ID correspondent to desired state
  `sendState` -
Returns:
  TransferableState Object containing this log information

#### transferApplicationState

    public void transferApplicationState(java.nio.channels.SocketChannel sChannel,
                                         int cid)

#### setLastCID

    public void setLastCID(int cid,
                           int checkpointPeriod,
                           int checkpointPortion)

#### update

    public void update(DefaultApplicationState transState)

Updates this log, according to the information contained in the TransferableState object

Overrides:
  `update` in class `StateLog`
Parameters:
  `transState` - TransferableState object containing the information which is used to updated this log

#### loadDurableState

    protected bftsmart.statemanagement.ApplicationState loadDurableState()