@ -77,7 +77,7 @@ func (node *Node) NodeHandler(conn net.Conn) {
if consensusObj . IsLeader {
if consensusObj . IsLeader {
consensusObj . ProcessMessageLeader ( msgPayload )
consensusObj . ProcessMessageLeader ( msgPayload )
} else {
} else {
consensusObj . ProcessMessageValidator ( msgPayload )
consensusObj . ProcessMessageValidator ( msgPayload , node . blockSyncing , node . syncNode )
}
}
}
}
case proto . NODE :
case proto . NODE :
@ -97,7 +97,7 @@ func (node *Node) NodeHandler(conn net.Conn) {
}
}
}
}
case proto_node . BLOCKCHAIN_SYNC :
case proto_node . BLOCKCHAIN_SYNC :
node . transactionMessageHandler ( msgPayload )
node . handleBlockchainSync ( conn )
case proto_node . CLIENT :
case proto_node . CLIENT :
clientMsgType := proto_node . ClientMessageType ( msgPayload [ 0 ] )
clientMsgType := proto_node . ClientMessageType ( msgPayload [ 0 ] )
switch clientMsgType {
switch clientMsgType {
@ -168,6 +168,12 @@ func (node *Node) NodeHandler(conn net.Conn) {
}
}
}
}
func ( node * Node ) handleBlockchainSync ( conn net . Conn ) {
for {
}
}
func ( node * Node ) transactionMessageHandler ( msgPayload [ ] byte ) {
func ( node * Node ) transactionMessageHandler ( msgPayload [ ] byte ) {
txMessageType := proto_node . TransactionMessageType ( msgPayload [ 0 ] )
txMessageType := proto_node . TransactionMessageType ( msgPayload [ 0 ] )
@ -224,10 +230,11 @@ func (node *Node) WaitForConsensusReady(readySignal chan struct{}) {
timeoutCount := 0
timeoutCount := 0
for { // keep waiting for Consensus ready
for { // keep waiting for Consensus ready
retry := false
retry := false
// TODO(minhdoan, rj): Refactor by sending signal in channel instead of waiting for 10 seconds.
select {
select {
case <- readySignal :
case <- readySignal :
time . Sleep ( 100 * time . Millisecond ) // Delay a bit so validator is catched up.
time . Sleep ( 100 * time . Millisecond ) // Delay a bit so validator is catched up.
case <- time . After ( 10 * time . Second ) :
case <- time . After ( 100 * time . Second ) :
retry = true
retry = true
node . Consensus . ResetState ( )
node . Consensus . ResetState ( )
timeoutCount ++
timeoutCount ++
@ -365,9 +372,9 @@ func (node *Node) UpdateUtxoAndState(newBlock *blockchain.Block) {
// //fmt.Println(newBlock.Transactions)
// //fmt.Println(newBlock.Transactions)
// fmt.Printf("LEADER CURRENT UTXO - %d\n", node.UtxoPool.ShardID)
// fmt.Printf("LEADER CURRENT UTXO - %d\n", node.UtxoPool.ShardID)
// fmt.Println(node.UtxoPool.CountNumOfUtxos())
// fmt.Println(node.UtxoPool.CountNumOfUtxos())
// // fmt.Println(node.UtxoPool)
// fmt.Println(node.UtxoPool)
// fmt.Printf("LEADER LOCKED UTXO - %d\n", node.UtxoPool.ShardID)
// fmt.Printf("LEADER LOCKED UTXO - %d\n", node.UtxoPool.ShardID)
// fmt.Println(node.UtxoPool.CountNumOfLockedUtxos())
// fmt.Println(node.UtxoPool.CountNumOfLockedUtxos())
// // fmt.Println(node.UtxoPool.StringOfLockedUtxos())
// fmt.Println(node.UtxoPool.StringOfLockedUtxos())
//}
//}
}
}