Hyperledger fabric Node js synchronising the block from channel - hyperledger-fabric

I have setup the hyper-ledger fabric network with chain-code its working fine.From the client end, i am using the fabric-node. Is there any method or way to sync the block one by one using fabric-node.

Related

How to setup multicloud architecture in hyperledger fabric?

I have a peer in google cloud platform. I have to join that peer to the channel in azure network.
What I tried:
Generated crypto-materials for new peer using azure network webclient and used that crypto-config materials in all the peers, orderer and webclient in azure and also in the new peer I have in google cloud. But after that new peer can join the channel of azure but could not install instantiate the chaincodes.
There are two recommended approaches to setting up Hyperledger Fabric Network on Azure. You can use the Hyperledger Fabric template available in the Azure Marketplace to launch your environment on Azure or you can take the hard way and manually commission VM Instances. Using the template is obviously a faster solution. It is also a better solution. If you were to manually set up your environment, you would have to consider 2 cases — using multiple VM instances (usually in a production environment) or a single VM (for a development environment).
In the second case, you would have to set up the communication rules between VM instances if you are using multiple ones. You would have to download and install the Fabric SDKs and configure the channels and peers and every other facet of a typical Hyperledger Fabric network. While that is easy to do for single, Dev mode VM instance, things get really complicated when you have to consider multiple running instances. Hence, it is better to use the Hyperledger Fabric Template to set up your Fabric environment on Azure.
In either approach, Fabric Network generates a channel configuration. This step generates a new channel configuration block that includes the new member belonging to the peer node in GCP. A configuration block is similar to the genesis block, defining the members and policies for a channel. In fact, you can consider a configuration block to be the genesis block plus the delta of configuration changes that have occurred since the channel was created.
Azure VM Fabric Network can shares the genesis block for the channel with Peer Node in GCP. Before the peer node in GCP joins the channel, it must be able to connect to the ordering service. It obtains the ordering service endpoint from the channel genesis block.
If you are facing issues in the GCP peer node, please confirm that the peer node is receiving blocks on the channel, you install chain code. You then run a query against the local ledger on the peer. After installing the chain code, the peer node in GCP can run queries against its own world state database.

Hyperledger fabric create the new block when we use storage

I am using hyper-ledger fabric with 2 organisation and peers with the chain-code installed in all the peers. I am using the storage to keep the state of blockchain on local drive.
If i am using the storage current blockchain state, when i stop all container of peers, orderer and run again, it adds the one extra block without doing the transaction, all the time when i stop and start all the container. How this block is getting created and what is the purpose of this extra block?

Implement the distributed-decentralised ledger for a hyperleder network

Did a small example using the hyperledger composer and then used the composer-rest-server to integrate it with GUI. So in the case of identity, only admin is there. There is also documentation to create and issue other identities to login into the business networks.
But still, the problem is it's only in a single peer, meaning my local machine. To my understanding, for the hyperledger to function as decentralized and distributed ledger system, additional peers have to be added to the channel and then states gets synced in those peers. Hence if one node is down, details can be obtained from other nodes.
I checked some links such as this and this. But all of these point to the things that :
Existing network should be stopped and teared down.
The IP address of the second machine should be manually added to the docker.yml file and then have to be restarted.
My doubts are :
But on doing this, won't the existing ledger stated be cleared? All the data are gone.
So before even creating a dApp using hyperledger, we have to include all the IP address of the machine in the yml and start the network?
How to actually implement the distributed-decentralised ledger system for a hyperleder network?
UPDATE :
I have checked the links mentioned by Paul O'Mahony. The links explains about the peer addition steps. Overall what happens there is :
downloaded the fabric sample as the fabric extension is only possible through the cryptogen version appropriate to the Fabric version.
Currently contains order, org1 & org2 (with 2 peers each).
To add a new peer along with its couchdb, changed the template count in the crypto-config.yaml and created crypto material for the new peer using the extend command.
Then using the docker composer file to spawn a new peer and its couchdb. This will create new containers.
Finally the created peers should be joined to the existing channel for the couch db to get sync. The adding to existing channel is via logging into the docker container and typing some cli commands and adding the peer to channel via channel join command.
Is this recommend way to add peers to the channel ? Suppose i am creating a network and wanted to add peers to the channel based on a condition. Like a user/users can add themselves to the network through a login via composer playground and act as a peer. So i have to follow the same steps to do it ? Is this the recommended way ?
Supporting link : https://chat.hyperledger.org/channel/fabric?msg=KgxFegcZyKEPdo4v2

Channels in hyperledger fabric

Are channels only created in hyperledger fabric only when the business network is deployed ? Or it can be created afterwards. If yes than how it is possible ?
Channels are a hyperledger fabric concept and not a hyperledger composer concept. A business network will be instantiated on a channel. So the channel must already have been created using the standard fabric mechanisms for creating channels.
It is able to create a new channel in an existing orderer, and then ask existing peers to join that channel.
On Fabric Node.js SDK, we can use Channel.createChannel() and Channel.joinChannel() to do it.
related references:
https://fabric-sdk-node.github.io/release-1.3/Client.html#createChannel
https://fabric-sdk-node.github.io/release-1.3/Channel.html#joinChannel
Hope this helps.

How to deploy a Chain Code with Hyperledger Fabric?

I’m interested into the development of Blockchain Apps using Fabric and Composer.
I’ve got just one question: while Ethereum is a public blockchain so you can deploy your Smart Contract on it and use them freely, can we do the same thing with Fabric? Let me explain: Ethereum has a running Blockchain on which we can work and access, but Fabric has not, right? Should I set up an entire new blockchain network before (setting up all the nodes, giving permissions etc.)?
Thank you
Hyperledger Fabric is different to the blockchain systems you mention in it is private and permissioned. Rather than an open permissionless system that allows unknown identities to participate in the network (requiring protocols like “proof of work” to validate transactions and secure the network), the members of a Hyperledger Fabric network enroll through a trusted Membership Service Provider (MSP). Member organisations would generally set up their own Fabric infrastructure, if they're participating in the blockchain network (context provided earlier). See more on FAQ here -> http://hyperledger-fabric.readthedocs.io/en/release-1.2/Fabric-FAQ.html and understand more on key Fabric Concepts here -> http://hyperledger-fabric.readthedocs.io/en/release-1.2/key_concepts.html . As for Hyperledger Composer, that is a development framework, with tools etc to accelerate development and abstract things to a business level (ie App development using structure/validated, model driven development as a given). See more here -> https://hyperledger.github.io/composer/latest/introduction/introduction (and also see the architectural and key concept links there).
So yes, you will have a running, private blockchain network (including all of the functionality discussed in the docs) with Hyperledger Fabric.
As in Ethereum we can able to create public blockchain and then the user can able to run smart contract on it, same thing we can do in Hyperledger fabric also.
Hyperledger Fabric has the same functionality as smart contracts called as “chaincode”.
A chaincode is a program that is written to read and update the ledger state. All the business logic handled by chaincode.
For example, if a transaction created then chaincode share and update the ledger throughout the network.
About a Fabric based running blockchain we can work on it and can access it but that's only possible when someone from existing network invites you.
It is quite difficult to say you should setup an entire new blockchain network until I know your use case. Based on your use case you can setup an entire new blockchain network using fabric which will be private.

Resources