CN114020403A - Chain code management method and device of alliance chain and terminal equipment - Google Patents

Chain code management method and device of alliance chain and terminal equipment Download PDF

Info

Publication number
CN114020403A
CN114020403A CN202111246219.6A CN202111246219A CN114020403A CN 114020403 A CN114020403 A CN 114020403A CN 202111246219 A CN202111246219 A CN 202111246219A CN 114020403 A CN114020403 A CN 114020403A
Authority
CN
China
Prior art keywords
container
chain code
docker
request instruction
interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111246219.6A
Other languages
Chinese (zh)
Inventor
匡立中
李伟
钟蔚蔚
张帅
柯帆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202111246219.6A priority Critical patent/CN114020403A/en
Publication of CN114020403A publication Critical patent/CN114020403A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45591Monitoring or debugging support

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application is applicable to the technical field of alliance chains, and provides a method, a device and a terminal device for managing a chain code of an alliance chain, wherein the method comprises the following steps: when a request instruction for performing corresponding operation on the chain code by the peer node is received, analyzing the request instruction; when the request instruction is analyzed and is not the request instruction constructed by the chain code mirror image, intercepting the calling of a Docker interface corresponding to a Docker container management module, and calling a K8s interface corresponding to a K8s container management module; the chain code container operation corresponding to the request instruction is executed through the K8s interface. The calling of a Docker interface corresponding to a Docker container management module can be intercepted firstly, and the source code of a chain code Docker control part in a peer node in a chain code cannot be changed, so that the source code of the chain code Docker control part is not required to be changed, errors are not easy to occur, containers can be managed simply and conveniently by combining K8s, and the management reliability of containers corresponding to the chain code is improved.

Description

Chain code management method and device of alliance chain and terminal equipment
Technical Field
The present application belongs to the field of alliance chain technologies, and in particular, to a method and an apparatus for managing a chain code of an alliance chain, and a terminal device.
Background
A federation chain sometimes encounters a need to deploy multiple identical or similar chain codes (called "smart contracts") during deployment, each time a large amount of time is spent for repetitive work, and thus container technology arises, and a container is a lightweight, portable, self-contained virtualization technology, so that the relevant chain codes can operate in the same manner almost anywhere.
The Docker is an open-source application container engine, and based on the Docker container technology, the Docker may be used as a virtualized container to run on a host in an isolated manner, and an Image (Image) of the Docker is a special file system, and besides providing files such as programs, libraries, resources, and configurations required by the container running, the Docker also includes configuration parameters (such as anonymous volumes, environment variables, users, and the like) prepared for the running.
Kubernetes, also called K8s, can provide orchestration and management functions, easily accomplish large-scale container deployment, with the help of K8s orchestration functions, users can build application services across multiple containers, achieve cross-cluster scheduling, expand containers, and continuously manage the health conditions of the containers for a long time, and integrate networks. Therefore, the control on the chaincode container can be realized by utilizing the K8s, the control can be understood as the integrated call on the K8s interface (K8sAPI), and the K8s interface can be adaptively replaced by the original Docker interface by transforming the source code of the chain code control part in the peer node in the chain code so as to achieve the aim of managing through the K8 s. However, the source code of the federation chain needs to be modified, for example, the source code of the chain code control part in the peer node is not well known, errors are easy to occur, and the operation is complex and tedious, so that the management reliability of the container corresponding to the chain code is low.
Disclosure of Invention
The embodiment of the application provides a chain code management method and device of a alliance chain and terminal equipment, and aims to solve the problem that the management reliability of a container corresponding to the existing chain code is low.
In a first aspect, an embodiment of the present application provides a link code management method for a federation chain, where the link code management method is applied to a link code management system, where the link code management system includes a Docker container management module created based on a Docker container technology, and the link code management system includes a K8s container management module based on a K8s container technology, and the method includes:
when a request instruction for performing corresponding operation on the chain code by a peer node is received, analyzing the request instruction;
when the request instruction is analyzed to be not the request instruction constructed by the chain code mirror image, intercepting the calling of a Docker interface corresponding to the Docker container management module, and calling a K8s interface corresponding to the K8s container management module;
and executing a chain code container operation corresponding to the request instruction through the K8s interface, wherein the chain code container operation comprises the creation of a chain code container, the configuration of the chain code container or the deletion of the chain code container.
In one embodiment, after parsing the request instruction, the method further includes: when the request instruction is analyzed to be a request instruction constructed by a chain code mirror image, constructing the mirror image based on the Docker container management module;
and pushing the constructed mirror image to a preset mirror image warehouse.
In one embodiment, when the request instruction is analyzed not to be a request instruction constructed by a chain code mirror image, intercepting a call of a Docker interface corresponding to the Docker container management module, and calling a K8s interface corresponding to the K8s container management module includes:
when the request instruction is analyzed to be the request instruction created by the chain code container, intercepting the call of a Docker creation interface corresponding to the Docker container management module, and calling the K8s creation interface;
correspondingly, the executing, through the K8s interface, a chain code container operation corresponding to a request instruction includes:
and executing a chain code container creation operation through the K8s creation interface.
When the request instruction is analyzed not to be the request instruction constructed by the chain code mirror image, 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 the request instruction is analyzed to be the request instruction configured by the chain code container, intercepting the call of a Docker configuration interface corresponding to the Docker container management module, and calling a configuration mapping creation interface of k8 s;
correspondingly, the executing, through the K8s interface, a chain code container operation corresponding to a request instruction includes:
and executing chain code container configuration operation through the configuration mapping creation interface of the k8 s.
In one embodiment, when the request instruction is analyzed not to be a request instruction constructed by a chain code mirror image, intercepting a call of a Docker interface corresponding to the Docker container management module, and calling a K8s interface corresponding to the K8s container management module includes:
intercepting the call of a Docker deleting interface corresponding to the Docker container management module and calling a K8s deleting interface when the request instruction is analyzed to be a request instruction for deleting the chain code container;
correspondingly, the executing, through the K8s interface, a chain code container operation corresponding to a request instruction includes:
and executing chain code container deleting operation through the K8s deleting interface.
In one embodiment, the performing, by the K8s creation interface, a chain code container creation operation includes:
acquiring a target mirror image corresponding to the container creation from a preset mirror image warehouse;
and according to the target image, performing chain code container creation operation through the K8s creation interface.
In one embodiment, before performing a chain container creation operation through the K8s creation interface according to the target image, the method further includes:
and if the target mirror image corresponding to the container creation is not acquired from a preset mirror image warehouse, constructing the target mirror image based on the Docker container management module.
In one embodiment, the chain code management method further includes:
acquiring a certificate file corresponding to the chain code;
and uploading the certificate file to the created chain code container.
In a second aspect, an embodiment of the present application provides a link code management apparatus for a federation chain, where the link code management apparatus is applied to a link code management system, the link code management system includes a Docker container management module created based on Docker container technology, and the link code management system includes a K8s container management module based on K8s container technology, and the apparatus includes:
the analysis module is used for analyzing the request instruction when receiving the request instruction of the peer node for carrying out corresponding operation on the chain code;
the calling module is used for intercepting the calling of a Docker interface corresponding to the Docker container management module and calling a K8s interface corresponding to the K8s container management module when the request instruction which is not constructed by the chain code mirror image is analyzed;
and the operation module is used for executing chain code container operation corresponding to the request instruction through the K8s interface, wherein the chain code container operation comprises the creation of a chain code container, the configuration of the chain code container or the deletion operation of the chain code container.
In a third aspect, an embodiment of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the above-mentioned method for managing chain codes of a federation chain in the first aspect when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned method for managing chain codes of a federation chain of the first aspect are implemented.
In a fifth aspect, the present application provides a computer program product, which when run on an electronic device, causes the electronic device to execute the steps of the above-mentioned method for managing chain codes of a federation chain of the first aspect.
Compared with the prior art, the first aspect of the embodiment of the application has the following beneficial effects: when a request instruction for performing corresponding operation on the chain code by a peer node is received, analyzing the request instruction; when the request instruction which is not constructed by the chain code mirror image is analyzed, intercepting the calling of a Docker interface corresponding to the Docker container management module, and calling a K8s interface corresponding to the K8s container management module; and executing a chain code container operation corresponding to the request instruction through the K8s interface, wherein the chain code container operation comprises the creation of a chain code container, the configuration of the chain code container or the deletion of the chain code container. When the request instruction is not the request instruction constructed by the chain code mirror image, the call of the Docker interface corresponding to the Docker container management module is intercepted first, the source code of the chain code Docker control part in the peer node in the chain code cannot be changed, the call is only carried out, and then the chain code container operation corresponding to the request instruction is executed by the K8s interface corresponding to the K8s container management module, so that the source code of the chain code Docker control part is not required to be changed, errors are not easy to occur, the operation is simple through interception, the K8s management container can be simply and conveniently combined, and the reliability of container management corresponding to the chain code is improved.
It is understood that the beneficial effects of the second aspect to the fifth aspect can be referred to the related description of the first aspect, and are not described herein again.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flowchart of a chain code management method of a federation chain according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a chain code management method of a federation chain according to a second embodiment of the present application;
fig. 3 is a schematic flowchart of a chain code management method of a federation chain according to a third embodiment of the present application;
fig. 4 is a flowchart illustrating a chain code management method of a federation chain according to a fourth embodiment of the present application;
fig. 5 is a schematic flowchart of a chain code management apparatus of a federation chain according to a fifth embodiment of the present application;
fig. 6 is a schematic structural diagram of a terminal device according to a sixth embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
The present embodiment provides a chain code management method for a federation chain, which may be applied to a node in the federation chain, where the node may be a server, a tablet computer, a wearable device, an in-vehicle device, an Augmented Reality (AR)/Virtual Reality (VR) device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a Personal Digital Assistant (PDA), a mobile phone, or other various electronic devices capable of performing data processing. The embodiment of the present application does not set any limit to the specific type of the device.
Example one
The present embodiment provides a link code management method of a federation chain, which is applied to a link code management system, where the link code management system includes a Docker container management module created based on Docker container technology, and the link code management system includes a K8S container management module based on K8S container technology, as shown in fig. 1, the method includes steps S101 to S103:
specifically, the Docker container management module is configured to run a chain code container of the federation chain based on Docker service, and the K8s container management module of the K8s container technology is configured to implement an operation method of the chain code container using a Kubernetes platform, where the operation method of the chain code container includes creation, running, closing, or removal of the chain code container. The K8s container management module is also used for realizing the call to Kubernets through the access of K8sAPI provided by the Kubernets platform.
And step S101, when a request instruction for performing corresponding operation on the chain code by the peer node is received, analyzing the request instruction.
Specifically, the federation chain includes a series of peer nodes. peer is the basis of the whole alliance chain network because it is the carrier of ledgers and chain codes. Through the chain code, the account book records the whole transaction process in a non-falsifiable mode. Hyperledger Fabric the Hyperledger framework contributed by IBM. It is an implementation of a block chain technique that is combined using existing mature techniques. In Hyperledger Fabric, chain code of Hyperledger Fabric supports general mainstream language programming and runs in a Docker manner. With the popularization of container technology and the large-scale application of distributed clusters, Hyperhedger Fabric cannot manage chaincode well based on a Docker deployment and operation mode. The Peer node may send a request instruction based on HTTP for creation of a chain container, configuration of the chain container or deletion operation of the chain container, construction of a mirror image of the chain container, and the like. When a request instruction for performing corresponding operation on the chain code by the peer node is received, analyzing which request instruction is one of the request instructions such as creation of a chain code container, configuration of the chain code container, deletion operation of the chain code container, construction of a mirror image of the chain code container and the like.
Step S102, when the request instruction is analyzed not to be the request instruction constructed by the chain code mirror image, intercepting the calling of the Docker interface corresponding to the Docker container management module, and calling the K8S interface corresponding to the K8S container management module.
Specifically, the chain code management system comprises a Docker container management module created based on a Docker container technology, and can automatically realize the operation of a process based on Docker service based on a Docker interface, wherein the related operation process constructed by mirroring is still executed by the Docker container management module, and the related operation process constructed by non-mirroring is based on a K8s container management module, so that when a request instruction constructed for chain code mirroring is not generated, 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. The method can provide uniform service for the peer node, analyze the path of the peer request instruction, forward the operation in the mirror image aspect to the Docker container management module, intercept the processing process of the Docker container management module by intermediate logic processing of other requests, and forward the processing process to the K8s container management module.
In an application scenario, the path of a peer request instruction may be analyzed based on a launcher (launcher) corresponding to a HyperLegendr Fabric, and according to which the path analysis of the request instruction is which request instruction of request instructions, such as creation of a chain container, configuration of the chain container, or deletion of the chain container, or construction of a mirror image of the chain container, the request instruction is forwarded to a Docker container management module for operations in the mirror image aspect, and other requests are subjected to intermediate logic processing, the processing process of the Docker container management module is intercepted first, and then forwarded to the K8s container management module.
And step S103, executing chain code container operation corresponding to the request instruction through the K8S interface, wherein the chain code container operation comprises the creation of a chain code container, the configuration of the chain code container or the deletion operation of the chain code container.
Specifically, when a request instruction constructed for mirroring is not provided, the API interface of the K8s is called, and management and control (creation, start, stop, deletion, and the like) of the chain code container by the K8s are realized, and the method can complete management and control of the chain code in the peer node by the K8s only by communicating with the peer node through an http/https protocol, for example: when the peer node initiates a creation request, a start request, a stop request, a deletion request, and the like, the control of the K8s on the chaincode container can be realized. After the corresponding chain code container operation is executed, the corresponding result is returned to the peer node.
In one embodiment, after parsing the request instruction, the method further includes: when the request instruction is analyzed to be a request instruction constructed by a chain code mirror image, constructing the mirror image based on the Docker container management module; and pushing the constructed mirror image to a preset mirror image warehouse.
Specifically, when the request instruction is analyzed to be the request instruction constructed by the chain code mirror image, the mirror image is constructed through the Docker based on the Docker container management module, and the constructed mirror image is pushed to a preset mirror image warehouse. The pre-defined mirror repository may be a pre-defined distributed storage repository-based database. And pushing the constructed mirror image to a preset mirror image warehouse, and pulling out the mirror image from the preset mirror image warehouse when needed.
When the request instruction is not the request instruction constructed by the chain code mirror image, the call of the Docker interface corresponding to the Docker container management module is intercepted first, the source code of the chain code Docker control part in the peer node in the chain code cannot be changed, the call is only carried out, and then the K8s container management module corresponding K8s interface executes the chain code container operation corresponding to the request instruction, so that the source code of the chain code Docker control part is not required to be changed, errors are not easy to occur, the interception operation is simple, the K8s management container can be conveniently and simply answered, and the reliability of container management corresponding to the chain code is improved.
Example two
The present embodiment is further described in the first embodiment, and reference may be specifically made to the related description of the first embodiment where the same or similar to the first embodiment, and details are not described herein again. As shown in fig. 2, step S102 includes step S202, step S103 includes step S203, and the method for managing a chain code of a federation chain provided in the embodiment of the present application includes:
step S201, when a request instruction of a peer node for performing corresponding operation on the chain code is received, the request instruction is analyzed.
Specifically, where step S201 is the same as or similar to step S101, reference may be specifically made to the related description of step S101, and details are not repeated here.
Step S202, when the request instruction is analyzed to be the request instruction created by the chain code container, intercepting the call of a Docker creation interface corresponding to the Docker container management module, and calling the K8S creation interface.
Specifically, the peer initiates a create request: such as creating a credit-cc chaincode. When the request instruction is received, the path is extracted, the flow enters a flow processing inlet, data in the create request is analyzed based on a preset reference flow control protocol, configuration parameters required for creation are obtained, a create-cc-deployment.
And step S203, executing the chain code container creating operation through the K8S creating interface.
Specifically, deployment of the credit-cc backbone is completed based on calling of the corresponding K8sAPI, and information that the credit-cc backbone is successfully deployed is returned to the peer node.
In one embodiment, the performing, by the K8s creation interface, a chain code container creation operation includes: acquiring a target mirror image corresponding to the container creation from a preset mirror image warehouse; and according to the target image, performing chain code container creation operation through the K8s creation interface.
Specifically, if a corresponding image file exists in the preset image warehouse in the creating process, the corresponding image file can be directly created according to the corresponding image file, so that a target image corresponding to the container creation can be obtained from the preset image warehouse; and according to the target image, performing chain code container creation operation through the K8s creation interface.
In one embodiment, before performing a chain container creation operation through the K8s creation interface according to the target image, the method further includes: and if the target mirror image corresponding to the container creation is not acquired from a preset mirror image warehouse, constructing the target mirror image based on the Docker container management module.
Specifically, in the creating process, if a corresponding image file exists in the preset image warehouse, the image can be directly created according to the corresponding image, but if a corresponding target image does not exist in the preset image warehouse, the image can be created through a Docker based on a Docker container management module, and the created image is pushed to the preset image warehouse.
In one embodiment, a certificate file corresponding to the chain code is obtained; and uploading the certificate file to the created chain code container.
Specifically, an environment variable EABLE _ TLS exists in the Peer, when the variable is true, the Peer self-signs to generate a TLS certificate, and an archive (which can be understood as upload) interface is called to upload the TLS certificate to a container, so that a certificate file corresponding to the chain code can be acquired; and uploading the certificate file to the created chain code container, so that the safety can be improved based on the certificate file.
In this embodiment, when the request instruction created by the chain code container is analyzed, the call of the Docker creation interface corresponding to the Docker container management module is intercepted, and the K8s creation interface is called; and executing a chain code container creation operation through the K8s creation interface. The container can be managed based on simple and convenient combination with K8s, the life cycle of the chain code container in the creation stage is controlled, and the management reliability of the chain code corresponding to the container is improved.
EXAMPLE III
The present embodiment is further described in the first embodiment, and reference may be specifically made to the related description of the first embodiment where the same or similar to the first embodiment, and details are not described herein again. As shown in fig. 3, step S102 includes step S302, step S103 includes step S303, and the method for managing a chain code of a federation chain provided in the embodiment of the present application includes:
step S301, when a request instruction of a peer node for performing corresponding operation on the chain code is received, the request instruction is analyzed.
Specifically, where step S301 is the same as or similar to step S101, reference may be specifically made to the related description of step S101, and details are not repeated here.
Step S302, when the request instruction is analyzed to be a request instruction configured for a chain code container, intercepting a call of a Docker configuration interface corresponding to the Docker container management module, and calling a configuration mapping creation interface of k 8S.
Specifically, the peer may initiate an "upload request," which may be actually implemented by calling an archive request, extract a path when receiving the request instruction, enter a process processing entry, analyze data in the "upload request" based on a preset reference process control protocol, and obtain configuration parameters required for configuration. The Configmap may be called a configuration map, the Configmap is a resource in K8S, and the interface performing the corresponding operation on the Configmap file is called a configuration map creation interface of K8 s. Yml file is generated based on the configuration parameters and preset configuration yml file template, and then the corresponding K8sAPI is called.
And step S303, executing chain code container configuration operation through the configuration mapping creation interface of the k 8S.
Specifically, configuration deployment of the credit-cc configmap is completed based on calling of the corresponding K8sAPI, and information that configuration deployment of the credit-cc configmap is successful is returned to the peer node.
In this embodiment, when the request instruction created by the chain code container is analyzed, the call of the Docker configuration interface corresponding to the Docker container management module is intercepted, and the configuration mapping creation interface of k8s is called; and executing chain code container configuration operation through the configuration mapping creation interface of the k8 s. The container can be managed based on simple and convenient combination K8s, the control of the configuration stage life cycle of the chain code container is realized, and the management reliability of the chain code corresponding to the container is improved.
Example four
The present embodiment is further described in the first embodiment, and reference may be specifically made to the related description of the first embodiment where the same or similar to the first embodiment, and details are not described herein again. As shown in fig. 4, step S102 includes step S402, step S103 includes step S403, and the method for managing a chain code of a federation chain according to the embodiment of the present application includes:
step S401, when a request instruction of a peer node for performing corresponding operation on the chain code is received, the request instruction is analyzed.
Specifically, where step S401 is the same as or similar to step S101, reference may be specifically made to the related description of step S101, and details are not repeated here.
Step S402, when the request instruction is analyzed to be a request instruction for deleting the chain code container, intercepting the call of a Docker deleting interface corresponding to the Docker container management module, and calling the K8S deleting interface.
Specifically, the peer node initiates a stop/kill/remove (after source code analysis, in the process of stop, these three operations must be executed, and the final result is that the chaincode is deleted) request: such as stop credit-cc chaincode. When the request instruction is received, the path is extracted, the flow processing entry is entered, the data in the stop credit-cc chaincode is analyzed based on a preset reference flow control protocol, the configuration data needing to be deleted is obtained, and then the corresponding K8sAPI is called to delete the corresponding configuration data.
And step S403, executing chain code container deleting operation through the K8S deleting interface.
Specifically, based on the fact that the corresponding K8sAPI is called to complete deletion, the information of successful deletion is returned to the peer node after the deletion is successful.
In this embodiment, when the request instruction is analyzed to be a request instruction for deleting a chain code container, the call of a Docker deletion interface corresponding to the Docker container management module is intercepted, and a K8s deletion interface is called; and executing chain code container deleting operation through the K8s deleting interface. The container can be managed based on simple and convenient combination of K8s, the control of the life cycle of the chain code container in the deleting stage is realized, and the management reliability of the chain code corresponding to the container is improved.
EXAMPLE five
Corresponding to the chain code management method of the federation chain described in the foregoing embodiment, fig. 5 shows a block diagram of a chain code management apparatus of the federation chain provided in the embodiment of the present application, where the chain code management apparatus 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, and for convenience of explanation, only the part related to the embodiment of the present application is shown. The apparatus 500 for managing chain code of federation chain includes:
the analysis module 501 is configured to, when receiving a request instruction for performing a corresponding operation on a chain code by a peer node, analyze the request instruction;
the calling module 502 is configured to intercept calling of a Docker interface corresponding to the Docker container management module when the request instruction is analyzed to be not a request instruction constructed by a chain code mirror image, and call a K8s interface corresponding to the K8s container management module;
an operation module 503, configured to execute a chain code container operation corresponding to the request instruction through the K8s interface, where the chain code container operation includes creating a chain code container, configuring a chain code container, or deleting a chain code container.
In one embodiment, the chain code management apparatus 500 of the federation chain further includes:
the mirror image analysis module is used for constructing a mirror image based on the Docker container management module when the request instruction is analyzed to be the request instruction constructed by the chain code mirror image;
and the pushing module is used for pushing the constructed mirror image to a preset mirror image warehouse.
In one embodiment, the calling module 502 includes a first calling unit, configured to intercept a call of a Docker creation interface corresponding to the Docker container management module when the request instruction is analyzed as a request instruction created by a chain code container, and call the K8s creation interface;
correspondingly, the operation module comprises a first operation unit, which is used for executing the chain code container creation operation through the K8s creation interface.
In an embodiment, the calling module 502 includes a second calling unit, configured to intercept calling of a Docker configuration interface corresponding to the Docker container management module when the request instruction is analyzed as a request instruction configured by a chain code container, and call a configuration mapping creation interface of k8 s;
correspondingly, the operation module comprises a second operation unit for executing the chain code container configuration operation through the configuration mapping creation interface of the k8 s.
In an embodiment, the calling module 502 includes a second calling unit, configured to intercept calling of a Docker deletion interface corresponding to the Docker container management module when the request instruction is analyzed as a request instruction for deleting a chain code container, and call a K8s deletion interface;
correspondingly, the operation module comprises a second operation unit for executing chain code container deletion operation through the K8s deletion interface.
In one embodiment, the first operation unit includes:
the acquisition subunit is used for acquiring a target mirror image corresponding to the container creation from a preset mirror image warehouse;
and the creating subunit is used for executing a chain code container creating operation through the K8s creating interface according to the target image.
In one embodiment, the first operation unit further includes:
a mirror image construction subunit, configured to, before executing a link container creation operation through the K8s creation interface according to the target mirror image, construct the target mirror image based on the Docker container management module if a target mirror image corresponding to the container creation is not acquired from a preset mirror image warehouse.
In one embodiment, the chain code management apparatus 500 of the federation chain further includes:
the certificate acquisition module is used for acquiring a certificate file corresponding to the chain code;
and the certificate uploading module is used for uploading the certificate file to the created chain code container.
When the request instruction is not the request instruction constructed by the chain code mirror image, the call of the Docker interface corresponding to the Docker container management module is intercepted first, the source code of the chain code Docker control part in the peer node in the chain code cannot be changed, the call is only carried out, and then the chain code container operation corresponding to the request instruction is executed by the K8s interface corresponding to the K8s container management module, so that the source code of the chain code Docker control part is not required to be changed, errors are not easy to occur, the operation is simple through interception, the K8s management container can be simply and conveniently combined, and the reliability of container management corresponding to the chain code is improved.
EXAMPLE six
As shown in fig. 6, an 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 said memory 602 and executable on said processor 601. The steps of the chain code management method of the federation chain in the above embodiment are implemented when the computer program 603 is executed by the processor 601.
Illustratively, the computer program 603 may be partitioned into one or more modules that are stored in the memory 602 and executed by the processor 601 to implement the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which 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 an analysis module, a call module, an operation module, and the like, and specific functions of the modules are described in the foregoing embodiments, which are not described herein again.
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 notebook computer, 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, a memory 602. Those skilled in the art will appreciate that fig. 6 is merely an example of a terminal device 600 and does not constitute a limitation of terminal device 600 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the terminal device may also include input-output devices, network access devices, buses, etc.
The Processor 601 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 602 may be an internal storage unit of the terminal device 600, such as a hard disk or a 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 memory Card (Flash Card), and the like, which are provided on the terminal device 600. Further, the memory 602 may also include both an internal storage unit and an external storage device of the terminal device 600. The memory 602 is used for storing the computer programs 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.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated module, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A chain code management method of a alliance chain is applied to a chain code management system, the chain code management system comprises a Docker container management module created based on Docker container technology, the chain code management system is characterized by comprising a K8s container management module based on K8s container technology, and the method comprises the following steps:
when a request instruction for performing corresponding operation on the chain code by a peer node is received, analyzing the request instruction;
when the request instruction is analyzed to be not the request instruction constructed by the chain code mirror image, intercepting the calling of a Docker interface corresponding to the Docker container management module, and calling a K8s interface corresponding to the K8s container management module;
and executing a chain code container operation corresponding to the request instruction through the K8s interface, wherein the chain code container operation comprises the creation of a chain code container, the configuration of the chain code container or the deletion of the chain code container.
2. The chain code management method according to claim 1, further comprising, after parsing the request command:
when the request instruction is analyzed to be a request instruction constructed by a chain code mirror image, constructing the mirror image based on the Docker container management module;
and pushing the constructed mirror image to a preset mirror image warehouse.
3. The chain code management method according to claim 1, wherein when the request instruction that is not constructed for a chain code image is analyzed, intercepting a call of a Docker interface corresponding to the Docker container management module, and calling a K8s interface corresponding to the K8s container management module includes:
when the request instruction is analyzed to be the request instruction created by the chain code container, intercepting the call of a Docker creation interface corresponding to the Docker container management module, and calling the K8s creation interface;
correspondingly, the executing, through the K8s interface, a chain code container operation corresponding to a request instruction includes:
and executing a chain code container creation operation through the K8s creation interface.
4. The chain code management method according to claim 1, wherein when the request instruction that is not constructed for a chain code image is analyzed, intercepting a call of a Docker interface corresponding to the Docker container management module, and calling a K8s interface corresponding to the K8s container management module includes:
when the request instruction is analyzed to be the request instruction configured by the chain code container, intercepting the call of a Docker configuration interface corresponding to the Docker container management module, and calling a configuration mapping creation interface of k8 s;
correspondingly, the executing, through the K8s interface, a chain code container operation corresponding to a request instruction includes:
and executing chain code container configuration operation through the configuration mapping creation interface of the k8 s.
5. The chain code management method according to claim 1, wherein when the request instruction that is not constructed for a chain code image is analyzed, intercepting a call of a Docker interface corresponding to the Docker container management module, and calling a K8s interface corresponding to the K8s container management module includes:
intercepting the call of a Docker deleting interface corresponding to the Docker container management module and calling a K8s deleting interface when the request instruction is analyzed to be a request instruction for deleting the chain code container;
correspondingly, the executing, through the K8s interface, a chain code container operation corresponding to a request instruction includes:
and executing chain code container deleting operation through the K8s deleting interface.
6. The chain code management method according to claim 3, wherein said performing a chain code container creation operation through said K8s creation interface comprises:
acquiring a target mirror image corresponding to the container creation from a preset mirror image warehouse;
and according to the target image, performing chain code container creation operation through the K8s creation interface.
7. The chain code management method according to claim 6, wherein before executing the chain code container creation operation through the K8s creation interface according to the target image, the method further comprises:
and if the target mirror image corresponding to the container creation is not acquired from a preset mirror image warehouse, constructing the target mirror image based on the Docker container management module.
8. The chain code management method according to claim 6, further comprising:
acquiring a certificate file corresponding to the chain code;
and uploading the certificate file to the created chain code container.
9. A chain code management device of a alliance chain is applied to a chain code management system, the chain code management system comprises a Docker container management module created based on Docker container technology, the chain code management system comprises a K8s container management module based on K8s container technology, and the device comprises:
the analysis module is used for analyzing the request instruction when receiving the request instruction of the peer node for carrying out corresponding operation on the chain code;
the calling module is used for intercepting the calling of a Docker interface corresponding to the Docker container management module and calling a K8s interface corresponding to the K8s container management module when the request instruction which is not constructed by the chain code mirror image is analyzed;
and the operation module is used for executing chain code container operation corresponding to the request instruction through the K8s interface, wherein the chain code container operation comprises the creation of a chain code container, the configuration of the chain code container or the deletion operation of the chain code container.
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 the processor implements the method according to any of claims 1 to 8 when executing the computer program.
CN202111246219.6A 2021-10-26 2021-10-26 Chain code management method and device of alliance chain and terminal equipment Pending CN114020403A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111246219.6A CN114020403A (en) 2021-10-26 2021-10-26 Chain code management method and device of alliance chain and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111246219.6A CN114020403A (en) 2021-10-26 2021-10-26 Chain code management method and device of alliance chain and terminal equipment

Publications (1)

Publication Number Publication Date
CN114020403A true CN114020403A (en) 2022-02-08

Family

ID=80057557

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111246219.6A Pending CN114020403A (en) 2021-10-26 2021-10-26 Chain code management method and device of alliance chain and terminal equipment

Country Status (1)

Country Link
CN (1) CN114020403A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023185058A1 (en) * 2022-03-30 2023-10-05 蚂蚁区块链科技(上海)有限公司 Method and system for deploying chain code in consortium blockchain

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023185058A1 (en) * 2022-03-30 2023-10-05 蚂蚁区块链科技(上海)有限公司 Method and system for deploying chain code in consortium blockchain

Similar Documents

Publication Publication Date Title
CN108629029B (en) Data processing method and device applied to data warehouse
CN109508326B (en) Method, device and system for processing data
US9971819B2 (en) Using cloud processing to integrate ETL into an analytic reporting mechanism
US20200278975A1 (en) Searching data on a synchronization data stream
CN111598575A (en) Business process control method and device, electronic equipment and readable storage medium
CN112685499A (en) Method, device and equipment for synchronizing process data of work service flow
CN113760722A (en) Test system and test method
CN114020403A (en) Chain code management method and device of alliance chain and terminal equipment
CN113836237A (en) Method and device for auditing data operation of database
CN110795331A (en) Software testing method and device
CN113378093A (en) Method and device for determining resource release strategy, electronic equipment and storage medium
CN112948467A (en) Data processing method and device, computer equipment and storage medium
CN112433757A (en) Method and device for determining interface calling relationship
CN110244951A (en) Using dissemination method and device
CN112947907A (en) Method for creating code branch
CN113157405A (en) Method and device for retrying breakpoint of business process
AU2021268828B2 (en) Secure data replication in distributed data storage environments
CN109495575B (en) Service configuration method, system and ERP server
CN113806327A (en) Database design method and device and related equipment
CN112764897A (en) Method, device and system for processing task request and computer readable storage medium
CN110019445B (en) Data synchronization method and device, computing equipment and storage medium
CN107256240B (en) Response method and system for distributed file service
CN118192897A (en) Data storage system, method and device
CN115905148A (en) Construction data receiving and sending method, device, equipment and storage medium
CN114490583A (en) Data migration method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination