Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit b6a7ceb

Browse files
committed
Don't reward shares which are too lagging behind
1 parent ccdfbef commit b6a7ceb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: proxy/blocks.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/CryptoManiac/open-ethereum-pool/util"
1414
)
1515

16-
const maxBacklog = 3
16+
const maxBacklog = 6
1717

1818
type heightDiffPair struct {
1919
diff *big.Int

Diff for: util/util.go

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/ethereum/go-ethereum/common/math"
1111
)
1212

13+
const maxUncleLag = 2
14+
1315
var Ether = math.BigPow(10, 18)
1416
var Shannon = math.BigPow(10, 9)
1517

@@ -59,18 +61,26 @@ func FormatRatReward(reward *big.Rat) string {
5961

6062
// Calculate PPS rate at given block and share height
6163
func GetShareReward(shareDiff, netDiff int64, height, topHeight uint64, fee float64) float64 {
64+
// Don't reward shares which are too lagging behind the tip
65+
if topHeight-height > maxUncleLag {
66+
return 0.0
67+
}
68+
69+
// Base reward
6270
base := new(big.Rat).SetInt(Ether)
6371
base.Mul(base, new(big.Rat).SetInt64(3))
6472
feePercent := new(big.Rat).SetFloat64(fee / 100)
6573
feeValue := new(big.Rat).Mul(base, feePercent)
6674
base.Sub(base, feeValue)
6775

76+
// Reward with given tip and share height
6877
R := new(big.Rat).SetInt64(int64(height))
6978
R.Add(R, new(big.Rat).SetInt64(8))
7079
R.Sub(R, new(big.Rat).SetInt64(int64(topHeight)))
7180
R.Mul(R, base)
7281
R.Quo(R, new(big.Rat).SetInt64(8))
7382

83+
// Actual share reward
7484
wei := R
7585
wei.Mul(wei, new(big.Rat).SetInt64(shareDiff))
7686
wei.Quo(wei, new(big.Rat).SetInt64(netDiff))

0 commit comments

Comments
 (0)