db backup

This commit is contained in:
Ryan Bakkes 2023-11-20 15:39:43 +01:00
parent 23a38956d2
commit c9deff7fda
3 changed files with 9 additions and 9 deletions

View File

@ -6,9 +6,9 @@ from cryptography.hazmat.backends import default_backend
import random
REWARD_VALUE = 50.0
leading_zeros = 2
leading_extra = 1
next_char_limit = 20
leading_zeros = 1
leading_extra = 2
next_char_limit = 25
class TxBlock (CBlock):
@ -42,7 +42,7 @@ class TxBlock (CBlock):
digest.update(bytes(str(self.nonce), 'utf8'))
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:
for i in range(leading_extra):
@ -55,7 +55,7 @@ class TxBlock (CBlock):
return True
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)])
if self.good_nonce():
return self.nonce

View File

@ -253,7 +253,7 @@ def createBlock(self):
if transactions[i].type != 1:
fees += transactions[i].inputs[0][1] - transactions[i].outputs[0][1]
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
@ -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}")
fees = round(fees, 2)
new_reward = Tx()
new_reward.createRewardTransaction(self.user.public_ser, 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!")
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 + 25} coins!")
utilityHelper.addFile("../data/transaction_pool.dat", new_reward)

View File

@ -82,7 +82,7 @@ class MenuHelper:
new_tx = Tx()
new_tx.createRewardTransaction(self.user.public_ser, self.user.private_ser, "SIGNUP")
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)
return
print(f"{utilityHelper.errorMessage('Transaction is invalid')}")