|
|
@ -74,6 +74,7 @@ func loggingInit(logFolder, role, ip, port string, onlyLogTps bool) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
|
|
|
|
accountModel := flag.Bool("account_model", false, "Whether to use account model") |
|
|
|
// TODO: use http://getmyipaddress.org/ or http://www.get-myip.com/ to retrieve my IP address
|
|
|
|
// TODO: use http://getmyipaddress.org/ or http://www.get-myip.com/ to retrieve my IP address
|
|
|
|
ip := flag.String("ip", "127.0.0.1", "IP of the node") |
|
|
|
ip := flag.String("ip", "127.0.0.1", "IP of the node") |
|
|
|
port := flag.String("port", "9000", "port of the node.") |
|
|
|
port := flag.String("port", "9000", "port of the node.") |
|
|
@ -190,20 +191,34 @@ func main() { |
|
|
|
|
|
|
|
|
|
|
|
// Assign closure functions to the consensus object
|
|
|
|
// Assign closure functions to the consensus object
|
|
|
|
consensus.BlockVerifier = currentNode.VerifyNewBlock |
|
|
|
consensus.BlockVerifier = currentNode.VerifyNewBlock |
|
|
|
|
|
|
|
if *accountModel { |
|
|
|
|
|
|
|
consensus.BlockVerifier = currentNode.VerifyNewBlockAccount |
|
|
|
|
|
|
|
} |
|
|
|
consensus.OnConsensusDone = currentNode.PostConsensusProcessing |
|
|
|
consensus.OnConsensusDone = currentNode.PostConsensusProcessing |
|
|
|
|
|
|
|
|
|
|
|
// Temporary testing code, to be removed.
|
|
|
|
// Temporary testing code, to be removed.
|
|
|
|
currentNode.AddTestingAddresses(10000) |
|
|
|
currentNode.AddTestingAddresses(10000) |
|
|
|
|
|
|
|
|
|
|
|
if consensus.IsLeader { |
|
|
|
if consensus.IsLeader { |
|
|
|
// Let consensus run
|
|
|
|
if *accountModel { |
|
|
|
go func() { |
|
|
|
// Let consensus run
|
|
|
|
consensus.WaitForNewBlock(currentNode.BlockChannel) |
|
|
|
go func() { |
|
|
|
}() |
|
|
|
consensus.WaitForNewBlockAccount(currentNode.BlockChannelAccount) |
|
|
|
// Node waiting for consensus readiness to create new block
|
|
|
|
}() |
|
|
|
go func() { |
|
|
|
// Node waiting for consensus readiness to create new block
|
|
|
|
currentNode.WaitForConsensusReady(consensus.ReadySignal) |
|
|
|
go func() { |
|
|
|
}() |
|
|
|
currentNode.WaitForConsensusReadyAccount(consensus.ReadySignal) |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// Let consensus run
|
|
|
|
|
|
|
|
go func() { |
|
|
|
|
|
|
|
consensus.WaitForNewBlock(currentNode.BlockChannel) |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
// Node waiting for consensus readiness to create new block
|
|
|
|
|
|
|
|
go func() { |
|
|
|
|
|
|
|
currentNode.WaitForConsensusReady(consensus.ReadySignal) |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
currentNode.StartServer(*port) |
|
|
|
currentNode.StartServer(*port) |
|
|
|