home..
P2P Server-Client Blockchain (WPF)
Mia Vrhovnik / January 2023 (51 Words, 1 Minutes)
C#
sockets
multithreading
blockchain
p2p
asynchronous programming
FULL SOURCE CODE:
- The application is a server and a client application that can connect to each other over LAN and sync a blockchain between them.
- A blockchain is a growing list of records, called blocks, that are linked together using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data.
- Every 5 seconds the server checks if there are any new blocks in the blockchain, if there are it sends them to the client. The client then adds the new blocks to its blockchain.
- The difficulty increases every 10 blocks, this means that the client has to do more work to find a valid hash for the block. This is done to simulate the real world where the difficulty increases as more blocks are added to the blockchain.
Mining With Multiple Applications

Each application connects to the other using different ports over LAN. Before doing that the application waits using a blocking function until the other application connects to it. This is done to make sure that both applications are connected to each other before starting mining.
An ‘unlimited’ amount of client-server pairs can be connected to each other. The server will send the new blocks to all of the clients every 5 seconds.