Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions BitTornado/Application/PeerID.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import os
import time
import base64
import hashlib
import itertools
import BitTornado

"""Use time clock or perf_counter, depending on python version"""
try:
from time import perf_counter, time
except ImportError:
from time import clock, time as perf_counter, time

mapbase64 = b'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-'


Expand All @@ -31,15 +36,15 @@ def reset(self):
except IOError:
x = b''

tic = time.clock()
toc1 = countwhile(lambda x: tic == time.clock())
tic = int(time.time() * 100)
toc2 = countwhile(lambda x: tic == int(time.time() * 100))
tic = int(time.time() * 10)
tic = perf_counter()
toc1 = countwhile(lambda x: tic == perf_counter())
tic = int(time() * 100)
toc2 = countwhile(lambda x: tic == int(time() * 100))
tic = int(time() * 10)
toc3 = 0 if toc2 >= 1000 else \
countwhile(lambda x: tic == int(time.time() * 10))
countwhile(lambda x: tic == int(time() * 10))

x += '{!r}/{}/{}/{}/{}/{}'.format(time.time(), time.time(), toc1, toc2,
x += '{!r}/{}/{}/{}/{}/{}'.format(time(), time(), toc1, toc2,
toc3, os.getpid()).encode()

self.randstr = base64.urlsafe_b64encode(
Expand Down