-
Notifications
You must be signed in to change notification settings - Fork 460
/
rewards.go
45 lines (42 loc) · 1.26 KB
/
rewards.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package misc
import (
"log"
"math/big"
"github.com/dominant-strategies/go-quai/common"
)
// CalculateReward calculates the coinbase rewards depending on the type of the block
// regions = # of regions
// zones = # of zones
// For each prime = Reward/3
// For each region = Reward/(3*regions*time-factor)
// For each zone = Reward/(3*regions*zones*time-factor^2)
func CalculateReward() *big.Int {
reward := big.NewInt(5e18)
reward.Mul(reward, big.NewInt(1000))
timeFactor := big.NewInt(10)
regions := big.NewInt(3)
zones := big.NewInt(3)
context := common.NodeLocation.Context()
if context == common.PRIME_CTX {
primeReward := big.NewInt(3)
primeReward.Div(reward, primeReward)
return primeReward
} else if context == common.REGION_CTX {
regionReward := big.NewInt(3)
regionReward.Mul(regionReward, regions)
regionReward.Mul(regionReward, timeFactor)
regionReward.Div(reward, regionReward)
return regionReward
} else if context == common.ZONE_CTX {
zoneReward := big.NewInt(3)
zoneReward.Mul(zoneReward, regions)
zoneReward.Mul(zoneReward, zones)
zoneReward.Mul(zoneReward, timeFactor)
zoneReward.Mul(zoneReward, timeFactor)
zoneReward.Div(reward, zoneReward)
return zoneReward
} else {
log.Fatal("unknown node context")
return nil
}
}