pull/61/head
ak 6 years ago
parent 5eeca78124
commit 20989c5069
  1. 5
      identitychain/identityblock.go
  2. 46
      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

@ -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

Loading…
Cancel
Save