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

55 lines
1.2 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/p2p"
"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
}
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)
}
}
func main() {
var IDC IdentityChain
var nullPeer p2p.Peer
go func() {
genesisBlock := &IdentityBlock{nullPeer, 0}
mutex.Lock()
IDC.Identities = append(IDC.Identities, genesisBlock)
mutex.Unlock()
}()
}