|
|
@ -16,20 +16,50 @@ var identityPerBlock = 100000 |
|
|
|
|
|
|
|
|
|
|
|
// IdentityChain (Blockchain) keeps Identities per epoch, currently centralized!
|
|
|
|
// IdentityChain (Blockchain) keeps Identities per epoch, currently centralized!
|
|
|
|
type IdentityChain struct { |
|
|
|
type IdentityChain struct { |
|
|
|
Identities []*IdentityBlock |
|
|
|
Identities []*IdentityBlock |
|
|
|
PendingIdentities []*waitnode.WaitNode |
|
|
|
PendingIdentities []*waitnode.WaitNode |
|
|
|
log log.Logger |
|
|
|
log log.Logger |
|
|
|
Peer p2p.Peer |
|
|
|
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.
|
|
|
|
//GlobalBlockchainConfig stores global level blockchain configurations.
|
|
|
|
type GlobalBlockchainConfig struct { |
|
|
|
type GlobalBlockchainConfig struct { |
|
|
|
NumberOfShards int |
|
|
|
NumberOfShards int |
|
|
|
EpochTimeSecs int16 |
|
|
|
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() { |
|
|
|
//Checks how many new shards we need. Currently we say 0.
|
|
|
|
return |
|
|
|
func needNewShards() int { |
|
|
|
|
|
|
|
return 0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetLatestBlock gests the latest block at the end of the chain
|
|
|
|
// GetLatestBlock gests the latest block at the end of the chain
|
|
|
|