-
Notifications
You must be signed in to change notification settings - Fork 211
/
reward.go
36 lines (31 loc) · 914 Bytes
/
reward.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
package mesh
import (
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/log"
"math"
"math/big"
)
type Config struct {
// reward config
BaseReward *big.Int `mapstructure:"base-reward"`
}
func DefaultMeshConfig() Config {
return Config{
BaseReward: big.NewInt(50 * int64(math.Pow10(12))),
}
}
func CalculateLayerReward(id types.LayerID, params Config) *big.Int {
//todo: add inflation rules here
return params.BaseReward
}
func calculateActualRewards(layer types.LayerID, rewards *big.Int, numBlocks *big.Int) *big.Int {
div, mod := new(big.Int).DivMod(rewards, numBlocks, new(big.Int))
log.With().Info("Reward calculated",
log.LayerId(uint64(layer)),
log.Uint64("total_reward", rewards.Uint64()),
log.Uint64("num_blocks", numBlocks.Uint64()),
log.Uint64("block_reward", div.Uint64()),
log.Uint64("reward_remainder", mod.Uint64()),
)
return div
}