-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_pseudo.py
More file actions
61 lines (21 loc) · 743 Bytes
/
node_pseudo.py
File metadata and controls
61 lines (21 loc) · 743 Bytes
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Node :
----
ip_to_id = {} #Indexed by ip, returns (id,pk)
key_fragment_arr = [[]] #Indexed by [from][to] contains corresponding fragment
available_ids = [] #queue containing the available ids
usr_cmds = ['usr_send_msg', 'usr_send_frag' ,'usr_exit']
node_cmds = ['node_new_user', 'node_new_msg']
def set_fragment(_from, to, frag):
key_fragment_arr[_from][to] = frag
def remove(ip):
'''
User of <ip> is remove from the chat
'''
rem_id = ip_to_id[ip]
for _from in key_fragment_arr:
set_fragment(_from, rem_id, None)
for usr in all_users:
set_fragment(rem_id, usr, None)
available_ids += [rem_id]
def register(ip, pubkey):
def notify_user(cmd, user_id, npk):