// receive hvs from validator on a given connection
receive hvs from validator on a given connection
// receive hvs from validator on a given connection
func (monitor *Monitor) receiveHvsFromValidator(conn *connection.Connection) {
	packetToSend := &connection.Packet{Code: connection.HvsRequest, Height: monitor.Height}
	if debug {
		log.Printf("Monitor: sending packet to %s", conn.Conn.RemoteAddr().String())
	}
	err := conn.Send(packetToSend)
	if err != nil && debug {
		log.Printf("Monitor: error while sending request to %s: %s", conn.Conn.RemoteAddr().String(), err)
	}
	packet, err := conn.Receive()
	if err != nil {
		if debug {
			if err == io.EOF {
				log.Printf("Monitor: connection has been closed by validator on address %s", conn.Conn.RemoteAddr())
			} else {
				log.Printf("Monitor: error while trying to receive packet from %s: %s", conn.Conn.RemoteAddr(), err)
			}
		}
		packet = &connection.Packet{Code: connection.HvsMissing}
	}
	monitor.receiveChannel <- packet
	conn.Close()
}
func ( monitor * Monitor ) receiveHvsFromValidator ( conn * connection . Connection ) { packetToSend := & connection . Packet { Code : connection . HvsRequest , Height : monitor . Height } if debug { log . Printf ( " " , conn . Conn . RemoteAddr ( ) . String ( ) ) } err := conn . Send ( packetToSend ) if err != nil && debug { log . Printf ( " " , conn . Conn . RemoteAddr ( ) . String ( ) , err ) } packet , err := conn . Receive ( ) if err != nil { if debug { if err == io . EOF { log . Printf ( " " , conn . Conn . RemoteAddr ( ) ) } else { log . Printf ( " " , conn . Conn . RemoteAddr ( ) , err ) } } packet = & connection . Packet { Code : connection . HvsMissing } } monitor . receiveChannel <- packet conn . Close ( ) }
receive hvs from validator on a given connection
receive hvs from validator on a given connection
// prepare packet to send // sending packet to validator // wait to receive packet from validator // if connection is closed or there's an error, exit // notify that will not receive any hvs from the validator on this connection // send packet to main thread // close connection with validator