// process packet from client (monitor)
process packet from client (monitor)
// process packet from client ( monitor )
func (validator *Validator) handleIncomingClientData(delay uint64) {
	for clientData := range validator.server.ReceiveChannel {
		time.Sleep(time.Duration(delay) * time.Second)
		packet := clientData.Packet
		conn := clientData.Connection
		if packet != nil && packet.Code == connection.HvsRequest {
			if debug {
				log.Printf("Validator %s at %s: received request for height vote set for height %d", validator.ID, validator.Address, packet.Height)
			}
			hvs, loaded := validator.Messages[packet.Height]
			if hvs != nil && loaded {
				packet.ID = validator.ID
				packet.Code = connection.HvsResponse
				packet.Hvs = hvs
				if debug {
					log.Printf("Validator %s at %s: sending height vote set requested for height %d to monitor", validator.ID, validator.Address, packet.Height)
				}
				err := conn.Send(packet)
				if err != nil && debug {
					log.Printf("Validator %s at %s: error while sending packet back to monitor: %s", validator.ID, validator.Address, err)
				}
			} else {
				if debug {
					log.Printf("Validator %s at %s does not have any message logs for height %d", validator.ID, validator.Address, packet.Height)
				}
			}
		}
	}
}
func ( validator * Validator ) handleIncomingClientData ( delay uint64 ) { for clientData := range validator . server . ReceiveChannel { time . Sleep ( time . Duration ( delay ) * time . Second ) packet := clientData . Packet conn := clientData . Connection if packet != nil && packet . Code == connection . HvsRequest { if debug { log . Printf ( " " , validator . ID , validator . Address , packet . Height ) } hvs , loaded := validator . Messages [ packet . Height ] if hvs != nil && loaded { packet . ID = validator . ID packet . Code = connection . HvsResponse packet . Hvs = hvs if debug { log . Printf ( " " , validator . ID , validator . Address , packet . Height ) } err := conn . Send ( packet ) if err != nil && debug { log . Printf ( " " , validator . ID , validator . Address , err ) } } else { if debug { log . Printf ( " " , validator . ID , validator . Address , packet . Height ) } } } } }
process packet from client (monitor)
process packet from client ( monitor )
// process client data from server channel // wait some time to answer back, if requested // get packet and connection // if it's a request packet, send the response back // load height vote set // if validator does not have any message log for requested height, send error message // prepare packet // send response