pull/61/head
ak 6 years ago
parent 5eeca78124
commit 20989c5069
  1. 5
      identitychain/identityblock.go
  2. 34
      identitychain/identitychain.go

@ -30,6 +30,11 @@ func (b *IdentityBlock) Serialize() []byte {
return result.Bytes()
}
//Get Identities
func (b *IdentityBlock) GetIdentities() []*waitnode.WaitNode {
return b.Identities
}
// DeserializeBlock deserializes a block
func DeserializeBlock(d []byte) *IdentityBlock {
var block IdentityBlock

@ -20,16 +20,46 @@ type IdentityChain struct {
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
MaxNodesInShard int
}
func (IDC *IdentityChain) shard() {
return
//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{}
}
//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

Loading…
Cancel
Save