func (db *DB) GetPeerInfos() (peerInfos map[lncore.LnAddr]lncore.PeerInfo, 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 all peer infos: \n%s", err)
			return
		}
		err = tx.Commit()
	}()

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

	// TODO: Finish this function
	var rows *sql.Rows
	getPeerInfosQuery := fmt.Sprintf("SELECT lnaddr, name, netaddr, peerIdx FROM %s;", db.peerTableName)
	if rows, err = tx.Query(getPeerInfosQuery); 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)
		}
	}()

	// make the map
	peerInfos = make(map[lncore.LnAddr]lncore.PeerInfo)

	// only get one, that's why we use if instead of for
	for rows.Next() {
		// init the data
		var lnAddrBytes []byte
		var nickname string
		var netAddr string
		var peerIdx uint32

		if err = rows.Scan(&lnAddrBytes, &nickname, &netAddr, &peerIdx); err != nil {
			err = fmt.Errorf("Error scanning for peer info: \n%s", err)
			return
		}

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

		// actually set the data to return
		peerInfos[lnAddr] = lncore.PeerInfo{
			LnAddr:   &lnAddr,
			Nickname: &nickname,
			NetAddr:  &netAddr,
			PeerIdx:  peerIdx,
		}

	}

	return
}
// GetPeerInfos gets a map of lnaddr's to peer info
GetPeerInfos gets a map of lnaddr's to peer info
// GetPeerInfos gets a map of lnaddr ' s to peer info
func (db *DB) GetPeerInfos() (peerInfos map[lncore.LnAddr]lncore.PeerInfo, 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 all peer infos: \n%s", err)
			return
		}
		err = tx.Commit()
	}()
	if _, err = tx.Exec("USE " + db.peerSchema + ";"); err != nil {
		return
	}
	var rows *sql.Rows
	getPeerInfosQuery := fmt.Sprintf("SELECT lnaddr, name, netaddr, peerIdx FROM %s;", db.peerTableName)
	if rows, err = tx.Query(getPeerInfosQuery); err != nil {
		return
	}
	defer func() {
		if err = rows.Close(); err != nil {
			err = fmt.Errorf("Error closing peer rows: \n%s", err)
		}
	}()
	peerInfos = make(map[lncore.LnAddr]lncore.PeerInfo)
	for rows.Next() {
		var lnAddrBytes []byte
		var nickname string
		var netAddr string
		var peerIdx uint32
		if err = rows.Scan(&lnAddrBytes, &nickname, &netAddr, &peerIdx); err != nil {
			err = fmt.Errorf("Error scanning for peer info: \n%s", err)
			return
		}
		var lnAddr lncore.LnAddr
		if lnAddr, err = lncore.ParseLnAddr(string(lnAddrBytes)); err != nil {
			return
		}
		peerInfos[lnAddr] = lncore.PeerInfo{
			LnAddr:   &lnAddr,
			Nickname: &nickname,
			NetAddr:  &netAddr,
			PeerIdx:  peerIdx,
		}
	}
	return
}
func ( db * DB ) GetPeerInfos ( ) ( peerInfos map [ lncore . LnAddr ] lncore . PeerInfo , 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 getPeerInfosQuery := fmt . Sprintf ( " " , db . peerTableName ) if rows , err = tx . Query ( getPeerInfosQuery ) ; err != nil { return } defer func ( ) { if err = rows . Close ( ) ; err != nil { err = fmt . Errorf ( " \n " , err ) } } ( ) peerInfos = make ( map [ lncore . LnAddr ] lncore . PeerInfo ) for rows . Next ( ) { var lnAddrBytes [ ] byte var nickname string var netAddr string var peerIdx uint32 if err = rows . Scan ( & lnAddrBytes , & nickname , & netAddr , & peerIdx ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } var lnAddr lncore . LnAddr if lnAddr , err = lncore . ParseLnAddr ( string ( lnAddrBytes ) ) ; err != nil { return } peerInfos [ lnAddr ] = lncore . PeerInfo { LnAddr : & lnAddr , Nickname : & nickname , NetAddr : & netAddr , PeerIdx : peerIdx , } } return }
GetPeerInfos gets a map of lnaddr's to peer info
GetPeerInfos gets a map of lnaddr ' s to peer info
// use peer schema // TODO: Finish this function // Add row close to defer stack // make the map // only get one, that's why we use if instead of for // init the data // actually set the data to return