Arkadaşlar elimizde şöyle bir kodumuz var
Ama bilgisayarda işlenmesi günlerce hatta beilki aylarca sürecek gibi görünüyor
Bunu hızlandırmak istiyoruz
Bilgisayarımız Hp Omen i7 7g
8 çekirdekli ve 16gb ram
C sürücüsü 120gb ssd (windows 10 burada yüklü)
D sürücüsü 1tb hdd
Kodumuzu Visual Studio Code - Python üzerinden çalıştırıyoruz
Lakin dikkat ettik ki program cpu’nun sadece %10 kullanıyor
Sistem ayarlarından 8 çekirdeği aktif ettik
ama hiçbir değişiklik yok hala 1 çekirdek kullanılıyor gibi
Biraz araştırma yapınca bunun için Multi Thread ve/veya Multi Process kullanmamız gerektiğini öğrendik
Ama bunları kodumuza uygulayamadık
Yardımcı olabilecek varsa müteşekkir oluruz.
from time import process_time
import bitcoin
# Bu sadece compressed adresleri buluyor
filehandle1 = open('file1.txt', mode="r") # First file
filehandle2 = open('file2.txt', mode="r") # Second file
filehandle3 = open('file3.txt', mode="r") # Check for combine
filehandle4 = open('file4.txt', 'w') # Equal list file
print("Wait for counting records first file...")
filecount = len(filehandle1.readlines())
filehandle1.seek(0)
count =0
t1_start = process_time()
def convert_key(kod) :
valid_private_key = False
while not valid_private_key:
private_key = kod
decoded_private_key = bitcoin.decode_privkey(private_key, 'hex')
valid_private_key = 0 < decoded_private_key < bitcoin.N
compressed_private_key = private_key + '01'
wif_compressed_private_key = bitcoin.encode_privkey(bitcoin.decode_privkey(compressed_private_key, 'hex'), 'wif')
public_key = bitcoin.fast_multiply(bitcoin.G, decoded_private_key)
(public_key_x, public_key_y) = public_key
if (public_key_y % 2) == 0:
compressed_prefix = '02'
else:
compressed_prefix = '03'
hex_compressed_public_key = compressed_prefix + bitcoin.encode(public_key_x, 16)
return bitcoin.pubkey_to_address(public_key)
def convert_key_compressed(kod) :
valid_private_key = False
while not valid_private_key:
private_key = kod
decoded_private_key = bitcoin.decode_privkey(private_key, 'hex')
valid_private_key = 0 < decoded_private_key < bitcoin.N
compressed_private_key = private_key + '01'
wif_compressed_private_key = bitcoin.encode_privkey(bitcoin.decode_privkey(compressed_private_key, 'hex'), 'wif')
public_key = bitcoin.fast_multiply(bitcoin.G, decoded_private_key)
(public_key_x, public_key_y) = public_key
if (public_key_y % 2) == 0:
compressed_prefix = '02'
else:
compressed_prefix = '03'
hex_compressed_public_key = compressed_prefix + bitcoin.encode(public_key_x, 16)
return bitcoin.pubkey_to_address(hex_compressed_public_key)
while True:
line1 = filehandle1.readline()
count = count+1
if not line1:
break
while True:
line2 = filehandle2.readline()
if not line2:
filehandle2.seek(0)
break
# Compressed Coin Check/ To check coin adress use coin_adress() here
try:
compare_key_compressed = convert_key_compressed(line1.strip()+line2.strip())
except:
pass
while True:
line3 = filehandle3.readline()
if not line3:
filehandle3.seek(0)
break
#print(line3, compare_key, compare_key_compressed)
#input()
if (line3.strip() == compare_key_compressed.strip() ) :
filehandle4.write(line1.strip()+line2.strip()+' : ')
filehandle4.write(line3.rstrip()+'\n')
print("Processing: %"+"%0.6f"% ((count/filecount)*100))
t1_stop = process_time()
print("Elapsed time in seconds:", t1_stop-t1_start)
filehandle1.close()
filehandle2.close()
filehandle3.close()
filehandle4.close()