0

I'm new to hyperledger and am working with the hyperledger fabcar sample in fabric-samples. When initLedger is executed in \fabric-samples\chaincode\fabcar\javascript\lib\fabcar I'm wondering where it saves the car data and subsequently the block data, to be clear, the exact directory location of where this data lives. Thanks.

I've tried looking in almost every location in fabric-samples haven't been able to find anything.

....

    for (let i = 0; i < cars.length; i++) {
        cars[i].docType = 'car';
        await ctx.stub.putState('CAR' + i, Buffer.from(JSON.stringify(cars[i])));
        console.info('Added <--> ', cars[i]);
    }
    console.info('============= END : Initialize Ledger ===========');
}

Upon executing ctx.stub.putState at the end of the function where is the data going?

Akaash
  • 31
  • 1
  • 7

1 Answers1

0

In Hyperledger Fabric data are stored in two different places:

  1. Worldstate - which contains the last version of an asset and it can be updated ( LevelDB or CouchDB )
  2. Blockchain - which contains the whole history of the asset and it cannot be modified.

Here you can find how ledger is implemented:

HL Fabric - Ledger

By invoking the following API:

await ctx.stub.putState('CAR' + i, Buffer.from(JSON.stringify(cars[i])));

you are writing data in both places.

Leonardo Carraro
  • 1,532
  • 1
  • 11
  • 24
  • Thanks for that. So I get where the world state is. My question is when it says, "The blockchain is always implemented as a file" (from the link you posted above), where is this file? – Akaash Jun 18 '19 at 13:14
  • See point 2 of the following question: https://stackoverflow.com/questions/55420313/hyperledger-fabric-ledger-encryption – Leonardo Carraro Jun 18 '19 at 13:19
  • Still not sure where /var/hyperledger/production/ledgersData lives. I can run: `docker exec peer0.org1.example.com peer channel getinfo -c mychannel` inside fabric-samples\basic-network and this gets me block hash info but still not sure where it's getting it from or what's in the block. – Akaash Jun 18 '19 at 20:05
  • Run `docker exec -ti peer0.org1.example.com bash` to enter in the container and then move to: `/var/hyperledger/production/ledgersData` – Leonardo Carraro Jun 19 '19 at 09:04