rgreen312 / OwlPlace

https://rgreen312.github.io/OwlPlace/
5 stars 1 forks source link

User data modifications #19

Closed aidan-curtis closed 5 years ago

aidan-curtis commented 5 years ago

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

Both of these structs contain two properties:

  1. Type: An integer representing the type of the message (types described in server/consensus/consensus.go)
  2. Data: A string representing the data that accompanies that type

The two types that are relevant for user data modification are the following

  1. 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.
  2. 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.