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.Serializable
This 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 boolean
readOnly
-
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 int
getConsensusId()
Returns the ID of the consensus in which this request was ordered (-1 if readonly).TOMMessage
getFirstInBatch()
Returns the first request in the ordered batchint
getLeader()
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 leaderint
getNumOfNonces()
Returns the number of nonces as generated by the leaderint
getOperationId()
Returns the operation IDjava.util.Set<ConsensusMessage>
getProof()
Returns the proof for the consensus.int
getRegency()
Returns the current regency in which the message was ordered.int
getReplyServer()
Returns the ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.long
getSeed()
Returns the seed as generated by the leaderint
getSender()
Returns the ID of the client that sent the messageint
getSequence()
Returns the request's sequence numberint
getSession()
Returns the client's sessionbyte[]
getSignature()
Returns the client's signature.long
getTimestamp()
Returns the timestamp as generated by the leaderTOMMessageType
getType()
Returns the request typeint
getViewID()
Returns the view IDboolean
isLastInBatch()
Returns the last request in the ordered batchboolean
isNoOp()
Returns true if the consensus instance has no operations to deliver to the applicationTOMMessage
recreateTOMMessage(byte[] content)
Generates a TOMMessage for its associated requests using the new info that it now supports since the previous commit.void
setLastInBatch()
-
-
-
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
-
-