Can we see states inside the vault through h2 database web application?
If yes, how? All I see is transaction_id and other details but not the data inside the state.
For the state to be stored in a readable format in the H2 database, it must implement the QueryableState interface.
See the docs at https://docs.corda.net/api-persistence.html and the example at https://github.com/corda/cordapp-example/blob/release-V3/java-source/src/main/java/com/example/state/IOUState.java.
Related
What's the easiest way to delete an entire partition in cosmos Db assuming that I'm using spirngboot with SQL API?
I have a class marked with the #Repository that extends the CosmosRepository and I want to delete every item from a particular partition.
I know that with CosmosClientBuilder I could do something like:
cosmosDbClient.getDatabase(dataBaseName)
.getContainer(container)
.deleteAllItemsByPartitionKey(
PartitionKey("partitionKey0001"),
CosmosItemRequestOptions())
Is it possible to access the container from the repository?
I don't want to use stored procedures for something that should be easy to do.
Thank you
Microsoft is releasing this feature since year now.
Its yet in preview state and you will need to opt to this before using
I'm developing a CorDapp but haven't implemented the schema as it is not a good practice.
But the code I have to get a particular record without using schema is first getting me all the states and then fetching a particular record, it is very time consuming as it is iterating through over each state object.
DataFeed, Vault.Update> dataFeed = proxy.vaultTrack(IOUState.class);
//this gives a snapshot of IOUState as of now. so if there are 11 IOUState as of now, this will return 11 IOUState objects
Vault.Page<IOUState> snapshot = dataFeed.getSnapshot();
for (StateAndRef<IOUState> state : snapshot.getStates()) {
if (state.getState().getData().getAssetId().equals(value)) {
cs = state.getState().getData();
}
}
Could you please suggest better approach to fetch a particular record from corda vault without using schema and iterating through over each state object.
Not sure how you come to the conclusion that using a schema is not a good practice. Do you have any data points to prove this? Or the source of this information would be helpful for us to understand the problem with implementing a schema.
Is's not possible to fetch a state based on one of its attributes without a schema. However, if you are specifically interested in fetching a state based on an ID (also considering your state is Linear/ Non-Fungible in nature), you could use a linear state. A linear state can be directly fetched from the vault using a LinearStateQueryCriteria.
val criteria = LinearStateQueryCriteria(linearId = listOf(linearId));
val results = vaultService.queryBy<LinearState>(criteria);
Who said implementing a schema is not a good practice?! Please post a link to where you read that.
You can't get a particular record from the vault (i.e. using a query on a certain attribute) without a custom schema.
am trying to get the value from db without using serviceHub and vault.but i couldn't. what my logic is, when i pass the country name, it should return the id's(PK)of that country which is in one table.using those id's, it should return the values related to those id's from other table.it could be possible in flow class.but am trying to do in api class where servicehub couldn't import. Please help me out.
Only the node has access to the ServiceHub. The API runs outside of the node in a separate process, so it is limited to interacting with the node via the operations offered by CordaRPCOps.
Either you need to store the data you want to access in a separate database outside of the node, or you need to find some way to programatically log into the node's database from the API, using JDBC as described here: https://docs.corda.net/node-database.html.
I created custom table in corda using QueryableState. e.g. IOUStates table.
I can able to see the custom information getting stored in this kind of table.
but i observed that if party A and Party B is doing the transaction then this
custom information gets stored at both the places , e.g. IOUStates
table getting created at nodeA ledger as well as nodeB's ledger.
and custom information is stored in partyA's and PartyB's ledger.
My Question is :-
If some Transaction is getting processed from PartyA's node , then
I want to store part of the transaction's data i.e. custom data ONLY at partyA's Ledger.* level . i.e. off-Ledger of partA only.
It should not be shared with partyB.
In simple case , how to store Only node specific off ledger custom data ?
Awaiting for some reply...
Thanks.
There's a number of ways to achieve this:
Don't use Corda at all! If the data is truly off-ledger then why are you using Corda? Instead, store it in a separate database. Of course you can "JOIN" it with on-ledger data if required, as the on-ledger data is stored in a SQL database.
Similar to point one except you can use the jdbcSession() functionality of the ServiceHub to create a custom table in the node's database. This table can easily be accessed from within your flows.
Create a ContractState object that only has one participant: the node that wants to store the data. I call this a "unilateral" state, i.e. a state that only one party ever stores.
Most importantly, if you don't want to share some data with a counter-party then it should never be disclosed inside a corda state object or attachment that another party might see. Instead:
inside your flows, you can use the data encapsulated within the shared state object (e.g. the IOU) to derive the private data
alternatively if the data is supplied when the flow begins then store the private data locally using one of the methods above
For example, I need to store info for current user of the app and I would like that info to stored in Realm (similarly to usersdefault, but with some big files). Is it the same as just create a current user singleton in Realm? What is the best practice to achieve that?
You could always just create a single user object, or have an isActive property on your user class.
Doing [User allObjectsInRealm:realm].firstObject should then let you fetch the user (presuming you go the single user object route).