mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 01:00:18 +01:00
Moved coords in separate module.
This commit is contained in:
parent
120531ed78
commit
b6c041b896
@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by the MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
package common
|
||||
|
||||
import "strconv"
|
||||
|
||||
// Constructs a database key out of byte slice.
|
||||
func bytes2pos(key []byte) (pos int64, err error) {
|
||||
func DecodePosFromBytes(key []byte) (pos int64, err error) {
|
||||
return strconv.ParseInt(string(key), 10, 64)
|
||||
}
|
@ -10,6 +10,8 @@ import (
|
||||
"sync"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
|
||||
"bitbucket.org/s_l_teichmann/mtredisalize/common"
|
||||
)
|
||||
|
||||
var globalLock sync.RWMutex
|
||||
@ -137,7 +139,7 @@ func (ss *SqliteSession) txStmt(stmt *sql.Stmt) *sql.Stmt {
|
||||
|
||||
func (ss *SqliteSession) Fetch(hash, key []byte) (data []byte, err error) {
|
||||
var pos int64
|
||||
if pos, err = bytes2pos(key); err != nil {
|
||||
if pos, err = common.DecodePosFromBytes(key); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -159,7 +161,7 @@ func (ss *SqliteSession) InTransaction() bool {
|
||||
|
||||
func (ss *SqliteSession) Store(hash, key, value []byte) (exists bool, err error) {
|
||||
var pos int64
|
||||
if pos, err = bytes2pos(key); err != nil {
|
||||
if pos, err = common.DecodePosFromBytes(key); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user