From a60723cf7e6c99c0f6269e074419bda352d517dc Mon Sep 17 00:00:00 2001 From: sponge <sponge@mail.i2p> Date: Fri, 14 Sep 2012 02:40:10 +0000 Subject: [PATCH] Test for old entries and use them. --- netdb.i2p2/fixedapp.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/netdb.i2p2/fixedapp.py b/netdb.i2p2/fixedapp.py index 3b3dd7ecf..95ae76f07 100644 --- a/netdb.i2p2/fixedapp.py +++ b/netdb.i2p2/fixedapp.py @@ -129,21 +129,29 @@ def application(environ, start_response): # tag the ip as new cur.execute("insert into client values (?, ?)", (remote, now)) # see if we have a list already, and use that - # generate links - entries = os.listdir(netdbdir) - if len(entries) > 150: - # select some randomly - new = [] - for i in range(100): - while True: - sel = choice(entries) - if not sel.startswith('routerInfo-'): - continue - if sel not in new: - new.append(sel) - cur.execute("insert into entry values (?, ?)", (nowtag, sel)) - break - entries = new + cur.execute("select * from entry where whn = ?", nowtag) + stuff = cur.fetchall() + if (len(stuff) == 0): + # generate links + entries = os.listdir(netdbdir) + if len(entries) > 150: + # select some randomly + new = [] + for i in range(100): + while True: + sel = choice(entries) + if not sel.startswith('routerInfo-'): + continue + if sel not in new: + new.append(sel) + cur.execute("insert into entry values (?, ?)", (nowtag, sel)) + break + entries = new + else: + # Use what we already generated + entries = [] + for junk,sel in stuff: + entries.append(sel) else: # use old list based on date in database, i.e. sends the same as before. junk, last = info[0] -- GitLab