Permalink
Browse files

Add option to keep mined tx fees

Credits to @jameshilliard and his PR #40
  • Loading branch information...
sammy007 committed Jun 30, 2016
1 parent 7665e8a commit e5ea4dd35f5233ad929751c102692c60c9b2b549
Showing with 16 additions and 1 deletion.
  1. +2 −0 README.md
  2. +1 −0 config.example.json
  3. +12 −1 payouts/unlocker.go
  4. +1 −0 storage/redis.go
View
@@ -257,6 +257,8 @@ otherwise you will get errors on start because of JSON comments.**
"depth": 120,
// Simply don't touch this option
"immatureDepth": 20,
+ // Keep mined transaction fees as pool fees
+ "keepTxFees": false,
// Run unlocker in this interval
"interval": "10m",
// Geth instance node rpc endpoint for unlocking blocks
View
@@ -87,6 +87,7 @@
"donate": true,
"depth": 120,
"immatureDepth": 20,
+ "keepTxFees": false,
"interval": "10m",
"daemon": "http://127.0.0.1:8545",
"timeout": "10s"
View
@@ -22,6 +22,7 @@ type UnlockerConfig struct {
Donate bool `json:"donate"`
Depth int64 `json:"depth"`
ImmatureDepth int64 `json:"immatureDepth"`
+ KeepTxFees bool `json:"keepTxFees"`
Interval string `json:"interval"`
Daemon string `json:"daemon"`
Timeout string `json:"timeout"`
@@ -211,7 +212,11 @@ func (u *BlockUnlocker) handleBlock(block *rpc.GetBlockReply, candidate *storage
if err != nil {
return fmt.Errorf("Error while fetching TX receipt: %v", err)
}
- reward.Add(reward, extraTxReward)
+ if u.config.KeepTxFees {
+ candidate.ExtraReward = extraTxReward
+ } else {
+ reward.Add(reward, extraTxReward)
+ }
// Add reward for including uncles
rewardForUncles := big.NewInt(0).Mul(uncleReward, big.NewInt(int64(len(block.Uncles))))
@@ -445,6 +450,12 @@ func (u *BlockUnlocker) calculateRewards(block *storage.BlockData) (*big.Rat, *b
rewards := calculateRewardsForShares(shares, block.TotalShares, minersProfit)
+ if block.ExtraReward != nil {
+ extraReward := new(big.Rat).SetInt(block.ExtraReward)
+ poolProfit.Add(poolProfit, extraReward)
+ revenue.Add(revenue, extraReward)
+ }
+
if u.config.Donate {
var donation = new(big.Rat)
poolProfit, donation = chargeFee(poolProfit, donationFee)
View
@@ -38,6 +38,7 @@ type BlockData struct {
PowHash string `json:"-"`
MixDigest string `json:"-"`
Reward *big.Int `json:"-"`
+ ExtraReward *big.Int `json:"-"`
ImmatureReward string `json:"-"`
RewardString string `json:"reward"`
RoundHeight int64 `json:"-"`

0 comments on commit e5ea4dd

Please sign in to comment.