From 10c61e371e64417077104f5be2949d21701b0cc3 Mon Sep 17 00:00:00 2001 From: Alok Kothari Date: Thu, 16 Aug 2018 17:45:27 -0700 Subject: [PATCH] saving changes --- identitychain/identity.go | 47 ++++++++++++++++++++++++++++++++++ identitychain/identityblock.go | 9 +++++++ 2 files changed, 56 insertions(+) create mode 100644 identitychain/identity.go create mode 100644 identitychain/identityblock.go diff --git a/identitychain/identity.go b/identitychain/identity.go new file mode 100644 index 000000000..88da487a3 --- /dev/null +++ b/identitychain/identity.go @@ -0,0 +1,47 @@ +package identitychain + +// IdentityChain (Blockchain) keeps Identities per epoch +type IdentityChain struct { + Identities []*IdentityBlock + PendingIdentities []*Node + Logger log +} + +// func main() { +// err := godotenv.Load() +// if err != nil { +// log.Fatal(err) +// } + +// go func() { +// t := time.Now() +// genesisBlock := Block{} +// genesisBlock = Block{0, t.String(), 0, calculateHash(genesisBlock), "", difficulty, ""} + +// mutex.Lock() +// Blockchain = append(Blockchain, genesisBlock) +// mutex.Unlock() +// }() +// log.Fatal(run()) + +// } + +// // web server +// func run() error { +// mux := makeMuxRouter() +// httpPort := os.Getenv("PORT") +// log.Println("HTTP Server Listening on port :", httpPort) +// s := &http.Server{ +// Addr: ":" + httpPort, +// Handler: mux, +// ReadTimeout: 10 * time.Second, +// WriteTimeout: 10 * time.Second, +// MaxHeaderBytes: 1 << 20, +// } + +// if err := s.ListenAndServe(); err != nil { +// return err +// } + +// return nil +// } diff --git a/identitychain/identityblock.go b/identitychain/identityblock.go new file mode 100644 index 000000000..39c539f0b --- /dev/null +++ b/identitychain/identityblock.go @@ -0,0 +1,9 @@ +package identitychain + +// IdentityBlock has the information of one node +type IdentityBlock struct { + ID int + IP string + Port string + NumIdentities int32 +}