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,740 points
1,394 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,370 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
• 69,220 points
857 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
• 69,220 points
1,731 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
1,165 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,740 points
795 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
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,740 points
1,003 views
+1 vote
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP