|
|
|
@ -16,20 +16,50 @@ var identityPerBlock = 100000 |
|
|
|
|
|
|
|
|
|
// IdentityChain (Blockchain) keeps Identities per epoch, currently centralized!
|
|
|
|
|
type IdentityChain struct { |
|
|
|
|
Identities []*IdentityBlock |
|
|
|
|
PendingIdentities []*waitnode.WaitNode |
|
|
|
|
log log.Logger |
|
|
|
|
Peer p2p.Peer |
|
|
|
|
Identities []*IdentityBlock |
|
|
|
|
PendingIdentities []*waitnode.WaitNode |
|
|
|
|
log log.Logger |
|
|
|
|
Peer p2p.Peer |
|
|
|
|
SelectedIdentitites []*waitnode.WaitNode |
|
|
|
|
EpochNum int |
|
|
|
|
PeerToShardMap map[p2p.Peer]int |
|
|
|
|
ShardLeaderMap map[int]p2p.Peer |
|
|
|
|
PubKey string |
|
|
|
|
CurrentEpochStartTime int64 |
|
|
|
|
NumberOfShards int |
|
|
|
|
NumberOfNodesInShard int |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func seekRandomNumber(EpochNum int, SelectedIdentitites []*waitnode.WaitNode) int { |
|
|
|
|
return 10 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//GlobalBlockchainConfig stores global level blockchain configurations.
|
|
|
|
|
type GlobalBlockchainConfig struct { |
|
|
|
|
NumberOfShards int |
|
|
|
|
EpochTimeSecs int16 |
|
|
|
|
NumberOfShards int |
|
|
|
|
EpochTimeSecs int16 |
|
|
|
|
MaxNodesInShard int |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Shard
|
|
|
|
|
func (IDC *IdentityChain) Shard() { |
|
|
|
|
num := seekRandomNumber(IDC.EpochNum, IDC.SelectedIdentitites) |
|
|
|
|
fmt.Println(num) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SelectIds
|
|
|
|
|
func (IDC *IdentityChain) SelectIds() { |
|
|
|
|
selectNumber := IDC.NumberOfNodesInShard - len(IDC.Identities) |
|
|
|
|
IB := IDC.GetLatestBlock() |
|
|
|
|
currentIDS := IB.GetIdentities() |
|
|
|
|
pending := IDC.PendingIdentities[:selectNumber] |
|
|
|
|
IDC.SelectedIdentitites = append(currentIDS, pending...) |
|
|
|
|
IDC.PendingIdentities = []*waitnode.WaitNode{} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (IDC *IdentityChain) shard() { |
|
|
|
|
return |
|
|
|
|
//Checks how many new shards we need. Currently we say 0.
|
|
|
|
|
func needNewShards() int { |
|
|
|
|
return 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetLatestBlock gests the latest block at the end of the chain
|
|
|
|
|