Package bftsmart.tom
Class MessageContext
- java.lang.Object
-
- bftsmart.tom.MessageContext
-
- All Implemented Interfaces:
java.io.Serializable
public class MessageContext extends java.lang.Object implements java.io.SerializableThis class represents the whole context of a request ordered in the system. It stores all informations regarding the message sent by the client, as well as the consensus instance in which it was ordered.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description booleanreadOnly
-
Constructor Summary
Constructors Constructor Description MessageContext(int sender, int viewID, TOMMessageType type, int session, int sequence, int operationId, int replyServer, byte[] signature, long timestamp, int numOfNonces, long seed, int regency, int leader, int consensusId, java.util.Set<ConsensusMessage> proof, TOMMessage firstInBatch, boolean noOp)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetConsensusId()Returns the ID of the consensus in which this request was ordered (-1 if readonly).TOMMessagegetFirstInBatch()Returns the first request in the ordered batchintgetLeader()Returns the id of the leader replica in which this message was ordered (-1 if readonly).byte[]getNonces()Returns the nonces as generated by the leaderintgetNumOfNonces()Returns the number of nonces as generated by the leaderintgetOperationId()Returns the operation IDjava.util.Set<ConsensusMessage>getProof()Returns the proof for the consensus.intgetRegency()Returns the current regency in which the message was ordered.intgetReplyServer()Returns the ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.longgetSeed()Returns the seed as generated by the leaderintgetSender()Returns the ID of the client that sent the messageintgetSequence()Returns the request's sequence numberintgetSession()Returns the client's sessionbyte[]getSignature()Returns the client's signature.longgetTimestamp()Returns the timestamp as generated by the leaderTOMMessageTypegetType()Returns the request typeintgetViewID()Returns the view IDbooleanisLastInBatch()Returns the last request in the ordered batchbooleanisNoOp()Returns true if the consensus instance has no operations to deliver to the applicationTOMMessagerecreateTOMMessage(byte[] content)Generates a TOMMessage for its associated requests using the new info that it now supports since the previous commit.voidsetLastInBatch()
-
-
-
Constructor Detail
-
MessageContext
public MessageContext(int sender, int viewID, TOMMessageType type, int session, int sequence, int operationId, int replyServer, byte[] signature, long timestamp, int numOfNonces, long seed, int regency, int leader, int consensusId, java.util.Set<ConsensusMessage> proof, TOMMessage firstInBatch, boolean noOp)Constructor- Parameters:
sender- The sender IDviewID- The view IDtype- The request typesession- Client's sessionsequence- Request's sequence numberoperationId- The operation IDreplyServer- ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.signature- Client's signature.timestamp- The timestamp as generated by the leadernumOfNonces- The nonces as generated by the leaderseed- The seed as generated by the leaderregency- The current regency in which the message was ordered.leader- The leader with which the batch was decidedconsensusId- The ID of the consensus in which this request was orderedproof- The proof for the consensusfirstInBatch- The first request in the ordered batchnoOp- true if the consensus instance has no operations to deliver to the application
-
-
Method Detail
-
getViewID
public int getViewID()
Returns the view ID- Returns:
- The view ID
-
getType
public TOMMessageType getType()
Returns the request type- Returns:
- The request type
-
getSession
public int getSession()
Returns the client's session- Returns:
- Client's session
-
getSequence
public int getSequence()
Returns the request's sequence number- Returns:
- Request's sequence number
-
getOperationId
public int getOperationId()
Returns the operation ID- Returns:
- The operation ID
-
getReplyServer
public int getReplyServer()
Returns the ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.- Returns:
- ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.
-
getSignature
public byte[] getSignature()
Returns the client's signature.- Returns:
- Client's signature.
-
getSender
public int getSender()
Returns the ID of the client that sent the message- Returns:
- The sender ID
-
getTimestamp
public long getTimestamp()
Returns the timestamp as generated by the leader- Returns:
- The timestamp as generated by the leader
-
getNonces
public byte[] getNonces()
Returns the nonces as generated by the leader- Returns:
- The nonces as generated by the leader
-
getNumOfNonces
public int getNumOfNonces()
Returns the number of nonces as generated by the leader- Returns:
- the number of nonces
-
getSeed
public long getSeed()
Returns the seed as generated by the leader- Returns:
- The seed as generated by the leader
-
getConsensusId
public int getConsensusId()
Returns the ID of the consensus in which this request was ordered (-1 if readonly).- Returns:
- The ID of the consensus in which this request was ordered
-
getLeader
public int getLeader()
Returns the id of the leader replica in which this message was ordered (-1 if readonly).- Returns:
- The leader with which the batch was decided
-
getProof
public java.util.Set<ConsensusMessage> getProof()
Returns the proof for the consensus.- Returns:
- The proof for the consensus
-
getRegency
public int getRegency()
Returns the current regency in which the message was ordered.- Returns:
- The current regency in which the message was ordered.
-
getFirstInBatch
public TOMMessage getFirstInBatch()
Returns the first request in the ordered batch- Returns:
- The first request in the ordered batch
-
setLastInBatch
public void setLastInBatch()
-
isLastInBatch
public boolean isLastInBatch()
Returns the last request in the ordered batch- Returns:
- The last request in the ordered batch
-
isNoOp
public boolean isNoOp()
Returns true if the consensus instance has no operations to deliver to the application- Returns:
- true if the consensus instance has no operations to deliver to the application
-
recreateTOMMessage
public TOMMessage recreateTOMMessage(byte[] content)
Generates a TOMMessage for its associated requests using the new info that it now supports since the previous commit. It is assumed that the byte array passed to this method is the serialized request associated to the original TOMMessage.- Parameters:
content- Serialized request associated to the original TOMMessage.- Returns:
- A TOMMessage object that is equal to the original object issued by the client
-
-