fix some send message failure

Signed-off-by: Leo Chen <leo@harmony.one>
pull/304/head
Leo Chen 6 years ago
parent 85baa93be2
commit 8edebd2250
  1. 3
      .gitignore
  2. 3
      internal/beaconchain/libs/beaconchain.go
  3. 5
      internal/newnode/newnode.go
  4. 1
      p2p/host/hostv2/hostv2.go
  5. 4
      test/configs/local_config1.txt
  6. 33
      test/deploy.sh

3
.gitignore vendored

@ -44,3 +44,6 @@ tmp_log
# beacon chain data
bc_config.json
# leveldb local storage
db/

@ -139,6 +139,9 @@ func (bc *BeaconChain) RespondRandomness(Node *node.Info) {
msg := bcconn.SerializeRandomInfo(response)
msgToSend := proto_identity.ConstructIdentityMessage(proto_identity.Acknowledge, msg)
bc.log.Info("Sent Out Msg", "# Nodes", response.NumberOfNodesAdded)
for i, n := range response.Leaders {
bc.log.Info("Sent Out Msg", "leader", i, "nodeInfo", n.PeerID)
}
host.SendMessage(bc.host, bc.Peer, msgToSend, nil)
bc.state = RandomInfoSent
}

@ -46,9 +46,10 @@ func New(ip string, port string) *NewNode {
node.PubK = pubKey
node.priK = priKey
node.Self = p2p.Peer{IP: ip, Port: port, PubKey: pubKey, ValidatorID: -1}
node.log = log.New()
node.log = utils.GetLogInstance()
node.SetInfo = make(chan bool)
node.host, err = p2pimpl.NewHost(&node.Self)
node.log.Info("NewNode New", "Self", node.Self)
if err != nil {
node.log.Error("failed to create new host", "msg", err)
return nil
@ -80,7 +81,7 @@ func (node *NewNode) requestBeaconChain(BCPeer p2p.Peer) (err error) {
if err != nil {
node.log.Error("Could not Marshall public key into binary")
}
nodeInfo := &proto_node.Info{IP: node.Self.IP, Port: node.Self.Port, PubKey: pubk, PeerID: node.host.GetID()}
nodeInfo := &proto_node.Info{IP: node.Self.IP, Port: node.Self.Port, PubKey: pubk, PeerID: node.Self.PeerID}
msg := bcconn.SerializeNodeInfo(nodeInfo)
msgToSend := proto_identity.ConstructIdentityMessage(proto_identity.Register, msg)
gotShardInfo := false

@ -114,7 +114,6 @@ func (host *HostV2) SendMessage(p p2p.Peer, message []byte) error {
return err
}
defer s.Close()
s.Write(message)
return nil

@ -1,5 +1,5 @@
127.0.0.1 9000 leader 0
127.0.0.1 9001 validator 0
127.0.0.1 9001 leader 0
127.0.0.1 9002 validator 0
127.0.0.1 9003 validator 0
127.0.0.1 9004 validator 0
@ -9,4 +9,6 @@
127.0.0.1 9008 validator 0
127.0.0.1 9009 validator 0
127.0.0.1 9010 validator 0
127.0.0.1 9011 validator 0
127.0.0.1 9012 validator 0
127.0.0.1 19999 client 0

@ -133,13 +133,18 @@ if [ -n "$MA" ]; then
HMY_OPT="-bc_addr $MA"
fi
NUM_NN=0
# Start nodes
while IFS='' read -r line || [[ -n "$line" ]]; do
IFS=' ' read ip port mode shardID <<< $line
#echo $ip $port $mode
if [[ "$mode" == "leader" || "$mode" == "validator" ]]; then
$DRYRUN $ROOT/bin/harmony -ip $ip -port $port -log_folder $log_folder $DB -min_peers $MIN $HMY_OPT 2>&1 | tee -a $LOG_FILE &
sleep 0.5
$DRYRUN $ROOT/bin/harmony -ip $ip -port $port -log_folder $log_folder $DB -min_peers $MIN $HMY_OPT 2>&1 | tee -a $LOG_FILE &
sleep 0.5
fi
if [[ "$mode" == "newnode" && "$SYNC" == "true" ]]; then
(( NUM_NN += 35 ))
(sleep $NUM_NN; $DRYRUN $ROOT/bin/harmony -ip $ip -port $port -log_folder $log_folder $DB -min_peers $MIN $HMY_OPT 2>&1 | tee -a $LOG_FILE ) &
fi
done < $config
@ -149,29 +154,17 @@ if [ "$SYNC" == "false" ]; then
fi
if [ "$TXGEN" == "true" ]; then
echo "launching txgen ..."
echo "launching txgen ... wait"
sleep 2
line=$(grep client $config)
IFS=' ' read ip port mode shardID <<< $line
if [ "$mode" == "client" ]; then
$DRYRUN $ROOT/bin/txgen -log_folder $log_folder -duration $DURATION -ip $ip -port $port $HMY_OPT 2>&1 | tee -a $LOG_FILE &
$DRYRUN $ROOT/bin/txgen -log_folder $log_folder -duration $DURATION -ip $ip -port $port $HMY_OPT 2>&1 | tee -a $LOG_FILE
fi
fi
# sleep enough time before consensus reached then add new node for state syncing
if [ "$SYNC" == "true" ]; then
sleep 45
echo "launching new node..."
while IFS='' read -r line || [[ -n "$line" ]]; do
IFS=' ' read ip port mode shardID <<< $line
echo launching newnode $ip $port $mode
if [ "$mode" == "newnode" ]; then
$DRYRUN $ROOT/bin/harmony -ip $ip -port $port -log_folder $log_folder $DB -min_peers $MIN $HMY_OPT 2>&1 | tee -a $LOG_FILE &
sleep 25
fi
done < $config
fi
wait
# save bc_config.json
cp -f bc_config.json $log_folder
cleanup
check_result

Loading…
Cancel
Save