mirror of
				https://bitbucket.org/s_l_teichmann/mtsatellite
				synced 2025-10-31 16:15:27 +01:00 
			
		
		
		
	Moved coords in separate module.
This commit is contained in:
		| @@ -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 | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user