Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created July 26, 2020 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/7a48a37ad3f2e13023daf1945232ecdf to your computer and use it in GitHub Desktop.
Save chelseatroy/7a48a37ad3f2e13023daf1945232ecdf to your computer and use it in GitHub Desktop.
Committing the Entry as the Leader
...
else:
if self.leader:
self.current_operation = string_operation
if self.current_operation.split(" ")[0] in ["set", "delete"]:
key_value_store.write_to_log(string_operation, term_absent=True)
broadcast(self, with_return_address(self, "append_entries ['" + self.current_operation + "']"))
while not self.current_operation_committed:
pass
send_pending = False
else:
response = key_value_store.read(self.current_operation)
else:
response = "I am not the leader. Please leave me alone."
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment