Skip to content

Commit ce41ca5

Browse files
committedJan 19, 2021
_id from clients
1 parent 90fefcd commit ce41ca5

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed
 

‎client/app.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
)
4343

4444
client = Client(args.client_number, port, num_clients, args.split_type)
45-
state = State('client', client.client_id, port)
45+
46+
# _id auto generated by State
47+
state = State('client', port, _id=None)
4648

4749
app = Flask(__name__)
4850

‎frontend/app.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ def check_clients_ok():
2525
else:
2626
client['check_ok'] = True
2727

28-
def get_id(host, port):
29-
return 'client_{}_{}'.format(host, port)
30-
31-
3228
@app.route('/')
3329
def index():
3430
check_clients_ok()
@@ -60,7 +56,7 @@ def fake_data():
6056
client = random.choice(client_types)
6157
status = random.choice(statuses)
6258
check_ok = random.choice([True, False])
63-
_id = 'client_127.0.0.1_{}'.format(port)
59+
_id = 'fake_client_{}'.format(port)
6460
data = {
6561
'client_type': client,
6662
'_id': _id,
@@ -87,7 +83,7 @@ def keep_alive():
8783
data = json.loads(request.data)
8884
host = request.remote_addr
8985
port = data['port']
90-
_id = get_id(host, port)
86+
_id = data['_id']
9187
if _id not in global_state['clients']:
9288
global_state['clients'][_id] = {
9389
'joined_at': datetime.now().strftime('%Y-%m-%d %H:%m'),
@@ -118,7 +114,7 @@ def get_state():
118114
host = request.remote_addr
119115
data = json.loads(request.data)
120116
port = data['port']
121-
_id = get_id(host, port)
117+
_id = data['_id']
122118
if _id not in global_state['clients']:
123119
global_state['clients'][_id] = {
124120
'joined_at': datetime.now().strftime('%Y-%m-%d %H:%m'),

‎main_server/app.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
rsa = rsa_utils.RSAUtils()
3434
args = parser.parse_args()
3535
hosts = utils.read_hosts()
36-
state = State('main_server', 'client_{}'.format(args.port), args.port)
36+
37+
# _id auto generated by State
38+
state = State('main_server', args.port, _id=None)
3739

3840
app = Flask(__name__)
3941

‎secure_aggregator/app.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
use_cuda = True
2828
sec_agg = SecAgg(args.port, use_cuda)
29-
state = State('secure_aggregator', sec_agg.client_id, args.port)
29+
30+
# _id auto generated by State
31+
state = State('secure_aggregator', args.port, _id=None)
3032

3133

3234
app = Flask(__name__)

0 commit comments

Comments
 (0)
Please sign in to comment.