Blockchain Without Copy,Clone Block-Refcell

I have got a mystery that I decide to reuse produced lasthash for the next block without any Copy or Clone because of high safe code(because I think if we used Copy and Clone afterward the Blockchain will be Hk by DoubleXpends or OverXpend). I used Rc<RefCell> but I have got this error:
(followed lines:
I can preceded lines solve by adding new Rc<RefCell for two types but I do not want do it.
I'm stuck in a loop repeating this puzzle for all non-primitives types!
What is solution instead of using Clone?

cannot move out of dereference of `RefMut<'_, library_blockchain::Block>`
move occurs because value has type `Vec<OptionTransaction>`, which does not implement the `Copy` trait
            //-------------Making Block
            let mut base_maked_block: Rc<RefCell<Block>> = Rc::new(RefCell::new(
                Block::new(i as u32, now(), last_hash.to_vec(), maked_transaction, difficulty)
            let mut refered1_base_maked_block=base_maked_block.borrow_mut();

            let refered1_block=Block::new(
            let b=*refered1_base_maked_block;
            blockchain.update_with_block(b).expect("\n\nFailed to add genesis block");    
            let refered2_base_maked_block=base_maked_block.borrow();
            last_hash =refered2_base_maked_block.prev_block_hash.to_vec().into_boxed_slice();
            println!("**last hash new:**\n{:?}\n",&last_hash);


pub struct Block {
    pub index: u32,
    pub timestamp: u128,
    pub hash: Hash,
    pub prev_block_hash: Hash,
    pub nonce: u64,
    pub option_transactions: Vec<OptionTransaction>,
    pub difficulty: u128, 

Reposource code branch armanriazi

I feel like the question you have could be formulated more clearly, and with a more descriptive title; feel free to edit your post accordingly, or post additional reply with more information.

One first step of improvement would be to post a complete error message (including things such as the information where in the code the error occurred) as e.g. returned from running cargo check in the terminal.

1 Like

How is refered1_block used after creation? Can it be the same block as the refered1_base_maked_block (i.e. the clone of the same Rc)? If it can't, then the cloning of the vector is semantically unavoidable.

1 Like