Fix missing byte allocation for typ serialize
This commit is contained in:
parent
6fa5f49bc0
commit
62b7adb967
@ -18,10 +18,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func typToBytes(typ DataTyp) []byte {
|
func typToBytes(typ DataTyp) []byte {
|
||||||
//var b []byte
|
var b [2]byte
|
||||||
b := make([]byte, 2)
|
binary.BigEndian.PutUint16(b[:], uint16(typ))
|
||||||
binary.BigEndian.PutUint16(b, uint16(typ))
|
return b[:]
|
||||||
return b
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func packKey(typ DataTyp, data []byte) []byte {
|
func packKey(typ DataTyp, data []byte) []byte {
|
||||||
@ -33,7 +32,6 @@ func ReadEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp)
|
|||||||
store.SetPrefix(db.DATATYPE_USERDATA)
|
store.SetPrefix(db.DATATYPE_USERDATA)
|
||||||
store.SetSession(sessionId)
|
store.SetSession(sessionId)
|
||||||
k := packKey(typ, []byte(sessionId))
|
k := packKey(typ, []byte(sessionId))
|
||||||
//k := []byte(sessionId)
|
|
||||||
b, err := store.Get(ctx, k)
|
b, err := store.Get(ctx, k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -45,7 +43,6 @@ func ReadEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp)
|
|||||||
func WriteEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp, value []byte) error {
|
func WriteEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp, value []byte) error {
|
||||||
store.SetPrefix(db.DATATYPE_USERDATA)
|
store.SetPrefix(db.DATATYPE_USERDATA)
|
||||||
store.SetSession(sessionId)
|
store.SetSession(sessionId)
|
||||||
//k := packKey(typ, []byte(sessionId))
|
k := packKey(typ, []byte(sessionId))
|
||||||
k := []byte(sessionId)
|
|
||||||
return store.Put(ctx, k, value)
|
return store.Put(ctx, k, value)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user