Shell for mutable object #206
Replies: 4 comments 3 replies
-
This is the storage requirement for an object. So, I think we could extend the // StorageObject
message StorageDescContent {
string id = 1;
optional bytes hash = 2;
}
message StorageBodyContent {
bytes value = 1;
optional bytes freedom_attachment = 2; // content without hash, you can update it with the same hash in `Desc`;
} And, we can implment a structure for pub struct ObjectShell<O> {
raw: O;
flags: u8; // FLAG_SIGNATURE_FREEDOM | FLAG_NONCE_FREEDOM
}
impl ObjectShell<O> {
pub fn from_storage(storage: &Storage) -> BuckyResult<Self>;
pub fn to_storage(&self) -> Storage;
pub fn shell_id(&self) -> ObjectId;
pub fn from_object(obj: O, flags: u8) -> Self;
pub fn as_ref(&self) -> &O;
pub fn as_mut(&mut self) -> &mut O; // update the raw object
}
impl RawEncode for ObjectShell {
fn raw_encode(&self, buf: &mut [u8]) -> BuckyResult<&mut [u8]> {
let mut raw = self.raw.clone();
if self.flags & FLAG_SIGNATURE_FREEDOM {
raw.clear_signatures();
}
if self.flags & FLAG_NONCE_FREEDOM {
raw.clear_nonce();
}
let value = self.flags + raw.encode(); // save unfreedom fields in value, and check it with the Storage.hash;
let freedom = ${exist_freedom_field_flags} // freedom and exist fields
+ [self.raw.signature] // signatures if freedom and exist, otherwise is none
+ [self.raw.nonce] // nonce if freedom and exist, otherwise is none
}
}
impl RawDecode for ObjectShell {
fn raw_decode(buf: &[u8]) -> BuckyResult<&[u8]> {
}
} |
Beta Was this translation helpful? Give feedback.
-
How does the cyfs-stack store multiple versions of the same object locally? According to our design principle, different versions of an object refer to different versions generated after the body is modified, identified by the The storage principle for multiple versions of objects with mutable bodies is as follows:
So the addition of a ShellObject object you mentioned to implement local noc storage of multiple versions is theoretically feasible. I have a few questions and suggestions for your reference:
|
Beta Was this translation helpful? Give feedback.
-
Is there a contradiction between the two you mentioned?
|
Beta Was this translation helpful? Give feedback.
-
Anyone can pay attention at this issue |
Beta Was this translation helpful? Give feedback.
-
I have a scenario where upgrading a mutable object is a process where there may be an old version object and multiple updating objects at the same time, which is not possible in the current
NOC
system.So, I want to design a shell that has the following properties:
NOC
;body
/signature/nonce
sections can decide if they lead to new shell construction according to the scenario:body
changes. At this time, you can add a signature to the original object, but continue to store it in the old shellnonce
changes also generate new shellsBeta Was this translation helpful? Give feedback.
All reactions