|
| 1 | +# Marbles FAQ |
| 2 | + |
| 3 | +1. [Does deleting a marble re-write history? How is this not breaking the blockchain ledger?](./#deleteHistory) |
| 4 | + |
| 5 | +1. [What is with the required input arguments for the marbles chaincode?](./#inputArgs) |
| 6 | + |
| 7 | +1. [How can I create a HA(high-availability) setup?](./#ha) |
| 8 | + |
| 9 | +1. [I want to run a local Hyperledger Fabric network... how?](./#localFabric) |
| 10 | + |
| 11 | +1. [What is this "fcw" aka "fc wrangler" thing?](./#fcw) |
| 12 | + |
| 13 | +1. [I'm stuck, can you help me?](./#stuck) |
| 14 | + |
| 15 | +*** |
| 16 | + |
| 17 | +<a name="deleteHistory"></a> |
| 18 | + |
| 19 | +### Q. Does deleting a marble re-write history? How is this not breaking the blockchain ledger? |
| 20 | +It does not re-write history. |
| 21 | +"History" would refer to the ledger, which can not be re-written under normal circumstances. |
| 22 | +The "delete" transaction is a regular transaction that gets recorded into a block in the ledger. |
| 23 | +Therefore the marble's creation and activity remains in the ledger unchanged, forever, even after a "delete". |
| 24 | +However the _state_ of the asset did change. |
| 25 | +The ledger and the world state are different things. |
| 26 | +The ledger contains the historic actions to the chaincode and channel (transactions). |
| 27 | +While the world state is all the asset data at a specific _moment_ of time. |
| 28 | +Think of it as the combined result of playing back all transactions. |
| 29 | +When we created a marble, we appended the create transaction to the ledger, and added the marble to the world state. |
| 30 | +Like-wise when we delete, the delete transaction is appended to the ledger, and the world state is altered to remove the marble. |
| 31 | + |
| 32 | + |
| 33 | +<a name="inputArgs"></a> |
| 34 | + |
| 35 | +### Q. What is with the required input arguments for the marbles chaincode? |
| 36 | +The marbles chaincode requires a single integer as an input. |
| 37 | +This is purely for demonstration reasons to show how its possible to pass inputs to a chaincode during its instantiate. |
| 38 | +The actual number you provide to marbles is meaningless, go nuts. |
| 39 | + |
| 40 | + |
| 41 | +<a name="ha"></a> |
| 42 | + |
| 43 | +### Q. How can I create a HA(high-availability) setup |
| 44 | +The latest and greatest marbles already does this! Checkout the `fc wrangler` files: [high_availability.js](../utils/fc_wrangler/high_availability.js) and [index.js](../utils/fc_wrangler/index.js). The code snippet below shows that when an invoke fails, we call `ha.switch_peer()` to send the same call to the next peer. Remember that the SDK is configured to send requests to specific peers, so all we have to do is change this peer. |
| 45 | + |
| 46 | +__./utils/fc_wrangler/index.js__ |
| 47 | +```js |
| 48 | + fcw.invoke_chaincode = function (obj, options, cb_done) { |
| 49 | + invoke_cc.invoke_chaincode(obj, options, function (err, resp) { |
| 50 | + if (err != null) { //looks like an error with the request |
| 51 | + if (ha.switch_peer(obj, options) == null) { //try another peer |
| 52 | + logger.info('Retrying invoke on different peer'); |
| 53 | + fcw.invoke_chaincode(obj, options, cb_done); |
| 54 | + } else { |
| 55 | + if (cb_done) cb_done(err, resp); //out of peers, give up |
| 56 | + } |
| 57 | + } else { //all good, pass resp back to callback |
| 58 | + ha.success_peer_position = ha.using_peer_position; //remember the last good one |
| 59 | + if (cb_done) cb_done(err, resp); |
| 60 | + } |
| 61 | + }); |
| 62 | + }; |
| 63 | +``` |
| 64 | + |
| 65 | + |
| 66 | +<a name="localFabric"></a> |
| 67 | + |
| 68 | +### Q. I want to run a local Hyperledger Fabric network... how? |
| 69 | +Great, I recommend that everyone starts with a local network. [Lets get going](../docs/use_local_hyperledger.md) . |
| 70 | + |
| 71 | + |
| 72 | +<a name="fcw"></a> |
| 73 | + |
| 74 | +### Q. What is this "fcw" aka "fc wrangler" thing? |
| 75 | +It's called the Fabric Client Wrangler. |
| 76 | +It is simply a wrapper around the [fabric-client](https://www.npmjs.com/package/fabric-client) SDK module. |
| 77 | +ie it gives me a slightly friendlier interface to the SDK. |
| 78 | +It is generic and reuseable for your own adaptations. |
| 79 | +It is **not** a required component of a node.js -> Fabric application, but I feel it helps. |
| 80 | + |
| 81 | + |
| 82 | +<a name="stuck"></a> |
| 83 | + |
| 84 | +### Q. I'm stuck, can you help me? |
| 85 | +Yes. Open an issue on our [GitHub Issues](https://github.com/IBM-Blockchain/marbles/issues). Please include as much info as you can, such as the logs you are seeing, what you were expecting to happen, etc. |
0 commit comments