work on proof of work

This commit is contained in:
Kevin Froman 2018-05-05 15:07:32 -05:00
parent 908ccbe664
commit e2cc375b1a
No known key found for this signature in database
GPG key ID: 0D414D0FE405B63B
4 changed files with 35 additions and 46 deletions

View file

@ -17,11 +17,11 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
import sqlite3, os, sys, time, math, base64, tarfile, getpass, simplecrypt, hashlib, nacl, logger, json, netcontroller
import sqlite3, os, sys, time, math, base64, tarfile, getpass, simplecrypt, hashlib, nacl, logger, json, netcontroller, math
#from Crypto.Cipher import AES
#from Crypto import Random
import onionrutils, onionrcrypto, btc, onionrevents as events
import onionrutils, onionrcrypto, onionrproofs, btc, onionrevents as events
if sys.version_info < (3, 6):
try:
@ -630,13 +630,23 @@ class Core:
Inserts a block into the network
'''
powProof = onionrproofs.POW(data)
powToken = ''
# wait for proof to complete
while True:
powToken = powProof.getResult()
if powToken != False:
break
time.sleep(0.3)
try:
data.decode()
except AttributeError:
data = data.encode()
retData = ''
metadata = {'type': header}
metadata = {'type': header, 'pow': powToken}
sig = {}
metadata = json.dumps(metadata)