identity chain

pull/56/head
Alok Kothari 6 years ago
parent b7fd11af5e
commit 69de9e9b27
  1. 47
      identitychain/identity.go
  2. 26
      identitychain/identitychain.go

@ -1,47 +0,0 @@
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
// }

@ -1,8 +1,12 @@
package identitychain
import (
"fmt"
"net"
"os"
"sync"
"github.com/simple-rules/harmony-benchmark/log"
"github.com/simple-rules/harmony-benchmark/waitnode"
)
@ -12,6 +16,7 @@ var mutex sync.Mutex
type IdentityChain struct {
Identities []*IdentityBlock
PendingIdentities []*waitnode.WaitNode
log log.Logger
}
func main() {
@ -25,3 +30,24 @@ func main() {
}()
}
//IdentityChainHandler handles transactions
func (IDC *IdentityChain) IdentityChainHandler(conn net.Conn) {
fmt.Println("yay")
}
func (IDC *IdentityChain) listenOnPort(port string) {
listen, err := net.Listen("tcp4", ":"+port)
defer listen.Close()
if err != nil {
IDC.log.Crit("Socket listen port failed", "port", port, "err", err)
os.Exit(1)
}
for {
conn, err := listen.Accept()
if err != nil {
IDC.log.Crit("Error listening on port. Exiting.", "port", port)
continue
}
go IDC.IdentityChainHandler(conn)
}
}

Loading…
Cancel
Save