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,550 points
45 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,050 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,550 points
32 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 7, 2018 in Blockchain by Johnathon
• 9,080 points
35 views
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,020 points
369 views
0 votes
1 answer
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,550 points
68 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,050 points
51 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,050 points
38 views