How to track changes of an object in exonum

0 votes

I have one object in my blockchain and my application keeps updating it regularly. I want to keep track of the 
changes that happen to the object. Below is a part of my code.

encoding_struct! {
    struct AC {
        const SIZE = 16;
        field s: Vec<u32> [00 => 08]
        field o: Vec<u32> [08 => 16]
    }
}

i have transaction with empty init

message! {
    struct TxInitAC {
        const TYPE = SERVICE_ID;
        const ID = TX_INIT_AC;
        const SIZE = 0;
    }
}

and i have an execute method

fn execute(&self, view: &mut Fork) {
    let mut schema = CurrencySchema { view };                   
    let ac = AC::new(vec![], vec![]);        
    schema.access_control().push(ac);
}

Jul 23, 2018 in Blockchain by digger
• 26,740 points
632 views

1 answer to this question.

0 votes

You have to describe each component in a corresponding encoding_struct! to describe a compound object.

you can do it like this:
encoding_struct! {
    struct Pair {
        const SIZE = 8;
        field s: u32 [00 => 04]
        field o: u32 [04 => 08]
    }
}

encoding_struct! {
    struct AC {
        const SIZE = 8;
        field inner : Vec<Pair> [00 => 08]
    }
}

then initialize the blockchain db like this:

impl Service for MService {
//...
    fn initialize(&self, fork: &mut Fork) -> Value {
        let mut schema = MatrixSchema { view: fork };
        let matrix = AC::new(vec![]);
        // assume method ac() is implemented for the schema
        schema.ac().set(ac);        
        Value::Null
    }
}

answered Jul 23, 2018 by slayer
• 29,370 points

Related Questions In Blockchain

0 votes
1 answer

How to get property of non object in Coinbase API

First, your sendMoney() call is stored into ...READ MORE

answered Aug 31, 2018 in Blockchain by digger
• 26,740 points
754 views
0 votes
1 answer

How to create an instance of contract in Truffle console?

Hi, @There, I would suggest you go through ...READ MORE

answered Jun 17, 2020 in Blockchain by Gitika
• 65,770 points
2,020 views
0 votes
1 answer

How to check the data integrity logic in proof of work mining?

The proof of work is actually works ...READ MORE

answered May 8, 2018 in Blockchain by Johnathon
• 9,090 points
802 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 26,740 points
1,003 views
+1 vote
1 answer
0 votes
1 answer

How to get amount of bitcoins in php?

I’ve tried this code and it works: <?php function ...READ MORE

answered Aug 24, 2018 in Blockchain by slayer
• 29,370 points
1,029 views
0 votes
1 answer

How to Track Payment API in Coinbase

Use the callback_url option as described in the API. ...READ MORE

answered Sep 5, 2018 in Blockchain by slayer
• 29,370 points
812 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP