-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate_ini.py
36 lines (30 loc) · 832 Bytes
/
state_ini.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import logging
import random
import pickle
from datacenter import LogEntry
import json
CONFIG = json.load(open('config.json'))
log = [LogEntry(0, 0, {'config':'single', 'data':CONFIG['datacenters']})]
current_term = 0
voted_for = None
dictobj = {'current_term': current_term, 'voted_for': voted_for, 'log': log}
filename = "./state1.pkl"
fileobj = open(filename, 'wb')
pickle.dump(dictobj, fileobj)
fileobj.close()
filename = "./state2.pkl"
fileobj = open(filename, 'wb')
pickle.dump(dictobj, fileobj)
fileobj.close()
filename = "./state3.pkl"
fileobj = open(filename, 'wb')
pickle.dump(dictobj, fileobj)
fileobj.close()
filename = "./state4.pkl"
fileobj = open(filename, 'wb')
pickle.dump(dictobj, fileobj)
fileobj.close()
filename = "./state5.pkl"
fileobj = open(filename, 'wb')
pickle.dump(dictobj, fileobj)
fileobj.close()