This pull request equips the backend API with two additional functions for storing and modifying user data. Communication with the consensus module is mediated using two channels
ApiServer.sendc: A channel for sending consensus.BackendMessage structs to the consensus module
ApiServer.recv: A channel for receiving consensus.ConsensusMessage structs from the consensus module
Both of these structs contain two properties:
Type: An integer representing the type of the message (types described in server/consensus/consensus.go)
Data: A string representing the data that accompanies that type
The two types that are relevant for user data modification are the following
consensus.GET_LAST_USER_UPDATE: Data is "get %s" where %s corresponds to the user id. The consensus module will return an error if no user is found with that id or a string timestamp for the last user modification.
consensus.SET_LAST_USER_UPDATE: Data is "put %s %s" where the first string is the user id and the second string is the timestamp. The consensus module will return a success message if the store was successful or a failure message if there was an error in processing the message.
Examples for how to use the channels and the data structs can be found in the GetLastUserModification and SetLastUserModification of the server/apiserver/apiserver.go file.
This pull request equips the backend API with two additional functions for storing and modifying user data. Communication with the consensus module is mediated using two channels
consensus.BackendMessage
structs to the consensus moduleconsensus.ConsensusMessage
structs from the consensus moduleBoth of these structs contain two properties:
The two types that are relevant for user data modification are the following
consensus.GET_LAST_USER_UPDATE
: Data is "get %s" where %s corresponds to the user id. The consensus module will return an error if no user is found with that id or a string timestamp for the last user modification.consensus.SET_LAST_USER_UPDATE
: Data is "put %s %s" where the first string is the user id and the second string is the timestamp. The consensus module will return a success message if the store was successful or a failure message if there was an error in processing the message.Examples for how to use the channels and the data structs can be found in the
GetLastUserModification
andSetLastUserModification
of the server/apiserver/apiserver.go file.