This is a commercial-grade implementation of the Capped Pay-Per-Share with Recent Backpay (CPPSRB) algorithm for cryptocurrency mining pools. The system provides a robust and fair payout mechanism while maintaining pool financial stability.
- Capped Payouts: Limits the pool's liability per share
- Recent Backpay: Rewards miners for recent shares even if they haven't found a block
- Proportional Distribution: Pays miners based on their share contributions
- Pool Protection: Prevents overpayment during high variance periods
- Runtime: Node.js
- Web Framework: Express.js
- Database: SQLite
- Logging: Winston
- Validation: Joi
- Testing: Jest + Supertest
- Linting: ESLint (Airbnb style)
- Formatting: Prettier
-
Clone the repository:
git clone https://github.com/yourusername/cpprb-pool.git cd cpprb-pool
-
Install dependencies:
npm install
-
Configure the application (see Configuration section)
-
Start the server:
npm start
Configuration is managed through config/default.json
:
{
"server": {
"port": 3000,
"rateLimit": {
"windowMs": 900000,
"max": 100
}
},
"logging": {
"level": "info",
"file": "logs/application.log"
},
"database": {
"file": "data/cpprb.db"
},
"cpprb": {
"capPerShare": 0.01, // Maximum payout per share
"backpayWindow": 3600 // Backpay window in seconds (1 hour)
}
}
Calculate payouts using CPPSRB method
Request Body:
{
"blockReward": 100,
"shares": [
{ "miner": "Alice", "shares": 50 },
{ "miner": "Bob", "shares": 30 }
]
}
Response:
{
"success": true,
"data": {
"totalShares": 80,
"payouts": [
{
"miner": "Alice",
"shares": 50,
"cappedPayout": 0.5,
"backpay": 0.2,
"totalPayout": 0.7
},
{
"miner": "Bob",
"shares": 30,
"cappedPayout": 0.3,
"backpay": 0.1,
"totalPayout": 0.4
}
],
"parameters": {
"capPerShare": 0.01,
"backpayWindow": 3600
}
}
}
Run unit tests:
npm test
Run linting:
npm run lint
Run formatting:
npm run format
Column | Type | Description |
---|---|---|
id | TEXT | Miner identifier (PK) |
balance | REAL | Current balance |
total_shares | REAL | Total shares submitted |
total_payouts | REAL | Total payouts received |
Column | Type | Description |
---|---|---|
id | INTEGER | Auto-incrementing ID (PK) |
miner_id | TEXT | Miner identifier (FK) |
shares | REAL | Number of shares submitted |
timestamp | DATETIME | When shares were recorded |
Distributed under the MIT License. See LICENSE
for more information.
Chris Bunting - [email protected]
Project Link: https://github.com/yourusername/cpprb-pool