From c13a7423352c5809f11abe1eeed415086fb000af Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 14 May 2018 23:24:38 -0500 Subject: [PATCH] removed btc and stopped delivering pow hash --- onionr/bitpeer | 1 - onionr/btc.py | 44 ------------------------------------------ onionr/core.py | 3 ++- onionr/onionrcrypto.py | 5 ++--- onionr/onionrproofs.py | 17 ++-------------- 5 files changed, 6 insertions(+), 64 deletions(-) delete mode 160000 onionr/bitpeer delete mode 100644 onionr/btc.py diff --git a/onionr/bitpeer b/onionr/bitpeer deleted file mode 160000 index a74e826e..00000000 --- a/onionr/bitpeer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a74e826e9c69e643ead7950f9f76a05ab8664ddc diff --git a/onionr/btc.py b/onionr/btc.py deleted file mode 100644 index f09ec622..00000000 --- a/onionr/btc.py +++ /dev/null @@ -1,44 +0,0 @@ -''' - Onionr - P2P Microblogging Platform & Social network - - Handle bitcoin operations -''' -''' - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -''' -from bitpeer.node import * -from bitpeer.storage.shelve import ShelveStorage -import logging, time -import socks, sys -class OnionrBTC: - def __init__(self, lastBlock='00000000000000000021ee6242d08e3797764c9258e54e686bc2afff51baf599', lastHeight=510613, torP=9050): - stream = logging.StreamHandler() - logger = logging.getLogger('halfnode') - logger.addHandler(stream) - logger.setLevel (10) - - LASTBLOCK = lastBlock - LASTBLOCKINDEX = lastHeight - self.node = Node ('BTC', ShelveStorage ('data/btc-blocks.db'), lastblockhash=LASTBLOCK, lastblockheight=LASTBLOCKINDEX, torPort=torP) - - self.node.bootstrap () - self.node.connect () - self.node.loop () - -if __name__ == "__main__": - torPort = int(sys.argv[1]) - bitcoin = OnionrBTC(torPort) - while True: - print(bitcoin.node.getBlockHash(bitcoin.node.getLastBlockHeight())) # Using print on purpose, do not change to logger - time.sleep(5) diff --git a/onionr/core.py b/onionr/core.py index 7877c849..143b11f8 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -21,7 +21,7 @@ import sqlite3, os, sys, time, math, base64, tarfile, getpass, simplecrypt, hash #from Crypto.Cipher import AES #from Crypto import Random -import onionrutils, onionrcrypto, onionrproofs, btc, onionrevents as events +import onionrutils, onionrcrypto, onionrproofs, onionrevents as events if sys.version_info < (3, 6): try: @@ -461,6 +461,7 @@ class Core: try: peerList.append(self._crypto.pubKey + '-' + self._crypto.pubKeyPowToken) except TypeError: + print('what') pass else: peerList.append(self._crypto.pubKey) diff --git a/onionr/onionrcrypto.py b/onionr/onionrcrypto.py index 4eeccdc5..84e9827f 100644 --- a/onionr/onionrcrypto.py +++ b/onionr/onionrcrypto.py @@ -28,7 +28,7 @@ class OnionrCrypto: self.privKey = None self.pubKeyPowToken = None - self.pubKeyPowHash = None + #self.pubKeyPowHash = None self.HASH_ID_ROUNDS = 2000 @@ -41,8 +41,7 @@ class OnionrCrypto: try: with open(self.keyPowFile, 'r') as powFile: data = powFile.read() - self.pubKeyPowHash = data.split('-')[0] - self.pubKeyPowToken = data.split('-')[1] + self.pubKeyPowToken = data except (FileNotFoundError, IndexError): pass else: diff --git a/onionr/onionrproofs.py b/onionr/onionrproofs.py index 7851689d..7001d1d6 100644 --- a/onionr/onionrproofs.py +++ b/onionr/onionrproofs.py @@ -19,7 +19,7 @@ ''' import nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, logger, sys -import btc, core +import core class POW: def pow(self, reporting = False): @@ -30,20 +30,8 @@ class POW: answer = '' heartbeat = 200000 hbCount = 0 - blockCheck = 300000 # How often the hasher should check if the bitcoin block is updated (slows hashing but prevents less wasted work) - blockCheckCount = 0 - block = '' #self.bitcoinNode.getBlockHash(self.bitcoinNode.getLastBlockHeight()) myCore = core.Core() while self.hashing: - ''' - if blockCheckCount == blockCheck: - if self.reporting: - logger.debug('Refreshing Bitcoin block') - block = '' #self.bitcoinNode.getBlockHash(self.bitcoinNode.getLastBlockHeight()) - blockCheckCount = 0 - blockCheckCount += 1 - hbCount += 1 - ''' rand = nacl.utils.random() token = nacl.hash.blake2b(rand + self.data).decode() #print(token) @@ -60,7 +48,7 @@ class POW: logger.info('took ' + str(endTime - startTime) + ' seconds', timestamp=True) self.result = (token, rand) - def __init__(self, data, bitcoinNode=''): + def __init__(self, data): self.foundHash = False self.difficulty = 0 self.data = data @@ -80,7 +68,6 @@ class POW: self.mainHash = '0000000000000000000000000000000000000000000000000000000000000000'#nacl.hash.blake2b(nacl.utils.random()).decode() self.puzzle = self.mainHash[0:self.difficulty] - self.bitcoinNode = bitcoinNode #logger.debug('trying to find ' + str(self.mainHash)) tOne = threading.Thread(name='one', target=self.pow, args=(True,)) tTwo = threading.Thread(name='two', target=self.pow, args=(True,))