Last active
July 26, 2020 03:38
-
-
Save chelseatroy/b12cc1632faf1dd991db695a046a2f41 to your computer and use it in GitHub Desktop.
Conditional Statement—Responding to append_entries Requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
if string_operation.split(" ")[0] == "append_entries": | |
# followers do this to update their logs. | |
stringified_logs_to_append = string_operation.replace("append_entries ", "") | |
print("Preparing to append: " + stringified_logs_to_append) | |
logs_to_append = ast.literal_eval(stringified_logs_to_append) | |
[key_value_store.write_to_log(log, term_absent=True) for log in logs_to_append] | |
print("State machine after appending: " + str(key_value_store.data)) | |
response = "Append entries call successful!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment