The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/identitychain/identitychain.go

54 lines
1.1 KiB

package identitychain
import (
6 years ago
"fmt"
"net"
"os"
"sync"
6 years ago
"github.com/simple-rules/harmony-benchmark/log"
"github.com/simple-rules/harmony-benchmark/waitnode"
)
var mutex sync.Mutex
// IdentityChain (Blockchain) keeps Identities per epoch, currently centralized!
type IdentityChain struct {
Identities []*IdentityBlock
PendingIdentities []*waitnode.WaitNode
6 years ago
log log.Logger
}
func main() {
var IDC IdentityChain
go func() {
genesisBlock := &IdentityBlock{0, "127.0.0.1", "8080", 0}
mutex.Lock()
IDC.Identities = append(IDC.Identities, genesisBlock)
mutex.Unlock()
}()
}
6 years ago
//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)
}
}