db backup
This commit is contained in:
parent
23a38956d2
commit
c9deff7fda
@ -6,9 +6,9 @@ from cryptography.hazmat.backends import default_backend
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
REWARD_VALUE = 50.0
|
REWARD_VALUE = 50.0
|
||||||
leading_zeros = 2
|
leading_zeros = 1
|
||||||
leading_extra = 1
|
leading_extra = 2
|
||||||
next_char_limit = 20
|
next_char_limit = 25
|
||||||
|
|
||||||
class TxBlock (CBlock):
|
class TxBlock (CBlock):
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class TxBlock (CBlock):
|
|||||||
digest.update(bytes(str(self.nonce), 'utf8'))
|
digest.update(bytes(str(self.nonce), 'utf8'))
|
||||||
this_hash = digest.finalize()
|
this_hash = digest.finalize()
|
||||||
|
|
||||||
bytes_array = [b'\x00', b'\x01', b'\x02', b'\x03', b'\x04', b'\x05', b'\x06']
|
bytes_array = [b'\x00', b'\x01', b'\x02', b'\x03', b'\x04', b'\x05', b'\x06', b'\x07', b'\x08', b'\x09']
|
||||||
if this_hash[:leading_zeros] == b'\x00'*leading_zeros:
|
if this_hash[:leading_zeros] == b'\x00'*leading_zeros:
|
||||||
|
|
||||||
for i in range(leading_extra):
|
for i in range(leading_extra):
|
||||||
@ -55,7 +55,7 @@ class TxBlock (CBlock):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def find_nonce(self):
|
def find_nonce(self):
|
||||||
for i in range(200000):
|
for i in range(350000):
|
||||||
self.nonce = "".join([random.choice("1234567890ABCDEF") for n in range(next_char_limit)])
|
self.nonce = "".join([random.choice("1234567890ABCDEF") for n in range(next_char_limit)])
|
||||||
if self.good_nonce():
|
if self.good_nonce():
|
||||||
return self.nonce
|
return self.nonce
|
||||||
|
@ -253,7 +253,7 @@ def createBlock(self):
|
|||||||
if transactions[i].type != 1:
|
if transactions[i].type != 1:
|
||||||
fees += transactions[i].inputs[0][1] - transactions[i].outputs[0][1]
|
fees += transactions[i].inputs[0][1] - transactions[i].outputs[0][1]
|
||||||
fees = round(fees, 2)
|
fees = round(fees, 2)
|
||||||
print(f"After validating you will receive a reward of {fees + 50} coins!")
|
print(f"After validating you will receive a reward of {fees + 25} coins!")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -291,8 +291,8 @@ def validateMinedBlock(self):
|
|||||||
self.db.createLog(transaction.outputs[0][0], time.time(), f"You have received new coins: {transaction.outputs[0][1]}, To see all info view block id {new_block.id}")
|
self.db.createLog(transaction.outputs[0][0], time.time(), f"You have received new coins: {transaction.outputs[0][1]}, To see all info view block id {new_block.id}")
|
||||||
fees = round(fees, 2)
|
fees = round(fees, 2)
|
||||||
new_reward = Tx()
|
new_reward = Tx()
|
||||||
new_reward.createRewardTransaction(self.user.public_ser, self.user.private_ser, "MINE", fees)
|
new_reward.createRewardTransaction(new_block.metadata['miner'], self.user.private_ser, "MINE", fees)
|
||||||
self.db.createLog(new_block.metadata['miner'], time.time(), f"Block id {new_block.id}, is validated! You received a reward of {fees} coins!")
|
self.db.createLog(new_block.metadata['miner'], time.time(), f"Block id {new_block.id}, is validated! You received a reward of {fees + 25} coins!")
|
||||||
utilityHelper.addFile("../data/transaction_pool.dat", new_reward)
|
utilityHelper.addFile("../data/transaction_pool.dat", new_reward)
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class MenuHelper:
|
|||||||
new_tx = Tx()
|
new_tx = Tx()
|
||||||
new_tx.createRewardTransaction(self.user.public_ser, self.user.private_ser, "SIGNUP")
|
new_tx.createRewardTransaction(self.user.public_ser, self.user.private_ser, "SIGNUP")
|
||||||
if new_tx != False and new_tx.is_valid():
|
if new_tx != False and new_tx.is_valid():
|
||||||
print(f"{utilityHelper.blinkMessage('Received sign up bonus')}")
|
print(f"{utilityHelper.blinkMessage('Added sign up bonus transaction to pool')}")
|
||||||
utilityHelper.addFile("../data/transaction_pool.dat", new_tx)
|
utilityHelper.addFile("../data/transaction_pool.dat", new_tx)
|
||||||
return
|
return
|
||||||
print(f"{utilityHelper.errorMessage('Transaction is invalid')}")
|
print(f"{utilityHelper.errorMessage('Transaction is invalid')}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user