Skip to content

Latest commit

 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Miner

Blockchain implementation implemented from the perspective of networking, basically simulating the whole blockchain network(mesh).

Demo

demo

Principle

Everthing is implemented based on this conversation with grok

features

  • Based on pool Miner
  • fullnodes are connected p2p

Visualization

concept

DOC

Node TCPPORT HTTPPORT
SeedServer (__) (8080)
Miner (8081-8083) (101-103)
FullNode (8084-8086) (104-106)
User (__) (107-108)

Setup

Each component ships its own Dockerfile and compose.yaml. Bring them up with docker compose up from each directory, starting with the seedserver — it creates the shared blockchain-network bridge that every other compose file joins as an external network, and the other nodes resolve it by the DNS name seedserver to discover their peers.

cd seedserver && docker compose up -d

cd ../fullnode && docker compose up -d

cd ../miner && docker compose up -d

cd ../user && docker compose up -d

Drop the -d to keep the logs in the foreground, and use docker compose down in each directory to tear things back down (the seedserver last, since it owns the network).

Check that a fullnode is alive:

curl http://localhost:104/
# {"message": "Success"}

Sending a transaction

Transactions are posted to a user (wallet) node, on HTTP port 107 or 108. The wallet asks the seedserver for a live fullnode, forwards the body to that node's /transaction, and hands back its reply — so you never have to know which fullnode is up:

curl -i -X POST http://localhost:107/ \
  -H 'Content-Type: application/json' \
  -d '{"from":"alice","to":"bob","amt":"50"}'

The amount field is keyed amt, and from, to and amt are all strings. A success is 202 Accepted with {"status":"accepted","id":"<tx id>"} proxied straight from the fullnode, which adds the transaction to its mempool and gossips it to its peers, where the miners pick it up.

If the wallet answers 502 Seedserver unreachable or 503 No fullnode available, the seedserver has fewer than two fullnodes registered — give fullnode/ a moment to come up and retry.

Releases

Packages

Contributors

Languages