func (db *DB) GetPeerAddrs() (lnAddresses []lncore.LnAddr, err error) {

	var tx *sql.Tx
	if tx, err = db.DBHandler.Begin(); err != nil {
		return
	}

	// Add commit to defer stack
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while getting peer addrs: \n%s", err)
			return
		}
		err = tx.Commit()
	}()

	// use peer schema
	if _, err = tx.Exec("USE " + db.peerSchema + ";"); err != nil {
		return
	}

	var rows *sql.Rows
	getPeerAddrsQuery := fmt.Sprintf("SELECT lnaddr FROM %s;", db.peerTableName)
	if rows, err = tx.Query(getPeerAddrsQuery); err != nil {
		return
	}

	// Add row close to defer stack
	defer func() {
		if err = rows.Close(); err != nil {
			err = fmt.Errorf("Error closing peer rows: \n%s", err)
		}
	}()

	for rows.Next() {
		var lnAddrBytes []byte
		if err = rows.Scan(&lnAddrBytes); err != nil {
			err = fmt.Errorf("Error scanning for ln addrs: \n%s", err)
			return
		}
		// This does weird stuff when putting the bytes in but creating a string works

		var lnAddr lncore.LnAddr
		if lnAddr, err = lncore.ParseLnAddr(string(lnAddrBytes)); err != nil {
			return
		}

		lnAddresses = append(lnAddresses, lnAddr)
	}

	return
}
// GetPeerAddrs gets the peer lnaddresses from the database
GetPeerAddrs gets the peer lnaddresses from the database
// GetPeerAddrs gets the peer lnaddresses from the database
func (db *DB) GetPeerAddrs() (lnAddresses []lncore.LnAddr, err error) {
	var tx *sql.Tx
	if tx, err = db.DBHandler.Begin(); err != nil {
		return
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while getting peer addrs: \n%s", err)
			return
		}
		err = tx.Commit()
	}()
	if _, err = tx.Exec("USE " + db.peerSchema + ";"); err != nil {
		return
	}
	var rows *sql.Rows
	getPeerAddrsQuery := fmt.Sprintf("SELECT lnaddr FROM %s;", db.peerTableName)
	if rows, err = tx.Query(getPeerAddrsQuery); err != nil {
		return
	}
	defer func() {
		if err = rows.Close(); err != nil {
			err = fmt.Errorf("Error closing peer rows: \n%s", err)
		}
	}()
	for rows.Next() {
		var lnAddrBytes []byte
		if err = rows.Scan(&lnAddrBytes); err != nil {
			err = fmt.Errorf("Error scanning for ln addrs: \n%s", err)
			return
		}
		var lnAddr lncore.LnAddr
		if lnAddr, err = lncore.ParseLnAddr(string(lnAddrBytes)); err != nil {
			return
		}
		lnAddresses = append(lnAddresses, lnAddr)
	}
	return
}
func ( db * DB ) GetPeerAddrs ( ) ( lnAddresses [ ] lncore . LnAddr , err error ) { var tx * sql . Tx if tx , err = db . DBHandler . Begin ( ) ; err != nil { return } defer func ( ) { if err != nil { tx . Rollback ( ) err = fmt . Errorf ( " \n " , err ) return } err = tx . Commit ( ) } ( ) if _ , err = tx . Exec ( " " + db . peerSchema + " " ) ; err != nil { return } var rows * sql . Rows getPeerAddrsQuery := fmt . Sprintf ( " " , db . peerTableName ) if rows , err = tx . Query ( getPeerAddrsQuery ) ; err != nil { return } defer func ( ) { if err = rows . Close ( ) ; err != nil { err = fmt . Errorf ( " \n " , err ) } } ( ) for rows . Next ( ) { var lnAddrBytes [ ] byte if err = rows . Scan ( & lnAddrBytes ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } var lnAddr lncore . LnAddr if lnAddr , err = lncore . ParseLnAddr ( string ( lnAddrBytes ) ) ; err != nil { return } lnAddresses = append ( lnAddresses , lnAddr ) } return }
GetPeerAddrs gets the peer lnaddresses from the database
GetPeerAddrs gets the peer lnaddresses from the database
// Add commit to defer stack // use peer schema // Add row close to defer stack // This does weird stuff when putting the bytes in but creating a string works