diff --git a/identitychain/identityblock.go b/identitychain/identityblock.go index 1cadc2f6f..53c7403b1 100644 --- a/identitychain/identityblock.go +++ b/identitychain/identityblock.go @@ -43,12 +43,12 @@ func DeserializeBlock(d []byte) *IdentityBlock { // NewBlock creates and returns a new block. func NewBlock(Identities []*waitnode.WaitNode, prevBlockHash [32]byte) *IdentityBlock { - numTxs := int32(len(Identities)) + numIds := int32(len(Identities)) var Ids []*waitnode.WaitNode for _, ids := range Identities { Ids = append(Ids, ids) } - block := &IdentityBlock{Timestamp: time.Now().Unix(), PrevBlockHash: prevBlockHash, NumIdentities: numTxs, Identities: Ids} + block := &IdentityBlock{Timestamp: time.Now().Unix(), PrevBlockHash: prevBlockHash, NumIdentities: numIds, Identities: Ids} return block } @@ -65,3 +65,11 @@ func (b *IdentityBlock) CalculateBlockHash() []byte { blockHash = sha256.Sum256(bytes.Join(hashes, []byte{})) return blockHash[:] } + +// NewGenesisBlock creates and returns genesis Block. +func NewGenesisBlock() *IdentityBlock { + numTxs := 0 + var Ids []*waitnode.WaitNode + block := &IdentityBlock{Timestamp: time.Now().Unix(), PrevBlockHash: [32]byte{}, NumIdentities: 1, Identities: Ids} + return block +}