mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 18:15:19 +00:00
20 lines
582 B
Markdown
20 lines
582 B
Markdown
|
<!--
|
||
|
order: 6
|
||
|
-->
|
||
|
|
||
|
# Begin Block
|
||
|
|
||
|
At the start of each block, hard tokens are distributed (as claims) to liquidity providers and delegators, respectively.
|
||
|
|
||
|
```go
|
||
|
// BeginBlocker applies rewards to liquidity providers and delegators according to params
|
||
|
func BeginBlocker(ctx sdk.Context, k Keeper) {
|
||
|
k.ApplyDepositRewards(ctx)
|
||
|
if k.ShouldDistributeValidatorRewards(ctx, k.BondDenom(ctx)) {
|
||
|
k.ApplyDelegationRewards(ctx, k.BondDenom(ctx))
|
||
|
k.SetPreviousDelegationDistribution(ctx, ctx.BlockTime(), k.BondDenom(ctx))
|
||
|
}
|
||
|
k.SetPreviousBlockTime(ctx, ctx.BlockTime())
|
||
|
}
|
||
|
```
|