-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add big objects support for meta on chain #3063
Changes from all commits
b194cc2
2bbea7f
a87f16d
228d4ac
06e7020
8ebd425
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,47 +5,65 @@ import ( | |
|
||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" | ||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" | ||
objectsdk "github.com/nspcc-dev/neofs-sdk-go/object" | ||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" | ||
) | ||
|
||
const ( | ||
currentVersion = 7 // it is also a number of fields | ||
) | ||
|
||
const ( | ||
networkMagicKey = "network" | ||
// required fields. | ||
cidKey = "cid" | ||
oidKey = "oid" | ||
sizeKey = "size" | ||
validUntilKey = "validUntil" | ||
networkMagicKey = "network" | ||
|
||
// optional fields. | ||
firstPartKey = "firstPart" | ||
previousPartKey = "previousPart" | ||
deletedKey = "deleted" | ||
lockedKey = "locked" | ||
validUntilKey = "validuntil" | ||
typeKey = "type" | ||
) | ||
|
||
// EncodeReplicationMetaInfo uses NEO's map (strict order) serialized format as a raw | ||
// representation of object's meta information. | ||
// | ||
// This (ordered) format is used (keys are strings): | ||
// | ||
// "network": network magic | ||
// "cid": _raw_ container ID (32 bytes) | ||
// "oid": _raw_ object ID (32 bytes) | ||
// "size": payload size | ||
// "deleted": array of _raw_ object IDs | ||
// "locked": array of _raw_ object IDs | ||
// "validuntil": last valid block number for meta information | ||
// | ||
// Last valid epoch is object's creation epoch + 10. | ||
func EncodeReplicationMetaInfo(cID cid.ID, oID oid.ID, pSize uint64, | ||
// "validUntil": last valid block number for meta information | ||
// "network": network magic | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better keep them alphabetically sorted (in optional/non-optional groups). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
👍
👎. Excessive load to the dev brain "where to place new key?". And i like how they are grouped by type currently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
well, my suggestion is not a random order, it was an intention. i grouped it like "logically" or as @cthulhu-rider said, currently, it is by type too. do you have any pros as to why it is better to sort them? new value will be harder to add, and alphabet sorting has no advantages (or change my mind) |
||
// "firstPart": [OPTIONAL] _raw_ object ID (32 bytes) | ||
// "previousPart": [OPTIONAL] _raw_ object ID (32 bytes) | ||
// "deleted": [OPTIONAL] array of _raw_ object IDs | ||
// "locked": [OPTIONAL] array of _raw_ object IDs | ||
// "type": [OPTIONAL] object type enumeration | ||
func EncodeReplicationMetaInfo(cID cid.ID, oID, firstPart, previousPart oid.ID, pSize uint64, typ objectsdk.Type, | ||
deleted, locked []oid.ID, vub uint64, magicNumber uint32) []byte { | ||
kvs := []stackitem.MapElement{ | ||
kv(networkMagicKey, magicNumber), | ||
roman-khimov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kv(cidKey, cID[:]), | ||
kv(oidKey, oID[:]), | ||
kv(sizeKey, pSize), | ||
oidsKV(deletedKey, deleted), | ||
oidsKV(lockedKey, locked), | ||
kv(validUntilKey, vub), | ||
kv(networkMagicKey, magicNumber), | ||
} | ||
|
||
if !firstPart.IsZero() { | ||
kvs = append(kvs, kv(firstPartKey, firstPart[:])) | ||
} | ||
if !previousPart.IsZero() { | ||
kvs = append(kvs, kv(previousPartKey, previousPart[:])) | ||
} | ||
if len(deleted) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'd split unit tests into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
kvs = append(kvs, oidsKV(deletedKey, deleted)) | ||
} | ||
if len(locked) > 0 { | ||
kvs = append(kvs, oidsKV(lockedKey, locked)) | ||
} | ||
if typ != objectsdk.TypeRegular { | ||
kvs = append(kvs, kv(typeKey, uint32(typ))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notice that tombstone/lock can be detected by deleted/locked already. But this covers more things, so OK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean lock type with some non-empy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. although There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
} | ||
|
||
result, err := stackitem.Serialize(stackitem.NewMapWithValue(kvs)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
motivated movement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same as in #3063 (comment)
ok-ok, waste of time, more code to review, etc. but i feel better this way