How to retrieve complete world state of hyperledger?

0 votes
How can i retrieve all the keys of the world state in hyperledger? Is there a shim function for it?
Jul 5, 2018 in Blockchain by digger
• 26,550 points
277 views

1 answer to this question.

0 votes

you can achieve this by iteration process over the keys by using stub.GetStateByRange() function.

I have included an example below. Go through it and try to implement on of ur own.

 keysIter, err := stub.GetStateByRange(startKey, endKey)
    if err != nil {
        return shim.Error(fmt.Sprintf("keys operation failed. Error accessing state: %s", err))
    }
    defer keysIter.Close()

    var keys []string
    for keysIter.HasNext() {
        key, _, iterErr := keysIter.Next()
        if iterErr != nil {
            return shim.Error(fmt.Sprintf("keys operation failed. Error accessing state: %s", err))
        }
        keys = append(keys, key)
    }

answered Jul 5, 2018 by slayer
• 29,050 points

Related Questions In Blockchain

0 votes
1 answer

Hyperledger: How to retrieve properties of relationship through query?

I dont think its possible using query. ...READ MORE

answered Nov 8, 2018 in Blockchain by Omkar
• 67,480 points
87 views
0 votes
1 answer

Hyperledger Composer: How to retrieve array of assets?

This is what worked for me: asset Ask ...READ MORE

answered Nov 14, 2018 in Blockchain by Omkar
• 67,480 points
384 views
0 votes
1 answer

How to connect two instances of Hyperledger Fabric?

Before getting on with your question, let ...READ MORE

answered Jun 11, 2018 in Blockchain by Christine
• 15,790 points
70 views
0 votes
1 answer

How to control visibility of assets in Hyperledger Fabric?

you can use proof of Authority consensus ...READ MORE

answered Jul 10, 2018 in Blockchain by digger
• 26,550 points
107 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