-
Notifications
You must be signed in to change notification settings - Fork 136
/
genesis.go
33 lines (29 loc) · 1.03 KB
/
genesis.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
package types
import (
bbn "github.com/babylonchain/babylon/types"
)
// DefaultGenesis returns the default Capability genesis state
func DefaultGenesis() *GenesisState {
headerBytes := bbn.GetBaseBTCHeaderBytes()
headerHeight := bbn.GetBaseBTCHeaderHeight()
headerHash := headerBytes.Hash()
// The cumulative work for the Base BTC header is only the work
// for that particular header. This means that it is very important
// that no forks will happen that discard the base header because we
// will not be able to detect those. Cumulative work will build based
// on the sum of the work of the chain starting from the base header.
headerWork := CalcWork(&headerBytes)
baseHeaderInfo := NewBTCHeaderInfo(&headerBytes, headerHash, headerHeight, &headerWork)
return &GenesisState{
BaseBtcHeader: *baseHeaderInfo,
}
}
// Validate performs basic genesis state validation returning an error upon any
// failure.
func (gs GenesisState) Validate() error {
err := gs.BaseBtcHeader.Validate()
if err != nil {
return err
}
return nil
}