ChainLink: where does the data from when I call GetRoundData? - blockchain

I am currently learning how to start developing on ChainLink, and I saw that there is a GetRoundData() method that is used to return data from a specific timestamp.
When I dig into the code and I found that there the method came from the interface AggregatorV3Interface. Also, I didn't find the implementation of the function inside any of .sol files, but I find it in a .go file.
My question is, how is the aggregator store data on the blockchain? as I see the data come from nowhere when I call getRoundData. If data comes from the module written by Go lang, does that means the data source is off-chain? Thank you.
Code snippet captures:
aggregator_v2v3_interface.go
AggregatorV3Interface.sol

A contract implementing this interface is deployed on an address specified in the _AggregatorV2V3Interface Golang variable.
So your offchain script is connected to a node of some EVM network (Ethereum, BSC, Polygon, ...) and queries the node to perform a read-only, gas-free, call on that specific contract address. The actual data is stored onchain.

Related

What is design pattern to store JSON objects in C++?

A co-worker and I have been discussed the best way to store data in memory within our C++ server. Basically, we need to store all requisitions made by clients. Those requisitions come as JSONs objects, so each requisition may have different number of parameters. Later, clients can ask the server for a list of those requisitions.
The total number of requisitions is small (order of 10^3). Clients ask for the list of requisitions using pagination.
So my question is what is the standard way of doing that?
1) Create a class that stores every JSON and then, when requested, send the list of those JSONs.
2) Deserialize the JSON, store it in a class then serialize the data again when requested.
If 2, what is the best way of doing that in modern C++?
3) Another option?
Thank you.
If the client asks you to support JSON, the are only two steps you need to do:
Add some JSON (e.g this) library with a suitable license to project.
Use it.
If the implementation of JSON is not the main goal of the project, this should work.
Note: you can also get a lot of design hints inspecting the aforementioned repo.

Several Cordapps can access to the same ledger?

I'm new to Corda and I'm still trying to understand it.
So, I already know that we can run multiple Cordapps in the same node. But the thing is that if those Cordapps can have access and update the same ledger?
Thank you very much :)
Yes they can, you can have the following structure inside your project:
1. Contracts module that defines CustomState and Custom Contract.
2. Workflows1 module that depends on Contracts module.
3. Workflows2 module that depends on Contracts module and Workflows1 module.
4. Workflows1 module can have a flow that creates and modifies CustomState.
5. Workflows2 module can have a flow that creates and modifies CustomState.
6. Workflows2 module can call a flow from Workflows1 module.
In the above structure you have 3 CorDapps (Contracts, Workflows1, and Workflows2); they all create and modify your state.
As for if they all access the same ledger, in Corda data is shared on a need to know basis; in other words when you define your state you define the Participants which are the parties that will be signing the transaction and storing the resulting state.
I recommend starting here: https://docs.corda.net/key-concepts.html
Also join the Corda Slack channel (Create a Stackoverflow post and share the link there): slack.corda.net

Protect external data file from unauthorized modifications

I am still learning QT, and this thing come to my mind: If I design a program and I want some data to be saved and protected, all the ways I know about saving data from QT Creator applications are writing into files which can be easily altered and deleted. Is there any way that I can safely store some application data and no one else can access it without breaking the application?
This might be a stupid question, but I am actually looking forward to some idea.
Thanks a lot.
It is not possible to make it impossible to rewrite data for someone who has root/administrator access. You can however make the application refuse unauthorized changes and exit.
Assuming you want an external data file that can only be changed from within the application you can do something lie this:
Each time when the data file is changed by the application, calculate a hash value of the data, encrypt that and store it along the data file. Each time when reading the data, first hash the data, then read in the stored hash, decrypt it and compare it with the data hash. If it is not the same, exit the application.
This way if someone makes any changes from the outside, he will not be able to provide the accurate encrypted hash value for the data file, so the hash check will fail. Only someone who has the secret key will be able to make changes that the application will accept.

Internal Table implementation in Hyperledger Fabric Chaincode

I am working with fabric chaincodes and have implemented the table concepts being provided to store data since blockchain does not allow modification or deletion, i am eager to know the internal implementation of the table format. Is there any documentation for that if yes please suggest or if anyone knows and can explain.
Thanks in advance
Tables are implemented using Protocol Buffers.
You can have a look at file table.pb.go. This file is auto-generated file by using proto message definitions in table.proto .
On top of this, chaincode API provides functions like CreateTable, GetTable, DeleteTable, GetRow, GetRows, InsertRow which you might be using in your chaincode.
Functions like CreateTable, InsertRow, DeleteTable which are supposed to do data modification internally use PutState API to write the bytevalues to ledger. PutState marshals a struct defined in file table.pb.go into bytes and stores into ledger.
Similarly functions like GetRow, GetRows, GetTable which are supposed to query data, internally use GetState API to read the bytevalues from ledger. GetState API finds the value from ledger in bytes and then unmarshals the byte value into structs.
Effectively you get to interact with Go structs without caring how internally the table is stored.

Best practice for creating an unalterable report file in c++

I am currently developping a windows application who test railroad equipments to find any defaults.
Utility A => OK
Utility B => NOK
...
This application will check the given equipment and generate a report.
This report needs to be written once, and no further modifications are allowed since this file can be used as working proof for the equipment.
My first idea was ta use pdf files (haru lib looks great), but pdf can also be modified.
I told myself that I could obsfuscate the report, and implement a homemade reader inside my application, but whatever way I store it, the file would always be possibly accessed and modified right?
So I'm running out of ideas.
Sorry if my approach and my problem appear naive but it's an intership.
Thanks for any help.
Edit: I could also add checksums for files after I generated them, and keep a "checksums record file", and implement a checksums comparison tool for verification? just thought about this.
I believe the answer to your question is to use any format whatosever, and use a digital signature anybody can verify, e.g., create a gnupg, get that key signed by the people who require to check your documents, upload it to one of the key servers, and use it to sign the documents. You can publish the documents, and have a link to your public key available for verification; for critical cases someone verifying must be trust your signature (i.e., trust somebody who signed your key).
People's lives depend on the state of train inspections. Therefore, I find it hard to believe that someone expects you to solve this problem only using free-as-in-beer components.
Adobe supports a strong digital signature model. If you buy into their technology base, you can create PDF's that are digitally signed, and are therefore tamper-evident, as the consumer can check for the signature.
You can, as someone else pointed out, use GNUpg, or for that matter OpenSSL, to implement your own signature scheme, but railroad regulators are somewhat less likely to figure out how to work with it.
I would store reports in an encrypted/protected datastore.
When a user accesses a report (requests a copy, the original is of course always in the database and cannot be modified), it includes the text "Report #XXXXX". If you want to validate the report, retrive a new copy from the system using the Report ID.