https://github.com/s4m-mo/blockchainminer
A simple, concurrent CPU blockchain miner framework implemented in Go.
https://github.com/s4m-mo/blockchainminer
bitcoin bitcoin-mining cryptocurrency
Last synced: 11 months ago
JSON representation
A simple, concurrent CPU blockchain miner framework implemented in Go.
- Host: GitHub
- URL: https://github.com/s4m-mo/blockchainminer
- Owner: s4m-mo
- License: mit
- Created: 2022-01-06T19:57:27.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-04-23T09:22:37.000Z (about 1 year ago)
- Last Synced: 2025-06-30T21:06:31.046Z (12 months ago)
- Topics: bitcoin, bitcoin-mining, cryptocurrency
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Blockchain Miner
A simple package to understand how blockchains work.
## Installation
```shell
go get github.com/s4m-mo/blockchainminer
```
Then, import it with...
```go
import (
m "github.com/s4m-mo/blockchainminer/miner"
)
```
## Usage
The bulk of the API is here. More detail is on [pkg.go.dev](https://pkg.go.dev/github.com/s4m-mo/blockchainminer)
```go
package main
import (
"fmt"
"github.com/s4m-mo/blockchainminer/hash"
"github.com/s4m-mo/blockchainminer/miner"
)
func main() {
transactionString := "\nAlice->Bob->20\nBob->Charlie->10\nCharlie->Alice->5\n[PrevBlockHash]\n%v"
m := miner.NewMiner(
transactionString,
hash.SHA256,
10000,
)
m.SetSearchSize(100000000000)
m.SetDifficulty(6)
m.SetHashTimes(1)
m.SetOutputLevel(1)
solution, hasFound := m.ThreadedMine()
if hasFound {
fmt.Println("\n\n", solution, "\n", hash.SHA256(hash.SHA256(fmt.Sprintf(transactionString, solution))))
}
}
```