A chain code management method, device and terminal device of alliance chain
By using Docker and K8s container management modules in the alliance chain to intercept the Docker interface and call the K8s interface to manage the chain code container, the problem of low chain code container management reliability is solved, and simplified operations and improved management efficiency is achieved.
Patent Information
- Application Number
- CN202111246219.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-26
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-10-26
AI Technical Summary
The reliability of the corresponding container management of chain codes in the alliance chain is low, resulting in complex and cumbersome deployment and management, and prone to errors.
By introducing Docker container management module and K8s container management module in the chain code management system, we intercept the call of the Docker interface and call the K8s interface to perform the creation, configuration and deletion of the chain code container, avoiding changes to the source code of the chain code Docker control. Simplify the operation process.
It improves the reliability and simplicity of chain code container management, reduces the possibility of operation errors, and simplifies the management process of chain code corresponding containers.
Smart Images

Figure CN114020403B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of alliance chain, and in particular, relates to a chain code management method, apparatus and terminal device of an alliance chain. Background Art
[0002] During the deployment process of the alliance chain, it is sometimes necessary to deploy multiple identical or similar chaincodes (Chaincode, also known as smart contracts). Each time, it takes a lot of time to perform repetitive work, so container technology came into being. Container is a lightweight, portable, self-contained virtualization technology that allows related chaincodes to run in the same way almost anywhere.
[0003] Docker is an open source application container engine. Based on Docker container technology, it can be run in isolation on the host machine as a virtualized container in Docker mode. Docker's image is a special file system. In addition to providing the programs, libraries, resources, configuration and other files required for the container runtime, it also contains some configuration parameters prepared for runtime (such as anonymous volumes, environment variables, users, etc.).
[0004] Kubernetes, also known as K8s, can provide orchestration and management functions to easily complete large-scale container deployment. With the orchestration function of K8s, users can build application services across multiple containers, implement cross-cluster scheduling, expand containers, and manage the health of these containers in the long term, and integrate the network. Therefore, K8s can be used to implement the control of chaincode containers, which can be understood as an integrated call to the K8s interface (K8sAPI). The purpose of management through K8s can be achieved by modifying the source code of the chaincode control part in the peer node of the chaincode and adaptively replacing the original Docker port with the K8s interface. However, the source code of the alliance chain needs to be modified. If the source code of the chaincode control part in the peer node is not well understood, it is easy to make mistakes, and the operation is also complicated and cumbersome, which makes the reliability of chaincode corresponding container management low. Summary of the invention
[0005] The embodiments of the present application provide a chain code management method, apparatus and terminal device for a consortium chain, aiming to solve the problem of low reliability of existing chain code corresponding container management.
[0006] In a first aspect, an embodiment of the present application provides a chaincode management method for a consortium chain, which is applied to a chaincode management system, wherein the chaincode management system includes a Docker container management module created based on Docker container technology, and the chaincode management system includes a K8s container management module based on K8s container technology. The method includes:
[0007] When receiving a request instruction from a peer node to perform a corresponding operation on a chain code, parsing the request instruction;
[0008] When it is parsed that the request instruction is not a request instruction for chain code image construction, intercept the call of the Docker interface corresponding to the Docker container management module, and call the K8s interface corresponding to the K8s container management module;
[0009] The chaincode container operation corresponding to the request instruction is executed through the K8s interface, and the chaincode container operation includes the creation of a chaincode container, the configuration of a chaincode container, or the deletion of a chaincode container.
[0010] In one embodiment, after parsing the request instruction, the method further includes: when parsing the request instruction to be a request instruction for chain code image construction, building an image based on the Docker container management module;
[0011] The built image is pushed to the preset image warehouse.
[0012] In one embodiment, when it is parsed that the request instruction is not a request instruction for chain code image construction, intercepting the call of the Docker interface corresponding to the Docker container management module, and calling the K8s interface corresponding to the K8s container management module, including:
[0013] When parsing the request instruction as a request instruction for chaincode container creation, intercepting the call of the Docker creation interface corresponding to the Docker container management module, and calling the K8s creation interface;
[0014] Correspondingly, executing the chain code container operation corresponding to the request instruction through the K8s interface includes:
[0015] The chaincode container creation operation is performed through the K8s creation interface.
[0016] When parsing that the request instruction is not a request instruction for chain code image construction, intercepting the call of the Docker interface corresponding to the Docker container management module, and calling the K8s interface corresponding to the K8s container management module, including:
[0017] When parsing the request instruction as a request instruction for chaincode container configuration, intercept the call of the Docker configuration interface corresponding to the Docker container management module, and call the configuration mapping creation interface of k8s;
[0018] Correspondingly, executing the chain code container operation corresponding to the request instruction through the K8s interface includes:
[0019] The chaincode container configuration operation is performed through the k8s configuration mapping creation interface.
[0020] In one embodiment, when it is parsed that the request instruction is not a request instruction for chain code image construction, intercepting the call of the Docker interface corresponding to the Docker container management module, and calling the K8s interface corresponding to the K8s container management module, including:
[0021] When parsing the request instruction as a request instruction for chaincode container deletion, intercepting the call of the Docker deletion interface corresponding to the Docker container management module, and calling the K8s deletion interface;
[0022] Correspondingly, executing the chain code container operation corresponding to the request instruction through the K8s interface includes:
[0023] The chaincode container deletion operation is performed through the K8s deletion interface.
[0024] In one embodiment, performing a chaincode container creation operation through the K8s creation interface includes:
[0025] Obtain a target image corresponding to the container creation from a preset image repository;
[0026] According to the target image, a chaincode container creation operation is performed through the K8s creation interface.
[0027] In one embodiment, before executing the chain code container creation operation through the K8s creation interface according to the target image, it also includes:
[0028] If the target image corresponding to the container creation is not obtained from the preset image repository, the target image is constructed based on the Docker container management module.
[0029] In one embodiment, the chain code management method further includes:
[0030] Obtain the certificate file corresponding to the chain code;
[0031] Upload the certificate file to the created chaincode container.
[0032] In a second aspect, an embodiment of the present application provides a chain code management device of a consortium chain, which is applied to a chain code management system, wherein the chain code management system includes a Docker container management module created based on Docker container technology, and the chain code management system includes a K8s container management module based on K8s container technology, and the device includes:
[0033] A parsing module, used to parse the request instruction when receiving the request instruction of the peer node to perform corresponding operations on the chain code;
[0034] A calling module, used for intercepting the call of the Docker interface corresponding to the Docker container management module and calling the K8s interface corresponding to the K8s container management module when parsing that the request instruction is not a request instruction for chain code image construction;
[0035] An operation module is used to execute a chain code container operation corresponding to the request instruction through the K8s interface, wherein the chain code container operation includes a chain code container creation, a chain code container configuration, or a chain code container deletion operation.
[0036] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the chain code management method of the consortium chain of the first aspect when executing the computer program.
[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the chain code management method of the alliance chain of the first aspect.
[0038] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the steps of the chain code management method of the consortium chain of the first aspect above.
[0039] The first aspect of the embodiment of the present application has the beneficial effect compared with the prior art: when receiving a request instruction for a peer node to perform a corresponding operation on a chain code, the embodiment of the present application parses the request instruction; when parsing out that the request instruction is not a request instruction for building a chain code image, intercepts the call of the Docker interface corresponding to the Docker container management module, and calls the K8s interface corresponding to the K8s container management module; and executes the chain code container operation corresponding to the request instruction through the K8s interface, and the chain code container operation includes the creation of a chain code container, the configuration of a chain code container, or the deletion of a chain code container. When the embodiment of the present application passes the request instruction that is not a request instruction for building a chain code image, first intercepts the call of the Docker interface corresponding to the Docker container management module, and does not change the source code of the chain code Docker control part in the peer node in the chain code, but only intercepts it, and then calls the K8s interface corresponding to the K8s container management module to execute the chain code container operation corresponding to the request instruction, so that there is no need to change the source code of the chain code Docker control part itself, it is not easy to make mistakes, and the interception operation is also simple, so that it can be simply and conveniently combined with K8s to manage containers and improve the reliability of chain code corresponding container management.
[0040] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0042] Figure 1 It is a flowchart of the chain code management method of the alliance chain provided in Example 1 of the present application;
[0043] Figure 2 It is a flowchart of the chain code management method of the alliance chain provided in Example 2 of the present application;
[0044] Figure 3 It is a flowchart of the chain code management method of the alliance chain provided in Example 3 of the present application;
[0045] Figure 4 It is a flowchart of the chain code management method of the alliance chain provided in the fourth embodiment of the present application;
[0046] Figure 5 This is a flow chart of the chain code management device of the alliance chain provided in Embodiment 5 of the present application;
[0047] Figure 6 It is a structural diagram of the terminal device provided in Example 6 of the present application. DETAILED DESCRIPTION
[0048] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0049] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0050] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0051] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0052] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0053] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0054] This embodiment provides a chain code management method for a consortium chain, which can be applied to nodes in the consortium chain, and the nodes can be servers, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), mobile phones, or other electronic devices capable of data processing. The embodiment of this application does not impose any restrictions on the specific type of the device.
[0055] Embodiment 1
[0056] This embodiment provides a chain code management method for a consortium chain, which is applied to a chain code management system. The chain code management system includes a Docker container management module created based on Docker container technology, and the chain code management system includes a K8s container management module based on K8s container technology, such as Figure 1 As shown, the method includes steps S101 to S103:
[0057] Specifically, the Docker container management module is used to run the chain code container of the alliance chain based on the docker service, and the K8s container management module of the K8s container technology is used to implement the operation method of the chain code container using the Kubernetes platform, and the operation method of the chain code container includes the creation, operation, shutdown or removal of the chain code container. The K8s container management module is also used to implement the call to Kubernetes through the access to the K8sAPI provided by the Kubernetes platform.
[0058] Step S101, when receiving a request instruction from a peer node to perform a corresponding operation on a chain code, the request instruction is parsed.
[0059] Specifically, the consortium chain includes a series of peer nodes. Peer is the foundation of the entire consortium chain network because it is the carrier of the ledger and chain code. Through the chain code, the ledger records the entire process of the transaction in an unalterable manner. Hyperledger Fabric is a hyperledger framework contributed by IBM. It is an implementation of blockchain technology that is combined with existing mature technologies. In Hyperledger Fabric, the chain code of Hyperledger Fabric supports writing in common mainstream languages and running in Docker mode. With the popularization of container technology and the large-scale application of distributed clusters, Hyperledger Fabric cannot manage chaincode well based on the Docker deployment and operation mode. Peer nodes can send request instructions such as creation of chain code containers, configuration of chain code containers or deletion of chain code containers, and construction of chain code container images based on HTTP. When receiving a request instruction for a peer node to perform a corresponding operation on a chain code, the request instruction is parsed to determine which of the request instructions is creation of a chain code container, configuration of a chain code container or deletion of a chain code container, and construction of a chain code container image.
[0060] Step S102, when it is parsed that the request instruction is not a request instruction for chain code image construction, intercept the call of the Docker interface corresponding to the Docker container management module, and call the K8s interface corresponding to the K8s container management module.
[0061] Specifically, since the chain code management system includes a Docker container management module created based on Docker container technology, it will automatically implement the process of running based on the Docker service based on the Docker interface. The relevant operation process of image construction is still handed over to the Docker container management module for execution, and the relevant operation process of non-image construction is based on the K8s container management module. Therefore, when the request instruction is not for chain code image construction, the call of the Docker interface corresponding to the Docker container management module is intercepted, and the K8s interface corresponding to the K8s container management module is called. It can provide unified services to peer nodes, analyze the path of peer request instructions, and forward the operations related to the image to the Docker container management module. Other requests are processed through intermediate logic, and the processing process of the Docker container management module is intercepted first, and then forwarded to the K8s container management module.
[0062] In an application scenario, the path of the peer request instruction can be analyzed based on the launcher corresponding to Hyperledger Fabric. According to the path of the request instruction, it can be analyzed whether it is a request instruction such as the creation of a chain code container, the configuration of a chain code container, the deletion of a chain code container, or the construction of an image of a chain code container. The operations on the image will be forwarded to the Docker container management module. Other requests will be processed by the intermediate logic, first intercepting the processing process of the Docker container management module, and then forwarded to the K8s container management module.
[0063] Step S103: Execute the chaincode container operation corresponding to the request instruction through the K8s interface, where the chaincode container operation includes the creation of a chaincode container, the configuration of a chaincode container, or the deletion of a chaincode container.
[0064] Specifically, when the request instruction is not for image building, the API interface of K8s is called to realize the control (creation, start, stop, deletion, etc.) of the chaincode container by K8s. This method only requires the corresponding peer node to communicate with it through the http / https protocol to complete the control of each stage of the life cycle of the chaincode in the peer node by K8s. For example, when the peer node initiates a create request, when the peer node initiates a start request, when the peer node initiates a stop request, when the peer node initiates a delete request, etc., K8s can control the chaincode container. After executing the corresponding chaincode container operation, the corresponding result is returned to the peer node.
[0065] In one embodiment, after parsing the request instruction, it also includes: when the request instruction is parsed as a request instruction for chain code image construction, building an image based on the Docker container management module; and pushing the constructed image to a preset image repository.
[0066] Specifically, when the request instruction is parsed as a request instruction for chain code image construction, the image is built through Docker based on the Docker container management module, and the built image is pushed to the preset image warehouse. The preset image warehouse can be a preset database based on a distributed storage warehouse. The built image is pushed to the preset image warehouse, and can be pulled out from the preset image warehouse when needed.
[0067] In the embodiment of the present application, when the request instruction is not a request instruction for chain code image construction, the call of the Docker interface corresponding to the Docker container management module is first intercepted, and the source code of the chain code Docker control part in the peer node in the chain code is not changed. It is only intercepted, and then the K8s interface corresponding to the K8s container management module is called to perform the chain code container operation corresponding to the request instruction, thereby eliminating the need to change the source code of the chain code Docker control part itself, making it less prone to errors, and the interception operation is also simple, so that the K8s management container can be simply and conveniently combined to improve the reliability of the chain code corresponding container management.
[0068] Embodiment 2
[0069] This embodiment is a further explanation of the first embodiment. For details of the same or similar parts as the first embodiment, please refer to the relevant description of the first embodiment, which will not be repeated here. Figure 2 As shown, the above step S102 includes step S202, and step S103 includes step S203. The chain code management method of the alliance chain provided in the embodiment of the present application includes:
[0070] Step S201: When receiving a request instruction from a peer node to perform a corresponding operation on a chain code, the request instruction is parsed.
[0071] Specifically, for the parts where step S201 is identical or similar to the above-mentioned step S101, please refer to the relevant description of step S101, which will not be repeated here.
[0072] Step S202, when it is parsed that the request instruction is a request instruction for chaincode container creation, intercept the call of the Docker creation interface corresponding to the Docker container management module, and call the K8s creation interface.
[0073] Specifically, the peer initiates a creation request: such as creating a credit-cc chaincode. When receiving the request instruction, the path is extracted, and the process processing entry is entered. Based on the preset reference process control protocol, the data in the "create request" is parsed to obtain the configuration parameters required for creation, and the credit-cc-deployment.yml file is generated based on the configuration parameters and the preset creation yml configuration file template, and then the corresponding K8sAPI is called.
[0074] Step S203: Execute the chain code container creation operation through the K8s creation interface.
[0075] Specifically, the deployment of credit-cc chiancode is completed based on calling the corresponding K8sAPI, and the information that the credit-cc chiancode deployment is successful is returned to the peer node.
[0076] In one embodiment, executing the chaincode container creation operation through the K8s creation interface includes: obtaining a target image corresponding to the container creation from a preset image repository; and executing the chaincode container creation operation through the K8s creation interface according to the target image.
[0077] Specifically, during the creation process, if the corresponding image file exists in the preset image repository, it can be created directly according to the corresponding image, so the target image corresponding to the container creation can be obtained from the preset image repository; according to the target image, the chain code container creation operation is performed through the K8s creation interface.
[0078] In one embodiment, before executing the chain code container creation operation through the K8s creation interface according to the target image, it also includes: if the target image corresponding to the container creation is not obtained from the preset image repository, the target image is built based on the Docker container management module.
[0079] Specifically, during the creation process, if the corresponding image file exists in the preset image repository, it can be created directly according to the corresponding image. However, if the corresponding target image does not exist in the preset image repository, the image can be built through Docker based on the Docker container management module, and the built image can be pushed to the preset image repository.
[0080] In one embodiment, a certificate file corresponding to the chain code is obtained; and the certificate file is uploaded to the created chain code container.
[0081] Specifically, there is an environment variable EABLE_TLS in the peer. When this variable is true, the peer self-signs a TLS certificate and calls the archive (which can be understood as upload) interface to upload it to the container, so as to obtain the certificate file corresponding to the chaincode; upload the certificate file to the created chaincode container, and security can be improved based on the certificate file.
[0082] When the request instruction is parsed as a request instruction for chain code container creation, this embodiment intercepts the call of the Docker creation interface corresponding to the Docker container management module, and calls the K8s creation interface; the chain code container creation operation is performed through the K8s creation interface. Based on the simple and convenient combination of K8s management container, the life cycle of the chain code container creation phase can be controlled, and the reliability of chain code corresponding container management is improved.
[0083] Embodiment 3
[0084] This embodiment is a further explanation of the first embodiment. For details of the same or similar parts as the first embodiment, please refer to the relevant description of the first embodiment, which will not be repeated here. Figure 3 As shown, the above step S102 includes step S302, and step S103 includes step S303. The chain code management method of the alliance chain provided in the embodiment of the present application includes:
[0085] Step S301: When receiving a request instruction from a peer node to perform a corresponding operation on a chain code, the request instruction is parsed.
[0086] Specifically, for the parts where step S301 is identical or similar to the above-mentioned step S101, please refer to the relevant description of step S101, which will not be repeated here.
[0087] Step S302, when the request instruction is parsed as a request instruction for chaincode container configuration, intercept the call of the Docker configuration interface corresponding to the Docker container management module, and call the configuration mapping creation interface of k8s.
[0088] Specifically, the peer can initiate an "upload request", which can actually be implemented by calling the archive request. When the request instruction is received, the path is extracted and the process processing entry is entered. Based on the preset reference process control protocol, the data in the "upload request" is parsed to obtain the configuration parameters required for the configuration. Configmap can be called configuration mapping. Configmap is a resource in K8S. The interface that performs corresponding operations on the Configmap file is called the k8s configuration mapping creation interface. Generate the credit-cc-configmap.yml file based on the configuration parameters and the preset configuration yml file template, and then call the corresponding K8sAPI.
[0089] Step S303, performing the chain code container configuration operation through the k8s configuration mapping creation interface.
[0090] Specifically, the configuration deployment of the credit-cc configmap is completed based on calling the corresponding K8sAPI, and the information that the credit-cc configmap configuration deployment is successful is returned to the peer node.
[0091] When the request instruction is parsed as a request instruction for chain code container creation, this embodiment intercepts the call of the Docker configuration interface corresponding to the Docker container management module, and calls the configuration mapping creation interface of k8s; the chain code container configuration operation is performed through the configuration mapping creation interface of k8s. Based on the simple and convenient combination of K8s management container, the configuration phase life cycle of the chain code container can be controlled, and the reliability of chain code corresponding container management is improved.
[0092] Embodiment 4
[0093] This embodiment is a further explanation of the first embodiment. For details of the same or similar parts as the first embodiment, please refer to the relevant description of the first embodiment, which will not be repeated here. Figure 4 As shown, the above step S102 includes step S402, and step S103 includes step S403. The chain code management method of the alliance chain provided in the embodiment of the present application includes:
[0094] Step S401: When receiving a request instruction from a peer node to perform a corresponding operation on a chain code, the request instruction is parsed.
[0095] Specifically, the parts where step S401 is identical or similar to the above-mentioned step S101 can be specifically referred to the relevant description of step S101, which will not be repeated here.
[0096] Step S402: When it is parsed that the request instruction is a request instruction for deleting a chaincode container, the call of the Docker deletion interface corresponding to the Docker container management module is intercepted, and the K8s deletion interface is called.
[0097] Specifically, the peer node initiates a stop / kill / remove request (after source code analysis, these three operations will be executed during the stop process, and the final result is that the chaincode is deleted): such as stopping the credit-cc chaincode. When receiving the request instruction, the path is extracted, and the process processing entrance is entered. Based on the preset reference process control protocol, the data in "stop credit-cc chaincode" is parsed to obtain the configuration data to be deleted, and then the corresponding K8sAPI is called to delete the corresponding configuration data.
[0098] Step S403: Execute the chain code container deletion operation through the K8s deletion interface.
[0099] Specifically, the deletion is completed based on calling the corresponding K8sAPI, and after the deletion is successful, the deletion success information is returned to the peer node.
[0100] When the request instruction is parsed as a request instruction for chain code container deletion, this embodiment intercepts the call of the Docker deletion interface corresponding to the Docker container management module and calls the K8s deletion interface; the chain code container deletion operation is performed through the K8s deletion interface. Based on the simple and convenient combination of K8s management container, the life cycle of the chain code container can be controlled in the deletion phase, which improves the reliability of chain code corresponding container management.
[0101] Embodiment 5
[0102] Corresponding to the chain code management method of the alliance chain described in the above embodiment, Figure 5 The structural block diagram of the chain code management device of the alliance chain provided by the embodiment of the present application is shown. The chain code management device is applied to the chain code management system. The chain code management system includes a Docker container management module created based on the Docker container technology. The chain code management system includes a K8s container management module based on the K8s container technology. For the sake of convenience, only the parts related to the embodiment of the present application are shown. The chain code management device 500 of the alliance chain includes:
[0103] The parsing module 501 is used to parse the request instruction when receiving the request instruction of the peer node to perform the corresponding operation on the chain code;
[0104] The calling module 502 is used to intercept the call of the Docker interface corresponding to the Docker container management module and call the K8s interface corresponding to the K8s container management module when parsing that the request instruction is not a request instruction for chain code image construction;
[0105] The operation module 503 is used to execute the chain code container operation corresponding to the request instruction through the K8s interface, and the chain code container operation includes the creation of a chain code container, the configuration of a chain code container, or the deletion of a chain code container.
[0106] In one embodiment, the chain code management device 500 of the alliance chain further includes:
[0107] An image parsing module, configured to build an image based on the Docker container management module when parsing the request instruction to be a request instruction for building a chaincode image;
[0108] The push module is used to push the built image to a preset image repository.
[0109] In one embodiment, the calling module 502 includes a first calling unit, which is used to intercept the call of the Docker creation interface corresponding to the Docker container management module and call the K8s creation interface when parsing the request instruction as a request instruction for chain code container creation;
[0110] Correspondingly, the operation module includes a first operation unit, which is used to perform a chain code container creation operation through the K8s creation interface.
[0111] In one embodiment, the calling module 502 includes a second calling unit, which is used to intercept the call of the Docker configuration interface corresponding to the Docker container management module when parsing the request instruction as a request instruction for chain code container configuration, and call the configuration mapping creation interface of k8s;
[0112] Correspondingly, the operation module includes a second operation unit, which is used to perform the chain code container configuration operation through the configuration mapping creation interface of the k8s.
[0113] In one embodiment, the calling module 502 includes a second calling unit, which is used to intercept the call of the Docker deletion interface corresponding to the Docker container management module and call the K8s deletion interface when parsing the request instruction as a request instruction for chain code container deletion;
[0114] Correspondingly, the operation module includes a second operation unit, which is used to perform the chain code container deletion operation through the K8s deletion interface.
[0115] In one embodiment, the first operating unit includes:
[0116] An acquisition subunit is used to acquire a target image corresponding to the container creation from a preset image repository;
[0117] A creation subunit is used to perform a chain code container creation operation through the K8s creation interface according to the target image.
[0118] In one embodiment, the first operating unit further includes:
[0119] The image building subunit is used to build the target image based on the Docker container management module if the target image corresponding to the container creation is not obtained from the preset image repository before the chain code container creation operation is performed through the K8s creation interface according to the target image.
[0120] In one embodiment, the chain code management device 500 of the alliance chain further includes:
[0121] A certificate acquisition module, used to obtain the certificate file corresponding to the chain code;
[0122] The certificate upload module is used to upload the certificate file to the created chain code container.
[0123] In the embodiment of the present application, when the request instruction is not a request instruction for chain code image construction, the call of the Docker interface corresponding to the Docker container management module is first intercepted, and the source code of the chain code Docker control part in the peer node in the chain code is not changed. It is only intercepted, and then the K8s interface corresponding to the K8s container management module is called to perform the chain code container operation corresponding to the request instruction, thereby eliminating the need to change the source code of the chain code Docker control part itself, making it less prone to errors, and the interception operation is also simple, so that the K8s management container can be simply and conveniently combined to improve the reliability of the chain code corresponding container management.
[0124] Embodiment 6
[0125] like Figure 6 As shown, the embodiment of the present application further provides a terminal device 600 including: a processor 601, a memory 602, and a computer program 603 stored in the memory 602 and executable on the processor 601. When the processor 601 executes the computer program 603, the steps of the chain code management method of the alliance chain in the above embodiment are implemented.
[0126] Exemplarily, the computer program 603 may be divided into one or more modules, which are stored in the memory 602 and executed by the processor 601 to complete the present invention. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 603 in the terminal device 600. For example, the computer program 603 may be divided into a parsing module, a calling module, an operation module, etc. The specific functions of each module have been described in the above embodiments and will not be repeated here.
[0127] The terminal device 600 may be a server, a tablet computer, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a mobile phone, or other computing devices. The terminal device may include, but is not limited to, a processor 601 and a memory 602. Those skilled in the art will appreciate that Figure 6 It is only an example of the terminal device 600 and does not constitute a limitation of the terminal device 600. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.
[0128] The processor 601 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0129] The memory 602 may be an internal storage unit of the terminal device 600, such as a hard disk or memory of the terminal device 600. The memory 602 may also be an external storage device of the terminal device 600, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 600. Further, the memory 602 may also include both an internal storage unit of the terminal device 600 and an external storage device. The memory 602 is used to store the computer program and other programs and data required by the terminal device. The memory 602 may also be used to temporarily store data that has been output or is to be output.
[0130] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0131] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0132] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0133] In the embodiments provided by the present invention, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0134] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0135] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0136] If the integrated module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0137] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A chain code management method for a consortium chain, applied to a chain code management system, wherein the chain code management system includes a Docker container management module created based on Docker container technology, characterized in that: The chain code management system includes a K8s container management module based on the K8s container technology, and the method includes: When receiving a request instruction from a peer node to perform a corresponding operation on a chain code, parsing the request instruction; When it is parsed that the request instruction is not a request instruction for chain code image construction, intercept the call of the Docker interface corresponding to the Docker container management module, and call the K8s interface corresponding to the K8s container management module; The chaincode container operation corresponding to the request instruction is executed through the K8s interface, and the chaincode container operation includes the creation of a chaincode container, the configuration of a chaincode container, or the deletion of a chaincode container.
2. The chain code management method according to claim 1, characterized in that: After parsing the request instruction, it also includes: When parsing the request instruction to be a request instruction for chain code image construction, building an image based on the Docker container management module; The built image is pushed to the preset image warehouse.
3. The chain code management method according to claim 1, characterized in that: When parsing that the request instruction is not a request instruction for chain code image construction, intercepting the call of the Docker interface corresponding to the Docker container management module, and calling the K8s interface corresponding to the K8s container management module, including: When parsing the request instruction as a request instruction for chaincode container creation, intercepting the call of the Docker creation interface corresponding to the Docker container management module, and calling the K8s creation interface; Correspondingly, executing the chain code container operation corresponding to the request instruction through the K8s interface includes: The chaincode container creation operation is performed through the K8s creation interface.
4. The chain code management method according to claim 1, characterized in that: When parsing that the request instruction is not a request instruction for chain code image construction, intercepting the call of the Docker interface corresponding to the Docker container management module, and calling the K8s interface corresponding to the K8s container management module, including: When parsing the request instruction as a request instruction for chaincode container configuration, intercept the call of the Docker configuration interface corresponding to the Docker container management module, and call the configuration mapping creation interface of k8s; Correspondingly, executing the chain code container operation corresponding to the request instruction through the K8s interface includes: The chaincode container configuration operation is performed through the k8s configuration mapping creation interface.
5. The chain code management method according to claim 1 is characterized in that: When parsing that the request instruction is not a request instruction for chain code image construction, intercepting the call of the Docker interface corresponding to the Docker container management module, and calling the K8s interface corresponding to the K8s container management module, including: When parsing the request instruction as a request instruction for chaincode container deletion, intercepting the call of the Docker deletion interface corresponding to the Docker container management module, and calling the K8s deletion interface; Correspondingly, executing the chain code container operation corresponding to the request instruction through the K8s interface includes: The chaincode container deletion operation is performed through the K8s deletion interface.
6. The chain code management method according to claim 3 is characterized in that: The chain code container creation operation is performed through the K8s creation interface, including: Obtain a target image corresponding to the container creation from a preset image repository; According to the target image, a chaincode container creation operation is performed through the K8s creation interface.
7. The chain code management method according to claim 6, characterized in that: Before executing the chain code container creation operation through the K8s creation interface according to the target image, it also includes: If the target image corresponding to the container creation is not obtained from the preset image repository, the target image is constructed based on the Docker container management module.
8. The chain code management method according to claim 6, characterized in that: The chain code management method further includes: Obtain the certificate file corresponding to the chain code; Upload the certificate file to the created chaincode container.
9. A chain code management device for a consortium chain, applied to a chain code management system, wherein the chain code management system includes a Docker container management module created based on Docker container technology, characterized in that: The chain code management system includes a K8s container management module based on K8s container technology, and the device includes: A parsing module, used to parse the request instruction when receiving the request instruction of the peer node to perform corresponding operations on the chain code; A calling module, used for intercepting the call of the Docker interface corresponding to the Docker container management module and calling the K8s interface corresponding to the K8s container management module when parsing that the request instruction is not a request instruction for chain code image construction; An operation module is used to execute a chain code container operation corresponding to the request instruction through the K8s interface, wherein the chain code container operation includes a chain code container creation, a chain code container configuration, or a chain code container deletion operation.
10. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Method for scheduling blockchain platform resources
CN111324453A
Chain code container management method and device of alliance chain, equipment and storage medium
CN112631728A
SDK deployment architecture and packaging mode for solving blockchain environment security management problem
CN113010905A
Peer node instruction transmission method and device, proxy server and storage medium
CN113407384A
