https://github.com/pvlbzn/blockchan
Blockchain implementation
https://github.com/pvlbzn/blockchan
blockchain cryptography
Last synced: 2 months ago
JSON representation
Blockchain implementation
- Host: GitHub
- URL: https://github.com/pvlbzn/blockchan
- Owner: pvlbzn
- Created: 2017-07-31T18:20:37.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-03T20:03:58.000Z (about 8 years ago)
- Last Synced: 2025-03-01T02:41:23.676Z (7 months ago)
- Topics: blockchain, cryptography
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Blockchain Implementation
Code prior to this [point](https://github.com/pvlbzn/blockchan/tree/a22d842dbaad3232bbb9758d0e2697749618dbea)
was written at my housewarming party knowing little about blockchain. Later commits contains refactoring
on a sober mind.### Architecture
Blocks are chosen to be stored as files in a file system rather than in memory (runtime) data structure.
Files are less abstract and more concrete so that one can see the content of a block straight away.Blocks are stored in `blocks` directory and they are named `{0..n}.block`. `0.block` is a genesis block
and should not be changed.A number of transactions in a block is currently from 1 to n.
### `block` Package
Block package implements core block chain logic: `Block`, `Transaction` and their methods.
```Go
// Create a new block
b, err := block.NewBlock()
if err != nil {
// handle it
}// Add a transaction into the block
b.AddTransaction(block.NewTransaction("from", "to", amount))// "perform" transaction
b.Write()status, err := block.ValidateChain()
if err != nil {
// handle it
}fmt.Println(status) // Should be true
```To parse some block out of the file into runtime memory layout (data structure) one should
use `func Read(n int) (*Block, error)` function. It will parse `n`th block into `Block`
structure.### Future Hackaton Plan
* Web server/interface to blockchain
* Transaction queue
* Transaction processing
* Public API
* Form a cryptocurrency on top of blockchain
* Nonce
* Rules
* Parallel mining software
* Find a hash to transaction
* Send a hash to public API