-
Notifications
You must be signed in to change notification settings - Fork 0
/
statedb_caller_config.go
64 lines (55 loc) · 1.75 KB
/
statedb_caller_config.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package staking
import (
"math/big"
"github.com/lvbin2012/NeuralChain/common"
)
// LayOut represents the Offset and Slot order of a state variable
type LayOut struct {
Offset uint16
Slot uint64
}
func (layOut *LayOut) slotHash() common.Hash {
return common.BigToHash(new(big.Int).SetUint64(layOut.Slot))
}
// IndexConfigs represents the configuration index of state variables.
type IndexConfigs struct {
WithdrawsStateLayout LayOut //1
CandidateVotersLayout LayOut //2
CandidateDataLayout LayOut //3
CandidatesLayout LayOut //4
StartBlockLayout LayOut //5
EpochPeriodLayout LayOut //6
MaxValidatorSizeLayout LayOut //7
MinValidatorStakeLayout LayOut //8
MinVoterCapLayout LayOut //9
AdminLayout LayOut //10
CandidateDataStruct CandidateDataStructIndex
}
// layout inside candidateData struct
type CandidateDataStructIndex struct {
Owner LayOut
TotalStake LayOut
VotersStakes LayOut
}
// DefaultConfig represents he default configuration.
var DefaultConfig = &IndexConfigs{
WithdrawsStateLayout: NewLayOut(1, 0),
CandidateVotersLayout: NewLayOut(2, 0),
CandidateDataLayout: NewLayOut(3, 0),
CandidatesLayout: NewLayOut(4, 0),
StartBlockLayout: NewLayOut(5, 0),
EpochPeriodLayout: NewLayOut(6, 0),
MaxValidatorSizeLayout: NewLayOut(7, 0),
MinValidatorStakeLayout: NewLayOut(8, 0),
MinVoterCapLayout: NewLayOut(9, 0),
AdminLayout: NewLayOut(10, 0),
CandidateDataStruct: CandidateDataStructIndex{
TotalStake: NewLayOut(1, 0),
Owner: NewLayOut(2, 0),
VotersStakes: NewLayOut(3, 0),
},
}
// NewLayOut returns new instance of a LayOut
func NewLayOut(slot uint64, offset uint16) LayOut {
return LayOut{Offset: offset, Slot: slot}
}