Commit 7ade0133 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/zeo: Try to decode OID|TID as both str and bytes

Continuing previous patch also teach ZEO to decode identifies from
on-wire as both [8]str or [8]byte.

Tests pending.
parent d695e2f1
...@@ -35,6 +35,7 @@ import ( ...@@ -35,6 +35,7 @@ import (
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet" "lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/zodb" "lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/internal/pickletools"
) )
type zeo struct { type zeo struct {
...@@ -404,15 +405,17 @@ func init() { ...@@ -404,15 +405,17 @@ func init() {
// xuint64Unpack tries to decode packed 8-byte string as bigendian uint64 // xuint64Unpack tries to decode packed 8-byte string as bigendian uint64
func xuint64Unpack(xv interface{}) (uint64, bool) { func xuint64Unpack(xv interface{}) (uint64, bool) {
s, ok := xv.(string) v, err := pickletools.Xstrbytes8(xv)
if !ok || len(s) != 8 { if err != nil {
return 0, false return 0, false
} }
return binary.BigEndian.Uint64(mem.Bytes(s)), true return v, true
} }
// xuint64Pack packs v into big-endian 8-byte string // xuint64Pack packs v into big-endian 8-byte string
//
// XXX do we need to emit bytes instead of str?
func xuint64Pack(v uint64) string { func xuint64Pack(v uint64) string {
var b [8]byte var b [8]byte
binary.BigEndian.PutUint64(b[:], v) binary.BigEndian.PutUint64(b[:], v)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment