I don't think it's intended for practical use-case, I suppose that it's more about the educational value of being able to replicate how a blockchain works on your own cloud server.
It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
import json
from datetime import datetime
from hashlib import sha256
class Blockchain(object):
def _init__(self):
self.chain = []
self.chain.append(self.new_block())
def new_block(self):
block = {
'timestamp' datetime.now().isoformat(),
'prev_hash': self.chain [-1]["hash"] if len(self.chain)>0 else None,
'nonce': len(self.chain)
}
block["hash"]=sha256(json.dumps(block).encode()).hexdigest()
return block
def proof_of_work(self):
while True:
new_block = self.new_block()
if new_block["hash"].startswith("0000"):
break
self.chain.append(new_block)
def get_block_count(self):
return len(self.chain)
bc = Blockchain()
bc.proof_of_work()
root@not-3:-# mkdir notyourkeynotyourbtc
root@not-3:-# cd notyourkeynotyourbtc/
root@not-3:-/notyourkeynotyourbtc# nano blockchain.py
print(json.dumps(bc.chain, indent=4))
print("amount of blochcain data", bc.get_block_count())
root@not-3:~/notyourkeynotyourbtc# python3 blockchain.py
[
{
"timestamp": "2024-10-15T19:35:43.065206",
"prev_hash": null,
"nonce": 0,
"hash":
"0efaec636d1c6a553d8139c82f40677249715a03a43ea93ed2081belbfc4e804"
},
{
"timestamp": "2024-10-15T19:35:43.089915",
"prev_hash":
"0efaec636d1c6a553d8139c82f40677249715a03a43ea93ed2081belbfc4e804",
"nonce": 1,
"hash": "00008e23dadfaa45e2e4e20b4eccaaaleab091b9060875ce32a33def4a0a9292"
}
Number of data on the blockchain: 2
root@not-3:~/notyourkeynotyourbtc#