mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +01:00
Fixed HKEYS command for SQLite3 backend.
This commit is contained in:
parent
b6c041b896
commit
6efb976ba2
@ -4,9 +4,17 @@
|
|||||||
|
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import "strconv"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
// Constructs a database key out of byte slice.
|
// Constructs a database key out of byte slice.
|
||||||
func DecodePosFromBytes(key []byte) (pos int64, err error) {
|
func DecodePosFromBytes(key []byte) (pos int64, err error) {
|
||||||
return strconv.ParseInt(string(key), 10, 64)
|
return strconv.ParseInt(string(key), 10, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Encode a block pos to byte slice.
|
||||||
|
func EncodePosToBytes(key int64) []byte {
|
||||||
|
return []byte(fmt.Sprintf("%d", key))
|
||||||
|
}
|
||||||
|
@ -242,12 +242,12 @@ func (ss *SqliteSession) AllKeys(hash []byte) (keys chan []byte, n int, err erro
|
|||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
defer close(keys)
|
defer close(keys)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var key []byte
|
var key int64
|
||||||
if err := rows.Scan(&key); err != nil {
|
if err := rows.Scan(&key); err != nil {
|
||||||
log.Printf("WARN: %s", err)
|
log.Printf("WARN: %s", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
keys <- key
|
keys <- common.EncodePosToBytes(key)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user