func processTableResponse(response []byte, db *DB, peerPubKey [33]byte, lnClient *lndwrapper.Lnd) error {

	var dest *destination
	var serializedDest []byte

	//Check if the response has enough length for it to be valid
	if len(response) < messageTypeSize+tableResponseHeaderSize {
		return errors.New("Invalid table response message size")
	}

	//Extract the type of message
	responseTypeBytes := response[:2]
	responseType := binary.BigEndian.Uint16(responseTypeBytes)

	//Validate the type of message
	if responseType != tableResponseType {
		return errors.New("Invalid table response message type")
	}

	//Extract the number of entries
	entriesCountBytes := response[2:4]
	entriesCount := int(binary.BigEndian.Uint16(entriesCountBytes))

	//Extract the entries and add them to the database
	for n := 0; n < entriesCount; n++ {
		serializedDest = response[4+n*destinationSize : 4+(n+1)*destinationSize]
		dest = deserializeDestination(serializedDest)
		log.Println("Adding destination to DB:", dest)
		db.addNewDestinationToDB(dest, peerPubKey, lnClient)
	}

	return nil
}
//Processes the response of a previously made table request
Processes the response of a previously made table request
// Processes the response of a previously made table request
func processTableResponse(response []byte, db *DB, peerPubKey [33]byte, lnClient *lndwrapper.Lnd) error {
	var dest *destination
	var serializedDest []byte
	if len(response) < messageTypeSize+tableResponseHeaderSize {
		return errors.New("Invalid table response message size")
	}
	responseTypeBytes := response[:2]
	responseType := binary.BigEndian.Uint16(responseTypeBytes)
	if responseType != tableResponseType {
		return errors.New("Invalid table response message type")
	}
	entriesCountBytes := response[2:4]
	entriesCount := int(binary.BigEndian.Uint16(entriesCountBytes))
	for n := 0; n < entriesCount; n++ {
		serializedDest = response[4+n*destinationSize : 4+(n+1)*destinationSize]
		dest = deserializeDestination(serializedDest)
		log.Println("Adding destination to DB:", dest)
		db.addNewDestinationToDB(dest, peerPubKey, lnClient)
	}
	return nil
}
func processTableResponse ( response [ ] byte , db * DB , peerPubKey [ 33 ] byte , lnClient * lndwrapper . Lnd ) error { var dest * destination var serializedDest [ ] byte if len ( response ) < messageTypeSize + tableResponseHeaderSize { return errors . New ( " " ) } responseTypeBytes := response [ : 2 ] responseType := binary . BigEndian . Uint16 ( responseTypeBytes ) if responseType != tableResponseType { return errors . New ( " " ) } entriesCountBytes := response [ 2 : 4 ] entriesCount := int ( binary . BigEndian . Uint16 ( entriesCountBytes ) ) for n := 0 ; n < entriesCount ; n ++ { serializedDest = response [ 4 + n * destinationSize : 4 + ( n + 1 ) * destinationSize ] dest = deserializeDestination ( serializedDest ) log . Println ( " " , dest ) db . addNewDestinationToDB ( dest , peerPubKey , lnClient ) } return nil }
Processes the response of a previously made table request
Processes the response of a previously made table request
//Check if the response has enough length for it to be valid //Extract the type of message //Validate the type of message //Extract the number of entries //Extract the entries and add them to the database