In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "java open source block chain initialization how to build jdchain services" related knowledge, editor through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope that this "java open source block chain initialization how to build jdchain services" article can help you solve the problem.
Initialize the Genesis Block
The first step in building a blockchain service is to initialize the creation block and create an account book. There are two ways to generate dchain initialization creation blocks, one is to initialize it on the page through the officially provided blockchain deployment tool, and the other is to create it through initialization scripts. At present, the function of the deployment tool to initialize the account book is limited, and only the node initialization of the btfsmart consensus algorithm is supported. If you want to support the mq consensus, you can only use the script that initializes the account book to create.
First, generate public and private keys
Use deployment tools to generate public and private keys. Although deployment tools do not support account initialization agreed by mq, you can still use deployment tools to create and maintain public and private keys, which is much more convenient than using scripts.
Step 2, prepare the configuration
Jdchain initialization account book requires three configurations, account book configuration ledger.init, local node configuration: local.conf, consensus service configuration: bftsmart.config or mq.config, where local.conf is the unique configuration of each consensus node, and account book and consensus service configuration need to be synchronized to each node.
For more configuration details, please see https://github.com/blockchain-jd-com/jdchain
Step 3, execute the initialization script
After the configuration is ready, first find the ledger-init.sh script, and then modify the-I and-l parameters to specify the configuration address configured in the second step. And then execute it in turn. If the configuration is correct, you will be prompted that the initialization service is ready and press any key to start initializing the account book. Enter at this time, and after successful initialization, the ledger-binding.conf file will be generated in the config/init directory. This configuration file is required to start the node service.
The process of creating the Genesis Block
Assuming that there are four consensus nodes node0, node1, node2, node3, participating in consensus creation block, then the behavior of node0 when executing the initialization script is as follows, and the behavior of other nodes is consistent:
1. Load the configuration according to-I and-l parameters
2. Create an initialization configuration instance
3. Verify whether the public and private keys of the current node match (use the private key to generate the signature and verify the signature with the public key)
4. Initialize the account book, instantiate the local transaction context, and generate the Genesis transaction.
5. Sign the initial transaction and generate the account book initialization license of the current node (use the hash of the current transaction context object and the private key of the current node to generate the signature)
6. Make a consensus among all participants in the first stage, request permission for account creation of all other participants, and request the / legerinit/permission/ interface of node1, node2, and node3 in turn. The other side's interface will verify the signature, in the same way as process 3.
7. Use the current node transaction context as a hash to verify the access license signature returned by other nodes. If this process fails, it will be retried 16 times.
8. Link the database to generate the initial ledger of the current node
9. Make a second-stage consensus among all participants, start requesting all members' account creation decisions, and submit the account books if they all return to the resolution creation, otherwise they will be rolled back. This process will also be retried 16 times.
The consensus interface for the above two phases of Genesis Block is defined as follows:
Public interface LedgerInitConsensusService {/ * request permission to initialize the account book; * * @ param requesterId * the participant who initiated the request id; * @ param signature * the signature made by the requester's private key to "id" + "account seed" A valid return can be obtained only if the signature is legal and the participant is a participant in the initialization configuration, otherwise it will be rejected * / @ HttpAction (path = "/ legerinit/permission/ {requesterId}", method = HttpMethod.POST, contentType = LedgerInitMessageConverter.CONTENT_TYPE_VALUE, responseConverter = PermissionResponseConverter.class) LedgerInitProposal requestPermission (@ PathParam (name = "requesterId") int requesterId, @ RequestBody (converter = SignatureDigestRequestBodyConverter.class) SignatureDigest signature); / * * synchronous account initialization resolution * * @ param initDecision * caller's book initialization resolution; * @ return target participant's account initialization resolution; if the target participant is not ready, return null * / @ HttpAction (path = "/ legerinit/decision", method = HttpMethod.POST, contentType = LedgerInitMessageConverter.CONTENT_TYPE_VALUE, responseConverter = DecisionResponseConverter.class) LedgerInitDecision synchronizeDecision (@ RequestBody (converter = DecisionRequestBodyConverter.class) LedgerInitDecision initDecision);}
Problem encountered: when requesting permission for the account creation of other participants, the following exception is output:
Invalid permission from participant!-- [Id=LdeNn8bWuc2DaqAbx3XCQPUf7bdb94PTKFT2E] [name=node1.com] Invalid permission from participant!-- [Id=LdeNezcG3rhs31u8UBSwvfMf2BKr1ZkaLKJAG] [name=node2.com] Invalid permission from participant!-- [Id=LdeNqxGmBdmEZK6hVeLcnXppW2qnLLKMMiQhN] [name=node3.com]
Seeing this output means that you can rule out the problem of public and private keys. Because this is the last step of the license, the transaction hash license signature verification failed to output. The transaction hash is created according to the current account context, and the current account context is loaded according to the initialization account configuration, so the final problem lies in the configuration of the initialization account. I misunderstood the following configuration:
# the current account transaction delivery queue topic (different books require different topics) system.msg.queue.topic.tx=node3-topic 's content on "how to build jdchain service for initializing java open source block chain" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.