* refactored subprocess and made it 20%+ faster by using ujson

+ added watchdog dep for sneakernet
+ added ujson dep for faster json esp in pow
master
Kevin Froman 2020-04-03 03:28:48 -05:00
parent 8d372cccfb
commit 8804c13225
4 changed files with 19 additions and 10 deletions

View File

@ -13,4 +13,5 @@ niceware==0.2.1
psutil==5.7.0
filenuke==0.0.0
mimcvdf==1.0.0
watchdog==0.10.2
watchdog==0.10.2
ujson==2.0.3

View File

@ -216,6 +216,15 @@ streamedrequests==1.0.0 \
toomanyobjs==1.1.0 \
--hash=sha256:99e27468f9dad19127be9e2fb086b42acd69aed9ad7e63cef74d6e4389be0534 \
# via -r requirements.in
ujson==2.0.3 \
--hash=sha256:0c23f21e8d2b60efab57bc6ce9d1fb7c4e96f4bfefbf5a6043a3f3309e2a738a \
--hash=sha256:2ab88e330405315512afe9276f29a60e9b3439187b273665630a57ed7fe1d936 \
--hash=sha256:3d1f4705a4ec1e48ff383a4d92299d8ec25e9a8158bcea619912440948117634 \
--hash=sha256:6217c63a36e9b26e9271e686d212397ce7fb04c07d85509dd4e2ed73493320f8 \
--hash=sha256:7ae13733d9467d16ccac2f38212cdee841b49ae927085c533425be9076b0bc9d \
--hash=sha256:bd2deffc983827510e5145fb66e4cc0f577480c62fe0b4882139f8f7d27ae9a3 \
--hash=sha256:c8369ef49169804944e920c427e350182e33756422b69989c55608fc28bebf98 \
# via -r requirements.in
unpaddedbase32==0.2.0 \
--hash=sha256:4aacee75f8fd6c8cf129842ecba45ca59c11bfb13dae19d86f32b48fa3715403 \
--hash=sha256:b7b780c31d27d55e66abf6c221216a35690ee8892c2daacff7f2528e229bd9c3 \

View File

@ -1,22 +1,20 @@
#!/usr/bin/env python3
"""
Onionr - Private P2P Communication
"""Onionr - Private P2P Communication.
Multiprocess proof of work
Multiprocess proof of work
"""
import os
from multiprocessing import Pipe, Process
import threading
import time
import json
import secrets
import onionrproofs
import ujson as json
import logger
import onionrproofs
import onionrcrypto as crypto
from onionrutils import bytesconverter
from .blocknoncestart import BLOCK_NONCE_START_INT
"""
This program is free software: you can redistribute it and/or modify
@ -110,11 +108,12 @@ class SubprocessPOW:
def do_pow(self, pipe):
"""find partial hash colision generating nonce for a block"""
nonce = -secrets.randbelow(10**10)
nonce = 0
data = self.data
metadata = self.metadata
puzzle = self.puzzle
difficulty = self.difficulty
while True:
# Break if shutdown received
if pipe.poll() and pipe.recv() == 'shutdown':

View File

@ -1 +1 @@
1585619396
1585902463