pub fn create_append_op(
        &mut self,
        entry: Entry,
        source: PublicKey,
    ) -> Result<CrdtDataOperation<A, Entry>> {
        // Retrieve the LSeq corresponding to the current Policy,
        // or create and insert one if there is none.
        let address = *self.address();

        // Let's retrieve current Policy
        match self.policy.last_entry() {
            None => Err(Error::InvalidOperation),
            Some(cur_policy) => match self.data.get_mut(&cur_policy.id) {
                None => Err(Error::CrdtUnexpectedState),
                Some(lseq) => {
                    // Append the entry to the LSeq corresponding to current Policy
                    // TODO: lseq should not apply the op yet
                    let crdt_op = lseq.append(entry);

                    // We return the operation as it may need to be broadcasted to other replicas
                    Ok(CrdtDataOperation {
                        address,
                        crdt_op,
                        source,
                        ctx: cur_policy.id.clone(),
                        signature: None,
                    })
                }
            },
        }
    }
/// Create crdt op to append a new item to the SequenceCrdt
Create crdt op to append a new item to the SequenceCrdt
Create crdt op to append a new item to the SequenceCrdt
pub fn create_append_op(
        &mut self,
        entry: Entry,
        source: PublicKey,
    ) -> Result<CrdtDataOperation<A, Entry>> {
        // Retrieve the LSeq corresponding to the current Policy,
        // or create and insert one if there is none.
        let address = *self.address();
        // Let's retrieve current Policy
        match self.policy.last_entry() {
            None => Err(Error::InvalidOperation),
            Some(cur_policy) => match self.data.get_mut(&cur_policy.id) {
                None => Err(Error::CrdtUnexpectedState),
                Some(lseq) => {
                    // Append the entry to the LSeq corresponding to current Policy
                    // TODO: lseq should not apply the op yet
                    let crdt_op = lseq.append(entry);
                    // We return the operation as it may need to be broadcasted to other replicas
                    Ok(CrdtDataOperation {
                        address,
                        crdt_op,
                        source,
                        ctx: cur_policy.id.clone(),
                        signature: None,
                    })
                }
            },
        }
    }
pub fn create_append_op ( & mut self , entry : Entry , source : PublicKey , ) -> Result < CrdtDataOperation < A , Entry > > { // Retrieve the LSeq corresponding to the current Policy, // or create and insert one if there is none. let address = * self . address ( ) ; // Let's retrieve current Policy match self . policy . last_entry ( ) { None => Err ( Error :: InvalidOperation ) , Some ( cur_policy ) => match self . data . get_mut ( & cur_policy . id ) { None => Err ( Error :: CrdtUnexpectedState ) , Some ( lseq ) => { // Append the entry to the LSeq corresponding to current Policy // TODO: lseq should not apply the op yet let crdt_op = lseq . append ( entry ) ; // We return the operation as it may need to be broadcasted to other replicas Ok ( CrdtDataOperation { address , crdt_op , source , ctx : cur_policy . id . clone ( ) , signature : None , } ) } } , } }
Create crdt op to append a new item to the SequenceCrdt
Create crdt op to append a new item to the SequenceCrdt
&mut self
entry
Entry
source
PublicKey
&mut self
entry
Entry
source
PublicKey