Commit 238e14a7 authored by Kirill Smelkov's avatar Kirill Smelkov

go/neo/proto: Sync GetObject and docstrings with NEO/py

- Rename GetObject .Tid    -> .Before
- Rename GetObject .Serial -> .At
- Sync docstrings

This corresponds to NEO/py commit 9f0f2afe (protocol: update packet
docstrings).
parent 144dafa0
...@@ -537,8 +537,8 @@ func (c *Client) Load(ctx context.Context, xid zodb.Xid) (buf *mem.Buf, serial z ...@@ -537,8 +537,8 @@ func (c *Client) Load(ctx context.Context, xid zodb.Xid) (buf *mem.Buf, serial z
// on the wire it comes as "before", not "at" // on the wire it comes as "before", not "at"
req := proto.GetObject{ req := proto.GetObject{
Oid: xid.Oid, Oid: xid.Oid,
Tid: at2Before(xid.At), Before: at2Before(xid.At),
Serial: proto.INVALID_TID, At: proto.INVALID_TID,
} }
resp := proto.AnswerObject{} resp := proto.AnswerObject{}
......
...@@ -307,8 +307,8 @@ func TestMasterStorage(t0 *testing.T) { ...@@ -307,8 +307,8 @@ func TestMasterStorage(t0 *testing.T) {
// ... -> GetObject(xid1) // ... -> GetObject(xid1)
tCS.Expect(conntx("c:2", "s:3", 3, &proto.GetObject{ tCS.Expect(conntx("c:2", "s:3", 3, &proto.GetObject{
Oid: xid1.Oid, Oid: xid1.Oid,
Tid: at2Before(xid1.At), Before: at2Before(xid1.At),
Serial: proto.INVALID_TID, At: proto.INVALID_TID,
})) }))
tCS.Expect(conntx("s:3", "c:2", 3, &proto.AnswerObject{ tCS.Expect(conntx("s:3", "c:2", 3, &proto.AnswerObject{
Oid: xid1.Oid, Oid: xid1.Oid,
...@@ -342,8 +342,8 @@ func TestMasterStorage(t0 *testing.T) { ...@@ -342,8 +342,8 @@ func TestMasterStorage(t0 *testing.T) {
// ... -> GetObject(xid1prev) // ... -> GetObject(xid1prev)
tCS.Expect(conntx("c:2", "s:3", 5, &proto.GetObject{ tCS.Expect(conntx("c:2", "s:3", 5, &proto.GetObject{
Oid: xid1prev.Oid, Oid: xid1prev.Oid,
Tid: serial1, Before: serial1,
Serial: proto.INVALID_TID, At: proto.INVALID_TID,
})) }))
tCS.Expect(conntx("s:3", "c:2", 5, &proto.AnswerObject{ tCS.Expect(conntx("s:3", "c:2", 5, &proto.AnswerObject{
Oid: xid1prev.Oid, Oid: xid1prev.Oid,
......
// Copyright (C) 2016-2018 Nexedi SA and Contributors. // Copyright (C) 2016-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -1015,8 +1015,8 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) { ...@@ -1015,8 +1015,8 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) {
case *proto.GetObject: case *proto.GetObject:
err = req.Reply(&proto.AnswerObject{ err = req.Reply(&proto.AnswerObject{
Oid: msg.Oid, Oid: msg.Oid,
Serial: msg.Serial, Serial: msg.At,
DataSerial: msg.Tid, DataSerial: msg.Before,
}) })
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
...@@ -1033,15 +1033,15 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) { ...@@ -1033,15 +1033,15 @@ func benchmarkLinkRTT(b *testing.B, l1, l2 *NodeLink) {
obj := &proto.AnswerObject{} obj := &proto.AnswerObject{}
get.Oid = zodb.Oid(i) get.Oid = zodb.Oid(i)
get.Serial = zodb.Tid(i+1) get.At = zodb.Tid(i+1)
get.Tid = zodb.Tid(i+2) get.Before = zodb.Tid(i+2)
err := l1.Ask1(get, obj) err := l1.Ask1(get, obj)
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }
if !(obj.Oid == get.Oid && obj.Serial == get.Serial && obj.DataSerial == get.Tid) { if !(obj.Oid == get.Oid && obj.Serial == get.At && obj.DataSerial == get.Before) {
b.Fatalf("read back: %v ; requested %v", obj, get) b.Fatalf("read back: %v ; requested %v", obj, get)
} }
......
This diff is collapsed.
...@@ -1907,8 +1907,8 @@ func (p *GetObject) NEOMsgEncodedLen() int { ...@@ -1907,8 +1907,8 @@ func (p *GetObject) NEOMsgEncodedLen() int {
func (p *GetObject) NEOMsgEncode(data []byte) { func (p *GetObject) NEOMsgEncode(data []byte) {
binary.BigEndian.PutUint64(data[0:], uint64(p.Oid)) binary.BigEndian.PutUint64(data[0:], uint64(p.Oid))
binary.BigEndian.PutUint64(data[8:], uint64(p.Serial)) binary.BigEndian.PutUint64(data[8:], uint64(p.At))
binary.BigEndian.PutUint64(data[16:], uint64(p.Tid)) binary.BigEndian.PutUint64(data[16:], uint64(p.Before))
} }
func (p *GetObject) NEOMsgDecode(data []byte) (int, error) { func (p *GetObject) NEOMsgDecode(data []byte) (int, error) {
...@@ -1916,8 +1916,8 @@ func (p *GetObject) NEOMsgDecode(data []byte) (int, error) { ...@@ -1916,8 +1916,8 @@ func (p *GetObject) NEOMsgDecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Oid = zodb.Oid(binary.BigEndian.Uint64(data[0 : 0+8])) p.Oid = zodb.Oid(binary.BigEndian.Uint64(data[0 : 0+8]))
p.Serial = zodb.Tid(binary.BigEndian.Uint64(data[8 : 8+8])) p.At = zodb.Tid(binary.BigEndian.Uint64(data[8 : 8+8]))
p.Tid = zodb.Tid(binary.BigEndian.Uint64(data[16 : 16+8])) p.Before = zodb.Tid(binary.BigEndian.Uint64(data[16 : 16+8]))
return 24, nil return 24, nil
overflow: overflow:
......
// Copyright (C) 2016-2018 Nexedi SA and Contributors. // Copyright (C) 2016-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -533,10 +533,10 @@ func (stor *Storage) serveClient1(ctx context.Context, req proto.Msg) (resp prot ...@@ -533,10 +533,10 @@ func (stor *Storage) serveClient1(ctx context.Context, req proto.Msg) (resp prot
switch req := req.(type) { switch req := req.(type) {
case *proto.GetObject: case *proto.GetObject:
xid := zodb.Xid{Oid: req.Oid} xid := zodb.Xid{Oid: req.Oid}
if req.Serial != proto.INVALID_TID { if req.At != proto.INVALID_TID {
xid.At = req.Serial xid.At = req.At
} else { } else {
xid.At = before2At(req.Tid) xid.At = before2At(req.Before)
} }
obj, err := stor.back.Load(ctx, xid) obj, err := stor.back.Load(ctx, xid)
...@@ -547,11 +547,11 @@ func (stor *Storage) serveClient1(ctx context.Context, req proto.Msg) (resp prot ...@@ -547,11 +547,11 @@ func (stor *Storage) serveClient1(ctx context.Context, req proto.Msg) (resp prot
// compatibility with py side: // compatibility with py side:
// for loadSerial - check we have exact hit - else "nodata" // for loadSerial - check we have exact hit - else "nodata"
if req.Serial != proto.INVALID_TID { if req.At != proto.INVALID_TID {
if obj.Serial != req.Serial { if obj.Serial != req.At {
return &proto.Error{ return &proto.Error{
Code: proto.OID_NOT_FOUND, Code: proto.OID_NOT_FOUND,
Message: fmt.Sprintf("%s: no data with serial %s", xid.Oid, req.Serial), Message: fmt.Sprintf("%s: no data with serial %s", xid.Oid, req.At),
} }
} }
} }
......
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