0

I am trying to figure out the best practice on a case where I have a Hyperledger Fabric blockchain network and using CouchDB as the World State.

Let's say we have one channel and I want to have some smart contracts that are divided into categories.

For example some smart contracts are developed to manage the identity of an account (registration, update, get and delete of account), some other smart contracts manage the assets of an account etc.

If for example we have 50000 records for each category, we have in total 100000 records or more if we assume that are more than 2 different chaincodes.

What could be the best practice if those smart contracts want to communicate with each other?

  1. Have a single CouchDB and a single chaincode but with many data inside the db?
  2. Have two or more chaincodes that have their own CouchDB and communicate with cross-chaincode functions?

Which could be more complex? Calling one chaincode through the other and wait for the second one to retrieve data from its own CouchDB? Or having a huge CouchDB with everything inside?

I have done a research on this topic, but could not find a proper answer.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Rafail K.
  • 365
  • 3
  • 14

1 Answers1

0

Chaincodes provide a namespace for storing data on the ledger. The various chaincode data on a peer will be persisted in the state database in the same CouchDB 'instance' but in a different CouchDB 'database' per chaincode (think of 'tables' in other database products).

Therefore, I think you'll want to use different chaincodes for each type of data. It is possible for one chaincode to invoke another chaincode to update data in both.

Dave Enyeart
  • 2,523
  • 14
  • 23