-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.go
39 lines (34 loc) · 1.56 KB
/
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
package service
import (
nodeconfig "github.com/PositionExchange/posichain/internal/configs/node"
)
// NodeConfig defines a structure of node configuration
// that can be used in services.
// This is to pass node configuration to services and prvent
// cyclic imports
type NodeConfig struct {
// The three groupID design, please refer to https://github.com/PositionExchange/posichain/blob/master/node/node.md#libp2p-integration
Beacon nodeconfig.GroupID // the beacon group ID
ShardGroupID nodeconfig.GroupID // the group ID of the shard
Client nodeconfig.GroupID // the client group ID of the shard
IsBeacon bool // whether this node is a beacon node or not
ShardID uint32 // shardID of this node
Actions map[nodeconfig.GroupID]nodeconfig.ActionType // actions on the groups
}
// GroupIDShards is a map of ShardGroupID ID
// key is the shard ID
// value is the corresponding group ID
var (
GroupIDShards = map[nodeconfig.ShardID]nodeconfig.GroupID{}
GroupIDShardClients = map[nodeconfig.ShardID]nodeconfig.GroupID{}
)
func init() {
// init beacon chain group IDs
GroupIDShards[0] = nodeconfig.NewGroupIDByShardID(0)
GroupIDShardClients[0] = nodeconfig.NewClientGroupIDByShardID(0)
for i := 1; i < nodeconfig.MaxShards; i++ {
sid := nodeconfig.ShardID(i)
GroupIDShards[sid] = nodeconfig.NewGroupIDByShardID(sid)
GroupIDShardClients[sid] = nodeconfig.NewClientGroupIDByShardID(sid)
}
}