tree checksum vpatch file split hunks
all signers:
antecedents: 9985-single-thread
press order:
patch:
(437 . 7)(437 . 7)- F6B26AA5D1367C471975FF5E943315E7136AB40D21C7A329E030A2CFFFC06B4E8C3C143844560DB05B9233087617D571B0D460F0C4FF63E61AFC58D79FD4A986
5 if peer:
6 self.pest_reply("keys:")
7 for key in peer.keys:
8 self.pest_reply("%s" % key)
9 self.pest_reply("'%s'" % key)
10 else:
11 self.pest_reply("unknown peer: %s" % handle)
12
(450 . 8)(450 . 11)
14 self.state.add_peer(arguments[0])
15 self.pest_reply("added new peer %s" % arguments[0])
16 self.message(":%s JOIN %s" % (arguments[0], self.server.channel_name))
17 except:
18 except Exception, ex:
19 self.pest_reply("error attempting to add peer %s" % arguments[0])
20 stack = traceback.format_exc()
21 logging.debug(ex)
22 logging.debug(stack)
23 else:
24 self.pest_reply("Usage: PEER <HANDLE>")
25
(461 . 9)(464 . 10)
27 self.state.remove_peer(arguments[0])
28 self.pest_reply("removed peer %s" % arguments[0])
29 self.message(":%s PART %s" % (arguments[0], self.server.channel_name))
30 except Exception, e:
31 logging.debug(e)
32 self.pest_reply("Error attempting to remove peer")
33 except Exception, ex:
34 self.pest_reply("Error attempting to remove peer: %s" % ex)
35 stack = traceback.format_exc()
36 logging.debug(stack)
37 else:
38 self.pest_reply("Usage: UNPEER <HANDLE>")
39
(503 . 13)(507 . 14)
41 try:
42 handle, address = arguments
43 address_ip, port = string.split(address, ":")
44 self.state.update_at({"handle": handle,
45 "address": address_ip,
46 "port": port},
47 False)
48 self.state.update_at(
49 {"handle": handle,
50 "address": address_ip,
51 "port": int(port)},
52 False)
53 self.pest_reply("updated address table: %s %s" % (handle, address))
54 except Exception as ex:
55 self.pest_reply("Error attempting to update address table")
56 self.pest_reply("Error attempting to update address table: %s" % ex)
57 stack = traceback.format_exc()
58 logging.debug(stack)
59 return
(91 . 7)(91 . 7)- 81527BDB79D3F7C5F42234E6355A530D86FCDC3974A0461782DCD4FE5FC245F8CDCA423F4F033CF207224544525EC222A647F8BF56E70BF5A0F04FBB73120D89
64 logging.error("aborting send: message modified by station!")
65 return
66
67 for peer in self.state.get_keyed_peers():
68 for peer in self.state.get_keyed_peers(exclude_addressless=True):
69
70 # we don't want to send a broadcast back to the originator
71 if message.peer and (peer.peer_id == message.peer.peer_id):
(132 . 7)(132 . 7)
73 if message.command != IGNORE:
74 logging.debug("packing message bytes: %s" % message.body)
75 else:
76 logging.debug("packing rubbish message bytes: %s" % binascii.hexlify(message.body))
77 logging.debug("packing rubbish message bytes: %s" % binascii.hexlify(message.body)[0:8])
78
79 message_bytes = struct.pack(MESSAGE_PACKET_FORMAT, message.timestamp, self_chain, net_chain, speaker, message.body)
80 return message_bytes
(1 . 4)(1 . 4)
85 VERSION = "9985"
86 VERSION = "9984"
87
88 import os
89 import select
- 034E0AF7BE67265B08FA39744E1AE5637F0B6BF28021748B964CBC1DCB5147F95B6B94EE94160946C54198669F4DAD4F1C98552ADE5B16BB78F327C20958777F(3 . 6)(3 . 7)- 2D26B4E88714111204FDFFB51AA603BC94F517781589411BD72BE924ABE9FC4DDF6F344EBF3DEC070580C4211B0FD533B3C8A45617F8C07A685166A33AE3118D
94 import imp
95 import hashlib
96 import logging
97 import datetime
98 from itertools import chain
99
100 class State(object):
(23 . 8)(24 . 7)
102 cursor.execute("create table if not exists at(handle_id integer,\
103 address text not null,\
104 port integer not null,\
105 active_at datetime default null,\
106 updated_at datetime default current_timestamp,\
107 updated_at datetime default null,\
108 unique(handle_id, address, port))")
109
110 cursor.execute("create table if not exists wot(peer_id integer primary key)")
(57 . 7)(57 . 7)
112 cursor = self.cursor()
113 at = []
114 if handle == None:
115 results = cursor.execute("select handle_id,address,port,active_at from at\
116 results = cursor.execute("select handle_id, address, port, updated_at from at\
117 order by updated_at desc").fetchall()
118 else:
119 result = cursor.execute("select handle_id from handles where handle=?",
(66 . 7)(66 . 7)
121 handle_id = result[0]
122 else:
123 return []
124 results = cursor.execute("select handle_id,address,port,active_at from at \
125 results = cursor.execute("select handle_id, address, port, updated_at from at \
126 where handle_id=? order by updated_at desc",
127 (handle_id,)).fetchall()
128 for result in results:
(158 . 25)(158 . 52)
130 if row != None:
131 handle_id = row[0]
132 else:
133 return
134 raise Exception("handle not found")
135
136 try:
137 cursor.execute("insert into at(handle_id, address, port) values(?, ?, ?)",
138 (handle_id, peer["address"], peer["port"]))
139 except sqlite3.IntegrityError as ex:
140 cursor.execute("update at set updated_at = current_timestamp\
141 where handle_id=? and address=? and port=?",
142 (handle_id, peer["address"], peer["port"]))
143 if set_active_at:
144 cursor.execute("update at set active_at = current_timestamp\
145 where handle_id=? and address=? and port=?",
146 (handle_id, peer["address"], peer["port"]))
147 at_entry = cursor.execute("select handle_id, address, port from at where handle_id=?",
148 (handle_id,)).fetchone()
149
150 # if there are no AT entries for this handle, insert one
151 timestamp = datetime.datetime.now() if set_active_at else None
152 if at_entry == None:
153 cursor.execute("insert into at(handle_id, address, port, updated_at) values(?, ?, ?, ?)",
154 (handle_id,
155 peer["address"],
156 peer["port"],
157 timestamp))
158 logging.debug("inserted new at entry for %s: %s:%d" % (
159 peer['handle'],
160 peer['address'],
161 peer['port']))
162
163 # otherwise update the existing entry if it differs
164 else:
165 try:
166 if (at_entry[1] != peer['address'] or
167 at_entry[2] != peer['port']):
168 cursor.execute("update at set updated_at = ?,\
169 address = ?,\
170 port = ?\
171 where handle_id=?",
172 (timestamp,
173 peer["address"],
174 peer["port"],
175 handle_id))
176
177 logging.debug("updated at entry for %s: %s:%d" % (
178 peer['handle'],
179 peer['address'],
180 peer['port']))
181 except sqlite3.IntegrityError:
182 cursor.execute("delete from at where handle_id=?", (handle_id,))
183
184
185 self.conn.commit()
186
187 def add_peer(self, handle):
188 cursor = self.cursor()
189 cursor.execute("insert into wot(peer_id) values(null)")
190 peer_id = self.cursor.lastrowid
191 peer_id = cursor.lastrowid
192 cursor.execute("insert into handles(peer_id, handle) values(?, ?)",
193 (peer_id, handle))
194 self.conn.commit()
(189 . 7)(216 . 7)
196 result = cursor.execute("select peer_id from handles where handle=?",
197 (handle,)).fetchone()
198 if result == None:
199 return
200 raise Exception("handle not found")
201 else:
202 peer_id = result[0]
203 # get all aliases
(248 . 7)(275 . 7)
205 def listify(self, results):
206 return list(chain.from_iterable(results))
207
208 def get_keyed_peers(self):
209 def get_keyed_peers(self, exclude_addressless=False):
210 cursor = self.cursor()
211 peer_ids = self.listify(cursor.execute("select peer_id from keys").fetchall())
212 peers = []
(257 . 7)(284 . 7)
214 peer = self.get_peer_by_handle(handle)
215 if self.is_duplicate(peers, peer):
216 continue
217 if peer.address == None or peer.port == None:
218 if exclude_addressless and (peer.address == None or peer.port == None):
219 continue
220 peers.append(peer)
221 return peers
(1 . 6)(1 . 6)
226 #!/bin/bash
227
228 # start 3 servers on different ports
229 ./blatta --log-level info --channel-name \#aleth --irc-port 9968 --udp-port 7778 --db-path a.db --address-table-path test_net_configs/a.py > logs/a &
230 ./blatta --log-level info --channel-name \#aleth --irc-port 6669 --udp-port 7779 --db-path b.db --address-table-path test_net_configs/b.py > logs/b &
231 ./blatta --log-level debug --channel-name \#aleth --irc-port 9968 --udp-port 7778 --db-path a.db --address-table-path test_net_configs/a.py > logs/a &
232 # ./blatta --log-level info --channel-name \#aleth --irc-port 6669 --udp-port 7779 --db-path b.db --address-table-path test_net_configs/b.py > logs/b &
233 ./blatta --log-level debug --channel-name \#aleth --irc-port 6670 --udp-port 7780 --db-path c.db --address-table-path test_net_configs/c.py > logs/c &