A state machine-based alliance chain construction method and system

By using a state machine-based consortium blockchain construction method, anomalies are monitored and handled, enabling progress management and state recovery of the consortium blockchain creation process. This solves the problem of low construction efficiency in existing technologies and improves user experience.

CN116842097BActive Publication Date: 2026-02-06GLODON CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210306209.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-25
Publication Date
2026-02-06
Estimated Expiration
2042-03-25

AI Technical Summary

Technical Problem

In existing technologies, when enterprises build blockchains, especially Fabric consortium blockchains, the deployment process is complex and time-consuming, and communication connection loss and abnormal events are prone to occur. This can lead to the loss of execution state after operation is interrupted, making it impossible to restart and continue execution, which affects the construction efficiency and user experience.

Method used

A state machine-based consortium blockchain construction method is adopted. The creation information is obtained through the first state machine, commands are sent to the second state machine, and a monitoring task is built to monitor the progress. When an exception occurs, an exception message is generated, the exception handling sub-state machine is called to handle it, and the state progress is saved for process recovery.

Benefits of technology

It enables progress monitoring and management of the consortium blockchain creation process, shortens user waiting time, improves construction efficiency and user experience, and reminds users of abnormal handling through state machine to ensure smooth process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116842097B_ABST
    Figure CN116842097B_ABST
Patent Text Reader

Abstract

The application provides a state machine-based alliance chain construction method and system. The method is applied to a first state machine corresponding to an alliance creator, and creation information of a target alliance chain submitted by the alliance creator is acquired. Based on the creation information, corresponding commands are sent to second state machines corresponding to each alliance organizer according to an alliance chain creation process. A listening task is constructed to monitor the alliance state progress changed after the second state machine executes the corresponding commands in the alliance chain creation process, and the alliance state progress of the listening task is changed according to the alliance state progress of the second state machine until the alliance chain creation process ends, and the construction of the target alliance chain is completed. By changing the alliance state progress by using the state machine, the progress monitoring and management in the entire creation process of the alliance chain are realized, which is beneficial to resuming the creation work of the alliance chain on the basis of the original alliance state after the exception is removed, shortens the waiting time of the user, and improves the alliance chain construction efficiency and the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of blockchain, in particular to a state machine-based consortium chain construction method and system, BACKGROUND

[0002] With the development of blockchain technology, more and more enterprises are trying to apply blockchain in their industry. The first problem enterprises face in application landing is how to build a blockchain. At present, the blockchain commonly used by enterprises is fabric consortium chain. Its deployment process is complex and tedious, and the dependency relationship between components is complex, which is very prone to problems. Enterprises need high technical ability and learning cost, which to some extent increases the threshold for enterprises to enter. Therefore, automatic means are needed to assist enterprises in building consortium chains. The common way at present is to use commercial blockchain services (BaaS).

[0003] However, many steps in the construction of the consortium chain, such as node startup and channel creation, are executed asynchronously and take a long time, which can cause communication connection loss and abnormal events. The existing BaaS method does not manage the stage state of the execution process, which causes the execution state to be lost after the operation is interrupted, and the execution cannot continue. It can only be executed from the beginning, which causes the customer to wait for twice the time, thereby greatly affecting the construction efficiency of the consortium chain and affecting the user experience. SUMMARY

[0004] Therefore, the embodiments of the present application provide a state machine-based consortium chain construction method and system to solve the problem that the existing technology cannot manage the stage state of the execution process when building a consortium chain through BaaS, which causes the execution state to be lost after the operation is interrupted and the execution cannot continue.

[0005] According to a first aspect, the embodiments of the present application provide a state machine-based consortium chain construction method applied to a first state machine corresponding to a consortium creator, which comprises:

[0006] Obtaining the creation information of the target consortium chain submitted by the consortium creator;

[0007] Based on the creation information, sending corresponding commands to the second state machine corresponding to each consortium organizer according to the consortium chain creation process;

[0008] Constructing a monitoring task to monitor the consortium state progress changed by the second state machine after executing the corresponding command in the consortium chain creation process, and changing its own consortium state progress according to the consortium state progress of the second state machine until the consortium chain creation process ends, completing the construction of the target consortium chain.

[0009] Optionally, the method further comprises:

[0010] When the monitoring task in the alliance chain creation process detects an exception, an exception message is generated;

[0011] The exception message is sent to an exception handling sub-state machine to call the exception handling sub-state machine to process the exception message.

[0012] Optionally, the commands include: an alliance invitation command, an identity information generation command, a node start command, and a channel joining command, the monitoring task monitors the alliance state progress changed after the execution of each command by the second state machine in the alliance chain creation process, and changes its own alliance state progress according to the alliance state progress of the second state machine, including:

[0013] The first monitoring task monitors the execution result of the alliance invitation command of the second state machine, and changes the alliance state of the first state machine to an organization invited state when it is monitored that a preset number of second state machines accept the alliance invitation and enter an alliance invitation accepted state;

[0014] The second monitoring task monitors the execution result of the identity information generation command of the second state machine, and changes the alliance state of the first state machine to an alliance identity information ready state when it is monitored that all second state machines corresponding to the alliance organizers accepting the invitation generate identity information and enter an identity information generated state;

[0015] The third monitoring task monitors the execution result of the node start command of the second state machine, and changes the alliance state of the first state machine to an alliance node ready state when it is monitored that all nodes of all second state machines corresponding to the alliance organizers accepting the invitation are started and enter a node started state;

[0016] The fourth monitoring task monitors the execution result of the channel joining command of the second state machine, and changes the alliance state of the first state machine to an alliance constructed state when it is monitored that all second state machines corresponding to the alliance organizers accepting the invitation have joined the channel and enter a channel joined state.

[0017] Optionally, the method further includes:

[0018] Sending an alliance chain construction process end notification to the second state machines joining the target alliance chain, so that each second state machine changes its own alliance state to an alliance constructed state.

[0019] According to a second aspect, an embodiment of the present application provides an alliance chain construction method based on a state machine, applied to a second state machine corresponding to an alliance organizer, and the method includes:

[0020] Receiving a command sent by a first state machine corresponding to an alliance creator;

[0021] execute the command, and change the alliance state progress of the self according to the execution result of the command;

[0022] send the alliance state progress of the self to the first state machine.

[0023] Optionally, the method further comprises:

[0024] generating an exception message when an exception occurs in the alliance chain creation process;

[0025] sending the exception message to an exception handling sub-state machine to call the exception handling sub-state machine to process the exception message;

[0026] when the second state machine is set to an exception state by the exception handling sub-state machine, sending the exception state to the first state machine.

[0027] According to a third aspect, an embodiment of the present application provides a state machine-based alliance chain construction method applied to an exception handling sub-state machine, and the method comprises:

[0028] receiving an exception message sent by a first state machine corresponding to an alliance creator or a second state machine corresponding to any alliance organizer after an exception occurs in an alliance chain creation process;

[0029] changing the sub-state of the self to an exception receiving state based on the exception message, and judging whether the exception message affects the change of the alliance state progress of the first state machine and each second state machine;

[0030] when the exception message affects the change of the alliance state progress of the first state machine and / or the second state machine, setting the first state machine and / or the second state machine affected by the exception message to an exception state, changing the sub-state of the self to the exception state, saving the current alliance state progress of the first state machine and / or the second state machine, and suspending the alliance creation process by the first state machine and / or the second state machine in the exception state.

[0031] Optionally, when the first state machine and / or the second state machine are in the exception state, the method further comprises:

[0032] monitoring whether the exception message is eliminated within a predetermined time;

[0033] if the exception message is eliminated within the predetermined time, changing the sub-state of the self to an end state;

[0034] if the exception message is not eliminated within the predetermined time, changing the sub-state of the self to a manual processing state to notify manual exception handling.

[0035] Optionally, when the first state machine or the second state machine is in an abnormal state, the method further comprises:

[0036] periodically monitoring whether the submachine state of the abnormal processing substate machine changes to an end state;

[0037] when it is monitored that the submachine state of the abnormal processing substate machine changes to the end state, resuming the current alliance state progress of the first state machine and / or the second state machine based on the current alliance state progress of the first state machine and / or the second state machine, so that the first state machine and / or the second state machine continue to execute the alliance creation process on the basis of the current alliance state progress.

[0038] Optionally, the method further comprises:

[0039] when the abnormal message does not affect the change of the alliance state of the first state machine and each second state machine, changing the submachine state to the end state, and sending the abnormal message to the abnormal queue.

[0040] According to a fourth aspect, an embodiment of the present application provides a state machine-based alliance chain construction system, comprising: an abnormal processing substate machine, a first state machine corresponding to an alliance creator, and a second state machine corresponding to each alliance organizer, wherein,

[0041] the first state machine is configured to obtain creation information of a target alliance chain submitted by the alliance creator, and send corresponding commands to the second state machine corresponding to each alliance organizer according to an alliance chain creation process based on the creation information;

[0042] the second state machine is configured to receive the commands sent by the first state machine corresponding to the alliance creator, execute the commands, change the alliance state progress of the second state machine according to the execution result of the commands, and send the alliance state progress of the second state machine to the first state machine;

[0043] the first state machine is further configured to construct a listening task to monitor the alliance state progress changed by the second state machine after executing the corresponding commands in the alliance chain creation process, and change the alliance state progress of the first state machine according to the alliance state progress of the second state machine, until the alliance chain creation process ends and the construction of the target alliance chain is completed;

[0044] The abnormality processing sub-state machine is used for receiving an abnormality message sent by the first state machine corresponding to the alliance creator or the second state machine corresponding to any alliance organizer after an abnormality occurs in the alliance chain creation process; the abnormality message sent after the abnormality occurs in the alliance chain creation process; based on the abnormality message, the sub-machine state of the abnormality processing sub-state machine is changed to an abnormality receiving state, and it is judged whether the abnormality message affects the change of the alliance state progress of the first state machine and each second state machine; when the abnormality message affects the change of the alliance state progress of the first state machine and / or the second state machine, the first state machine and / or the second state machine affected by the abnormality message are placed in an abnormality state, the sub-machine state of the abnormality processing sub-state machine is changed to an abnormality state, and the current alliance state progress of the first state machine and / or the second state machine is saved; the first state machine and / or the second state machine in the abnormality state suspends the alliance creation process.

[0045] According to a fifth aspect, an embodiment of the present application provides a computer readable storage medium, the computer readable storage medium stores computer instructions, and the computer instructions are executed by a processor to implement the method in the first aspect and any optional manner thereof.

[0046] According to a sixth aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, which are connected in communication with each other, the memory stores computer instructions, and the processor executes the computer instructions to implement the method in the first aspect and any optional manner thereof.

[0047] The technical scheme of the present application has the following advantages:

[0048] 1.The embodiment of the present application provides a state machine-based alliance chain construction method, which is applied to a first state machine corresponding to an alliance creator, and the method comprises the following steps: obtaining creation information of a target alliance chain submitted by the alliance creator; sending corresponding commands to second state machines corresponding to each alliance organizer according to an alliance chain creation process based on the creation information; constructing a monitoring task to monitor alliance state progress changed after the second state machines execute corresponding commands in the alliance chain creation process, and changing the alliance state progress of the first state machine according to the alliance state progress of the second state machines until the alliance chain creation process ends, and the construction of the target alliance chain is completed. Thus, the alliance state progress of the first state machine is changed by constructing the monitoring task to monitor the alliance state progress changed after the second state machines execute corresponding commands in the alliance chain creation process, so that progress monitoring and management of the alliance organizers in the entire creation process of the alliance chain is realized. When an exception occurs in the alliance chain creation process, the creation stage of the alliance chain can be understood by using the alliance state progress of the first state machine and the second state machines, which is beneficial to resuming the creation work of the alliance chain on the basis of the original alliance state progress after the exception is removed, so that the waiting time of the user can be effectively reduced, the construction efficiency of the alliance chain is improved, and the use experience of the user is improved.

[0049] 2.The embodiment of the present application provides a state machine-based alliance chain construction method, which is applied to a second state machine corresponding to an alliance organizer, and the method comprises the following steps: receiving a command sent by a first state machine corresponding to an alliance creator; executing the command, and changing the alliance state progress of the second state machine according to the execution result of the command; and sending the alliance state progress of the second state machine to the first state machine. Thus, the alliance state progress is changed by using the state machine to change the alliance state progress according to the execution result of each command sent by the first state machine corresponding to the alliance creator, so that progress monitoring and management of the alliance organizers in the entire creation process of the alliance chain is realized. When an exception occurs in the alliance chain creation process, the creation stage of the alliance chain can be understood by using the alliance state progress of the second state machine, which is beneficial to resuming the creation work of the alliance chain on the basis of the original alliance state progress after the exception is removed, so that the waiting time of the user can be effectively reduced, the construction efficiency of the alliance chain is improved, and the use experience of the user is improved.

[0050] 3. The embodiment of the present application provides a state machine-based alliance chain construction method, which is applied to an exception processing sub-state machine, receives an exception message sent by a first state machine corresponding to an alliance creator or a second state machine corresponding to any alliance organizer after an exception occurs in an alliance chain creation process, changes a sub-machine state of the embodiment into an exception receiving state based on the exception message, and judges whether the exception message affects a change of an alliance state progress of the first state machine and each second state machine; when the exception message affects the change of the alliance state progress of the first state machine and / or the second state machine, the first state machine and / or the second state machine affected by the exception message is set into an exception state, the sub-machine state of the embodiment is changed into an exception state, and a current alliance state progress of the first state machine and / or the second state machine is saved; and the first state machine and / or the second state machine in the exception state suspends the alliance creation process. Thus, the state machine is used to process the exception message occurring in the alliance chain creation process, and when the exception message affects the state machine corresponding to the alliance creator or the organizer, the state machine in the exception is set into the exception state to suspend the alliance chain creation process, and the corresponding alliance state progress is saved, so that the creation stage of the alliance chain is known, and the creation work of the alliance chain can be resumed on the basis of the original alliance state progress after the exception is removed, thereby effectively reducing the waiting time of the user, improving the construction efficiency of the alliance chain, and further improving the use experience of the user; and the reminding of the sub-machine state of the embodiment is beneficial to the user to know the running situation of the alliance chain creation process and timely remind the user to process the exception.

[0051] 4. The embodiment of the present application provides a state machine-based alliance chain construction system, which comprises an exception processing sub-state machine, a first state machine corresponding to an alliance creator and a second state machine corresponding to each alliance organizer, wherein the first state machine is used for obtaining creation information of a target alliance chain submitted by the alliance creator; based on the creation information, corresponding commands are sent to the second state machine corresponding to each alliance organizer according to an alliance chain creation process; the second state machine is used for receiving the commands sent by the first state machine corresponding to the alliance creator; the second state machine is used for executing the commands and changing the alliance state progress of the second state machine according to the execution result of the commands; the second state machine is used for sending the alliance state progress of the second state machine to the first state machine; the first state machine is further used for constructing a monitoring task to monitor the alliance state progress changed by the second state machine after the second state machine executes the corresponding commands in the alliance chain creation process, and changing the alliance state progress of the first state machine according to the alliance state progress of the second state machine until the alliance chain creation process ends and the construction of the target alliance chain is completed; the exception processing sub-state machine is used for receiving an exception message sent by the first state machine corresponding to the alliance creator or the second state machine corresponding to any alliance organizer after an exception occurs in the alliance chain creation process; the exception processing sub-state machine is used for sending the exception message after the exception occurs in the alliance chain creation process; based on the exception message, the sub-state machine state of the exception processing sub-state machine is changed to an exception receiving state, and it is judged whether the exception message affects the change of the alliance state progress of the first state machine and the second state machines; when the exception message affects the change of the alliance state progress of the first state machine and / or the second state machine, the first state machine and / or the second state machine affected by the exception message are set to an exception state, the sub-state machine state of the exception processing sub-state machine is changed to the exception state, and the current alliance state progress of the first state machine and / or the second state machine is saved, and the first state machine and / or the second state machine in the exception state suspend the alliance creation process. Thus, the creation of the alliance chain is realized by using the state machine, the progress monitoring and management in the entire creation process of the alliance chain are realized by changing the alliance state progress of the alliance chain participants in the creation process of the alliance chain by using the state machine, when an exception occurs in the alliance chain creation process, the exception message is processed by using the state machine, and when the exception message affects the state machine corresponding to the alliance creator or the organizer, the state machine in the exception state is set to the exception state to suspend the alliance chain creation process of the state machine, and the creation stage of the alliance chain is understood by saving the corresponding alliance state progress, which is beneficial to resuming the creation of the alliance chain on the basis of the original alliance state progress after the exception is removed, so that the waiting time of the user can be effectively reduced, the construction efficiency of the alliance chain is improved, the use experience of the user is improved, and the running situation of the alliance chain creation process is understood by the reminding of the sub-state machine state, so that the user can be reminded to handle the exception in time. BRIEF DESCRIPTION OF DRAWINGS

[0052] In order to more clearly illustrate the technical solutions in the specific embodiments of the present application or the prior art, the drawings needed to be used in the specific embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0053] Figure 1 The structural schematic diagram of the alliance chain construction system based on the state machine in the embodiment of the present application is shown in the figure.

[0054] Figure 2 The flowchart of the alliance chain construction method based on the state machine in the embodiment of the present application is shown in the figure.

[0055] Figure 3 Another flowchart of the alliance chain construction method based on the state machine in the embodiment of the present application is shown in the figure.

[0056] Figure 4 Still another flowchart of the alliance chain construction method based on the state machine in the embodiment of the present application is shown in the figure.

[0057] Figure 5 The structural schematic diagram of the electronic device in the embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0058] The technical solutions of the present application will be described clearly and completely in combination with the drawings. Obviously, the described embodiments are some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0059] In addition, the technical features involved in different embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.

[0060] Since the construction of the alliance chain needs a series of complex pre-operations: creation of alliance information, organization invitation and confirmation, MSP application of organization and its nodes, dynamic rendering of alliance chain configuration information, node startup, genesis file creation, channel creation, node joining channel, etc. Many steps in the construction of the alliance chain, such as node startup, channel creation, are executed asynchronously and take a long time, which will cause communication connection loss and abnormal events. The existing BaaS method does not manage the stage state during execution, which leads to the fact that after the operation is interrupted, it cannot be restarted and continued to execute because of the loss of its execution state, and it can only be executed from the beginning.

[0061] Based on the above problems, the embodiment of the present application provides an alliance chain construction system based on a state machine, as shown in Figure 1As shown, the state machine-based alliance chain construction system includes:

[0062] The abnormality processing sub-state machine, the first state machine corresponding to the alliance creator, and the second state machine corresponding to each alliance organizer, wherein the first state machine is configured to obtain the creation information of the target alliance chain submitted by the alliance creator; send corresponding commands to the second state machine corresponding to each alliance organizer according to the creation information according to the alliance chain creation process; the second state machine is configured to receive the commands sent by the first state machine corresponding to the alliance creator; execute the commands, and change the alliance state progress of the second state machine according to the execution result of the commands; send the alliance state progress of the second state machine to the first state machine; the first state machine is further configured to monitor the alliance state progress changed by the second state machine after executing the corresponding commands in the alliance chain creation process through a listening task, and change the alliance state progress of the first state machine according to the alliance state progress of the second state machine until the end of the alliance chain creation process, and complete the construction of the target alliance chain; the abnormality processing sub-state machine is configured to receive the exception messages sent by the first state machine corresponding to the alliance creator or the second state machine corresponding to any alliance organizer after an exception occurs in the alliance chain creation process; send the exception messages after an exception occurs in the alliance chain creation process; change the sub-state machine state of the abnormality processing sub-state machine to an abnormality receiving state based on the exception messages, and determine whether the exception messages affect the change of the alliance state progress of the first state machine and the second state machines; when the exception messages affect the change of the alliance state progress of the first state machine and / or the second state machines, set the first state machine and / or the second state machines affected by the exception messages to an abnormality state, change the sub-state machine state of the abnormality processing sub-state machine to an abnormality state, save the current alliance state progress of the first state machine and / or the second state machines, and suspend the alliance creation process of the first state machine and / or the second state machines in the abnormality state.

[0063] The creator of the alliance chain and the organizers of each alliance chain, i.e., the participants, are each correspondingly provided with a state machine, and one alliance chain creator and a plurality of alliance chain organizers are required in the construction of each alliance chain, and the number of alliance chain organizers is defined by the alliance chain creator according to the creation demand of the alliance chain, and the present application is not limited thereto. In the following, the first state machine corresponding to the alliance creator is referred to as the alliance creator state machine, and the second state machine corresponding to each alliance chain organizer is referred to as the alliance organizer state machine. The alliance creator state machine and the alliance organizer state machine interact with each other, and both of them are nested with the abnormality processing sub-state machine. For further description of the first state machine, the second state machine, and the abnormality processing state machine, refer to the related description of the method embodiment in the following, which will not be described here.

[0064] Specifically, the alliance creator state machine is a centralized construction idea, responsible for coordinating the execution of the construction operation of each alliance organization state machine and being responsible for the final alliance construction result; the alliance organization state machine is responsible for managing the organization member permissions and receiving the alliance creator instruction to execute the construction request on the server component and generate the corresponding configuration file; the exception handling sub-state machine is responsible for unified processing of the failure of the above two operations, and thanks to the construction mode of the double state machines of the alliance creator state machine and the alliance organization state machine, the exception handling sub-state machine can decide to suspend the state of the alliance creator state machine or a single alliance organization state machine, that is, to set the working state to an abnormal state, and support the corresponding alliance state progress to be restored after the exception problem is solved.

[0065] Through the cooperation of the above-mentioned components, the alliance chain construction system based on the state machine provided by the embodiment of the application realizes the creation of the alliance chain by using the state machine, and realizes the progress monitoring and management in the entire creation process of the alliance chain by changing the alliance state progress of the alliance chain participants in the creation process of the alliance chain by using the state machine. When an exception occurs in the creation process of the alliance chain, the state machine is used to process the exception message, and when the exception message affects the corresponding state machine of the alliance creator or the organizer, the abnormal state machine is set to an abnormal state to suspend the alliance chain creation process, and the corresponding alliance state progress is saved to understand the creation stage of the alliance chain, which is beneficial to the recovery of the creation work of the alliance chain on the basis of the original alliance state progress after the exception is resolved, thereby effectively reducing the user waiting time, improving the construction efficiency of the alliance chain, and further improving the user experience. Through the reminder of the state of the sub-machine, the user can understand the running situation of the alliance chain creation process and timely remind the user to handle the exception.

[0066] The embodiment of the application also provides an alliance chain construction method based on a state machine, which is applied to the alliance chain construction system based on the state machine as shown in Figure 1 The first state machine is used to execute steps S101 to S103, and the second state machine is used to execute steps S201 to S203, as shown in Figure 2 The first state machine is used to execute steps S101 to S103, and the second state machine is used to execute steps S201 to S203, as shown in Figure 3 The alliance chain construction method based on the state machine specifically includes the following steps:

[0067] Step S101: Obtain the creation information of the target alliance chain submitted by the alliance creator.

[0068] Specifically, the alliance creator administrator and each alliance organizer administrator prepare the initialized host resources in advance, and then the alliance creator sends the basic information, configuration information, and each member organization information and node configuration required for creating the alliance to the first state machine for storage.

[0069] Step S102: sending a corresponding command to each second state machine corresponding to the alliance organizer based on the creation information according to the alliance chain creation process.

[0070] Specifically, the creation information contains information of the second state machine corresponding to the alliance organization member that the alliance chain intends to join, and then the second state machine is interacted with the instruction according to the alliance chain creation process.

[0071] Step S201: receiving the command sent by the first state machine corresponding to the alliance creator.

[0072] The commands in the entire alliance chain creation process include: alliance invitation command, identity information generation command, node startup command, channel joining command, etc.

[0073] Step S202: executing the command, and changing the alliance state progress of itself according to the execution result of the command.

[0074] The alliance state progress of the alliance organizer corresponding to the above-mentioned command includes: invited state, identity information generated state, node started state, channel joined state, etc.

[0075] Step S203: sending the alliance state progress of itself to the first state machine.

[0076] Step S103: constructing a listening task to monitor the alliance state progress changed by the second state machine after executing the corresponding command in the alliance chain creation process, and changing the alliance state progress of itself according to the alliance state progress of the second state machine, until the alliance chain creation process ends, and the construction of the target alliance chain is completed.

[0077] The creation process of the alliance chain will be described in detail below in combination with the entire alliance chain creation process.

[0078] First, the first state machine, i.e. the alliance creator state machine, sends a join alliance invitation command to all organization members participating in the construction of the alliance chain. After receiving the invitation, the alliance organizer state machine enters the invited confirmation state and waits for the administrator of the alliance organizer to process the invitation information. At this time, the administrator has three processing methods: acceptance, rejection and long-time processing leading to timeout. After accepting the invitation, the alliance organizer state machine enters the invitation accepted state; after rejecting the invitation, the alliance organizer state machine enters the invitation rejected state; after timeout, the alliance organizer state machine enters the invitation timeout state. The invitation rejected state or the invitation timeout state will indicate that the organization does not want to join this alliance, so that the alliance organizer state machine reaches the end state. In the invitation accepted state or the invitation rejected state, the alliance organizer state machine will send the invited feedback information, i.e. the alliance state progress of itself, to the alliance creator state machine.

[0079] At this time, the alliance creator state machine monitors the execution result of the alliance invitation command of the second state machine by constructing a first listening task, and changes the alliance state of the first state machine to an organization invited state after monitoring that a preset number of second state machines accept the alliance invitation. Illustratively, the alliance creator state machine starts the listening task by timing, and when it is detected that all invited organizations have accepted, rejected or timed out, the number of alliance members accepting the invitation is counted. If it is less than 2, the alliance construction condition is not established, and the final state of alliance construction cancellation is entered. Otherwise, the alliance creator state machine enters the organization invited state. Thereafter, the alliance creator only communicates and interacts with the invited organization members.

[0080] Then, in the organization invited state, the alliance creator state machine sends a generate identity information command to the alliance organizer state machine corresponding to the invited organization, and each alliance organizer state machine enters an identity information generation in state. Each alliance organizer node has and only has two types: a blockchain endorsement node and a blockchain ordering node, and the number of the two types of nodes has been specified by the alliance creator in the alliance invitation information. The alliance organizer state machine generates the identity information of the organization and the identity information of all its endorsement nodes and ordering nodes. After the identity information of the alliance organizer and its endorsement nodes and ordering nodes is generated, the alliance organizer enters an identity information generated state and feeds back the result to the alliance creator state machine.

[0081] At this time, the alliance creator state machine monitors the execution result of the generate identity information command of the second state machine by constructing a second listening task, and changes the alliance state of the first state machine to an alliance identity information ready state after monitoring that all alliance organizers corresponding to the second state machine that accept the invitation generate identity information and enter the identity information generated state. Illustratively, the alliance creator state machine starts the listening task by timing, and enters the alliance identity information ready state after detecting and confirming that all invited organizations have successfully generated identity information, and generates an alliance chain genesis block and sends a start node command to the alliance organizer state machine corresponding to each invited organization.

[0082] Then, the alliance organizer state machine corresponding to each invited organization receives the start node command and enters an organization node start in state, and the alliance organizer state machine starts all endorsement nodes and ordering nodes under the organization. After all nodes, all endorsement nodes and ordering nodes have been started, the alliance organizer state machine enters a node started state and feeds back the result to the alliance creator state machine.

[0083] At this time, the alliance creator state machine monitors the execution result of the start node command of the second state machine by constructing a third listening task, and after monitoring that all the alliance organizers corresponding to the second state machines of the alliance organizers who accept the invitation have all started and entered the node started state, the alliance state of the first state machine is changed to the alliance node ready state. Illustratively, the alliance creator state machine starts the constructed listening task at a fixed time, detects and confirms that all the alliance organizer state machines corresponding to the invited organization nodes have started and entered the alliance node ready state, and obtains the configuration information required for creating the channel file, and then creates the system channel file and the default application channel file, and then constructs a timing task to execute the create channel command. After the channel is successfully created, the alliance construction enters the channel created state, and sends a join channel command to the alliance organizer state machines corresponding to the invited organizations.

[0084] Then, the alliance organizer state machines corresponding to the invited organizations receive the join channel command and enter the organization joined channel state, and add the endorsement nodes to the channel. After the endorsement nodes are added to the channel, the alliance organizer state machine enters the joined channel state and feeds back the result to the alliance creator state machine.

[0085] At this time, the alliance creator state machine monitors the execution result of the join channel command of the second state machine by constructing a fourth listening task, and after monitoring that all the alliance organizers corresponding to the second state machines of the alliance organizers who accept the invitation have joined the channel and entered the joined channel state, the alliance state of the first state machine is changed to the alliance constructed state.

[0086] Then the alliance creator state machine sends an alliance chain construction process end notification to the second state machines that join the target alliance chain, so that each second state machine changes its own alliance state to the alliance constructed state.

[0087] Illustratively, the alliance creator state machine starts the constructed listening task at a fixed time, and when it detects that all the invited organizations have joined the channel and entered the alliance constructed state, it notifies each invited organization to set its own state to the alliance organization constructed state. At this time, the alliance creator state machine and the alliance organizer state machines of the invited organizations have completed the final state of this construction, and the creation of the alliance chain is completed.

[0088] Thus, the construction method based on the alliance state transition mode of the dual-state machine, i.e., the alliance creator state machine and the alliance organizer state machine, is more suitable for the complex alliance chain construction task with interactive complexity. The alliance state identifies the current construction phase of the alliance chain, which can effectively avoid the execution conflict between the construction tasks, is conducive to the simultaneous participation of each alliance chain organizer in the construction of multiple different alliance chains, realizes the synchronous construction of different alliance chains, and is conducive to the improvement of the system performance and the concurrent operation ability.

[0089] Specifically, in an embodiment, the consortium chain creator state machine described above is further configured to perform the following steps:

[0090] Step S104: When the task monitoring in the consortium chain creation process detects an exception, an exception message is generated.

[0091] The exception message includes the location of the exception, such as the exception location being in the consortium creator state machine and / or one or more consortium organizer state machines, and the exception message also includes the exception type, which can be divided into four categories: condition not met exception, server agent service exception, network request exception, and construction execution exception. For details, see the description of the exception handling sub-state machine below, which will not be described here.

[0092] Step S105: The exception message is sent to the exception handling sub-state machine to invoke the exception handling sub-state machine to process the exception message.

[0093] Specifically, in an embodiment, the consortium chain organizer state machine described above is further configured to perform the following steps:

[0094] Step S204: When an exception occurs in the consortium chain creation process, an exception message is generated.

[0095] Step S205: The exception message is sent to the exception handling sub-state machine to invoke the exception handling sub-state machine to process the exception message.

[0096] Step S206: When the second state machine is set to an exception state by the exception handling sub-state machine, the exception state is sent to the first state machine.

[0097] When the consortium organizer state machine is in an exception state, it will pause the consortium chain creation process, and by sending its exception state to the consortium creator state machine, the consortium creator state machine can determine whether the consortium chain creation process can continue, and if not, it will generate a corresponding exception message and send it to the exception handling state machine again to invoke it to process the exception message.

[0098] Thus, by sending an exception message from the consortium creator state machine and the consortium organizer state machine to invoke the exception handling sub-state machine to process the exception message, the exception condition in the consortium chain creation process is managed separately, and by using the state machine to manage the exception message, it is easy to monitor and manage the state of the exception condition, which is convenient for users to understand the exception condition in the consortium chain creation process in real time, and improves the user experience.

[0099] Through the cooperation of the above steps, the state machine-based alliance chain construction method provided by the embodiment of the application changes the alliance state progress of the second state machine corresponding to the alliance organizer after the alliance chain creation process related instructions are executed, to correspondingly change the alliance state progress of the first state machine, thereby achieving progress monitoring and management in the entire creation process of the alliance chain. When an exception occurs in the creation process of the alliance chain, the creation stage of the alliance chain can be understood by using the alliance state progress of the first state machine and the second state machine, which is beneficial to resuming the creation work of the alliance chain on the basis of the original alliance state progress after the exception is resolved, thereby effectively reducing the user waiting time, improving the construction efficiency of the alliance chain, and further improving the user experience.

[0100] The embodiment of the application further provides a state machine-based alliance chain construction method, which is applied to the state machine-based alliance chain construction method as shown in Figure 1 as shown in Figure 4 The state machine-based alliance chain construction method comprises the following steps:

[0101] Step S301: receiving an exception message sent by a first state machine corresponding to an alliance creator or a second state machine corresponding to any alliance organizer after an exception occurs in an alliance chain creation process.

[0102] The exception message is an exception message sent by the alliance creator state machine or the alliance organizer state machine, and runs through the entire alliance chain construction life cycle.

[0103] Step S302: changing the state of the sub-machine to an exception receiving state based on the exception message, and determining whether the exception message affects the change of the alliance state progress of the first state machine and each second state machine.

[0104] Specifically, when the exception message does not affect the change of the alliance state of the first state machine and each second state machine, the state of the sub-machine is changed to an end state, and the exception message is sent to an exception queue. In order to handle the exception separately later, without affecting the continuous execution of the current alliance chain construction process.

[0105] Step S303: when the exception message affects the change of the alliance state progress of the first state machine and / or the second state machine, setting the first state machine and / or the second state machine affected by the exception message to an exception state, changing the state of the sub-machine to an exception state, saving the current alliance state progress of the first state machine and / or the second state machine, and suspending the alliance creation process of the first state machine and / or the second state machine in the exception state.

[0106] For example, if the exception occurs in the alliance creator state machine, the alliance chain construction process of the alliance creator state machine is suspended, and the state of the alliance creator state machine is set to a suspended state, i.e., an exception state, but the alliance organizer state machines are not affected, and the operations that have been performed can continue to be executed, and after the execution is successful, the next command of the alliance creator state machine is waited for; if the exception occurs in the alliance organizer state machine, the alliance chain construction process of the alliance organizer state machine is suspended, and the state of the alliance organizer state machine is set to a suspended state, i.e., an exception state. At this time, the alliance chain construction process of the alliance creator state machine is not affected, and the operations that have been performed can continue to be executed. After the alliance organizer state machine is suspended, the suspended state is fed back to the alliance creator state machine, so that the alliance creator state machine cannot be transferred to the next alliance state, and then the alliance creator state machine also sends an exception message to the exception processing sub-state machine for exception message processing.

[0107] Specifically, in an embodiment, the above-mentioned exception processing sub-state machine is further used to perform the following steps when the first state machine and / or the second state machine is in an exception state:

[0108] Step S304: It is monitored whether the exception message is eliminated within a predetermined time.

[0109] Specifically, if the exception message is eliminated within the predetermined time, the state of the sub-machine of the exception processing sub-state machine is changed to an end state; if the exception message is not eliminated within the predetermined time, the state of the sub-machine of the exception processing sub-state machine is changed to a manual processing state, so as to notify manual exception processing.

[0110] Step S305: It is periodically monitored whether the state of the sub-machine of the exception processing sub-state machine is changed to the end state.

[0111] Step S306: When it is monitored that the state of the sub-machine of the exception processing sub-state machine is changed to the end state, the current alliance state progress of the first state machine and / or the second state machine is restored based on the current alliance state progress of the first state machine and / or the second state machine, so that the first state machine and / or the second state machine continue to execute the alliance creation process on the basis of the current alliance state progress.

[0112] Specifically, when the alliance creator state machine or the alliance organizer state machine is in a suspended state, the exception processing sub-state machine cyclically checks the state of the sub-machine of the exception processing sub-state machine, if the state of the sub-machine is ended, the alliance creator state machine or the alliance organizer state machine is re-set to an execution state according to the alliance state progress information saved by the exception processing sub-state machine, so that the alliance creator state machine or the alliance organizer state machine can continue to perform the alliance chain creation process on the basis of the original alliance state.

[0113] The following will be combined with 4 large categories of specific exception types: conditional exceptions, server agent service exceptions, network request exceptions and construction execution exceptions, and the specific execution process of the exception handling sub-state machine will be described in detail.

[0114] Conditional exceptions indicate that the conditions required for the construction of the alliance chain are abnormal, such as the fact that the alliance organizer has a backup node that has not started successfully, but the alliance chain construction condition requires only one backup node to be successfully started. Therefore, the exception handling sub-state machine will also loop to count whether other backup nodes are successfully started within a certain time. If the condition is met again within a certain time, the sub-state of the exception handling sub-state machine changes to end; if the condition is still not met, it indicates that the alliance creator state machine or the alliance organizer state machine has a construction condition exception, and the sub-state is set to the construction canceled state to perform the corresponding operation of canceling the construction of the alliance chain. After the alliance construction cancel operation is completed, the alliance chain cancel construction process, the sub-state of the exception handling sub-state machine changes to end.

[0115] The proxy exception state refers to the exception of the server agent service. Usually, the exception handling sub-state machine will try to request the proxy service once to confirm whether the proxy service is still unavailable. If the call is successful, it means that the proxy service is normal, and the sub-state of the exception handling sub-state machine changes to end; if it fails, the sub-state is set to the manual processing state and waits for manual solution.

[0116] The request exception state refers to the failure of network request. Usually, the exception handling sub-state machine will retry the network request three times at intervals. If the request is successful, it means that the network service has recovered, and the sub-state changes to end; if it fails, the state is set to the manual processing state.

[0117] The execution exception state refers to other exceptions captured during the construction execution. Usually, the exception handling sub-state machine will try to fix these exceptions according to the business exception handling rule engine. For example, after obtaining the user certificate, it is found that the certificate has expired, and then a new certificate is applied to replace the old one. If the execution exception is handled successfully, the sub-state of the exception handling sub-state machine changes to end; otherwise, the sub-state of the exception handling sub-state machine is set to the manual processing state.

[0118] When the exception handling sub-state machine is in the manual processing state, it will notify the responsible person to manually handle the related problems. After the problem is solved, the sub-state of the exception handling sub-state machine changes to end, indicating that the alliance chain construction exception is solved.

[0119] This approach replaces the traditional script-based build method with a state machine-based build pattern. By defining key stages in the build process using necessary states, it is more suitable for consortium blockchain build tasks with complex dependencies, numerous data files, and intricate processes. The build process is divided into consortium creator state machines and consortium organization state machines, which better distinguishes the main entities involved in the consortium build process, making responsibilities clearer, execution logic more explicit, data hierarchy more reasonable, and easier to track and trace. Based on the state machine-based build pattern, exception handling sub-machines can be placed at any state transition point, enabling end-to-end state exception capture, unified exception handling, and state recovery. Identifying key stages in the build process with states makes each stage concrete, responsible, unique, and authoritative. This provides intuitive state references for processes such as adding organizations, adding channels, and organizations joining channels, helping to prevent execution conflicts. The state-based build approach can also optimize concurrency efficiency and reduce resource waste.

[0120] By performing the above steps, the state machine-based consortium blockchain construction method provided in this embodiment of the invention processes abnormal messages that occur during the consortium blockchain creation process using a state machine. When an abnormal message affects the state machine corresponding to the consortium creator or organizer, the abnormal state machine is set to an abnormal state to suspend its consortium blockchain creation process. By saving the corresponding consortium state progress, the creation stage of the consortium blockchain can be understood. This facilitates the resumption of the consortium blockchain creation work based on the original consortium state progress after the abnormality is resolved. This can effectively reduce user waiting time, improve the efficiency of consortium blockchain construction, and thus improve the user experience. Furthermore, the reminders of the status of its own sub-machines help users understand the operation of the consortium blockchain creation process and promptly remind users to handle abnormalities.

[0121] This invention also provides an electronic device, such as... Figure 5 As shown, the electronic device may include a processor 901 and a memory 902, wherein the processor 901 and the memory 902 may be connected via a bus or other means. Figure 5 Taking the example of a connection between China and Israel via a bus.

[0122] Processor 901 can be a Central Processing Unit (CPU). Processor 901 can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations of the above types of chips.

[0123] The memory 902, as a kind of non-transient computer readable storage medium, can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the method in the embodiments of the present application. The processor 901 executes various functions of the processor and data processing by running the non-transient software programs, instructions and modules stored in the memory 902, that is, realizes the above-mentioned method.

[0124] The memory 902 can include a program storage area and a data storage area, wherein the program storage area can store application programs required by the operation device and at least one function; the data storage area can store data created by the processor 901 and the like. In addition, the memory 902 can include a high-speed random access memory, and can also include a non-transient memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transient solid-state memory device. In some embodiments, the memory 902 can optionally include a memory disposed remotely with respect to the processor 901, which can be connected to the processor 901 through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.

[0125] One or more modules are stored in the memory 902, and when executed by the processor 901, the above-mentioned method is executed.

[0126] The above-mentioned electronic device can correspond to the specific details described above. The corresponding related description and effects of the embodiment of the method can be understood, and will not be repeated here.

[0127] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by a computer program instructing related hardware. The implemented program can be stored in a computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiments of the method. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD) or a solid state drive (SSD), etc. The storage medium can also include a combination of the above-mentioned types of storage.

[0128] The above examples are only used to illustrate the technical solutions of the present application but not to limit the present application. Although the present application is described in detail with reference to the above examples, it should be understood by those skilled in the art that the specific embodiments of the present application can be changed or replaced equivalently without departing from the spirit and scope of the present application, and any change or equivalent replacement without departing from the spirit and scope of the present application should be covered in the scope of claims of the present application.

Claims

1. A state machine-based alliance chain construction method, applied to a first state machine corresponding to an alliance creator, and having the steps of: The method comprises: obtaining the creation information of the target alliance chain submitted by the alliance creator; sending corresponding commands to the second state machine corresponding to each alliance organizer according to the creation information according to the alliance chain creation process; monitoring the alliance state progress changed after the second state machine executes the corresponding commands in the alliance chain creation process, and changing the alliance state progress of the second state machine according to the alliance state progress of the second state machine until the alliance chain creation process ends, and completing the construction of the target alliance chain; The commands include: alliance invitation command, identity information generation command, node startup command, channel joining command, alliance chain creation process includes alliance invitation stage, identity information generation stage, node startup stage, channel joining stage corresponding to the commands one by one, the construction of the monitoring task monitors the alliance state progress changed after the second state machine executes each command in the alliance chain creation process, and changes the alliance state progress of the second state machine according to the alliance state progress of the second state machine, including: constructing a first monitoring task to monitor the execution result of the alliance invitation command of the second state machine, and changing the alliance state of the first state machine to an organization invited state after monitoring that a preset number of second state machines accept the alliance invitation and enter the alliance invitation accepted state; constructing a second monitoring task to monitor the execution result of the identity information generation command of the second state machine, and changing the alliance state of the first state machine to an alliance identity information ready state after monitoring that all alliance organizers corresponding to the second state machine that accept the invitation generate identity information and enter the identity information generated state; constructing a third monitoring task to monitor the execution result of the node startup command of the second state machine, and changing the alliance state of the first state machine to an alliance node ready state after monitoring that all nodes of the second state machine corresponding to all alliance organizers that accept the invitation are started and enter the node started state; constructing a fourth monitoring task to monitor the execution result of the channel joining command of the second state machine, and changing the alliance state of the first state machine to an alliance constructed state after monitoring that all alliance organizers corresponding to the second state machine that accept the invitation have joined the channel and enter the channel joined state.

2. The method of claim 1, wherein, Further comprising: generating an exception message when the monitoring task in the alliance chain creation process detects an exception; sending the exception message to an exception handling sub-state machine to call the exception handling sub-state machine to process the exception message.

3. The method of claim 1, wherein, Further comprising: sending an alliance chain construction process end notification to the second state machine joining the target alliance chain, so that each second state machine changes its own alliance state to an alliance constructed state.

4. A state machine-based alliance chain construction method, applied to a second state machine corresponding to an alliance organizer, characterized in that, The method comprises: receiving the commands sent by the first state machine corresponding to the alliance creator; executing the commands, and changing the alliance state progress of the first state machine according to the execution result of the commands; sending a self alliance state progress to the first state machine, so that the first state machine builds a listening task to monitor the alliance state progress changed after the second state machine executes each command in the alliance chain creation process, and changes the self alliance state progress according to the alliance state progress of the second state machine, the command including: a coalition invitation command, a generated identity information command, a start node command, a join channel command, the alliance chain creation process including a coalition invitation stage, a generated identity information stage, a start node stage, and a join channel stage corresponding to the command one by one, the building of the listening task to monitor the alliance state progress changed after the second state machine executes each command in the alliance chain creation process, and the changing of the self alliance state progress according to the alliance state progress of the second state machine, including: building a first listening task to monitor the execution result of the coalition invitation command of the second state machine, and changing the alliance state of the first state machine to an organization invited state after monitoring that a preset number of second state machines accept the coalition invitation and enter an accepted coalition invitation state; building a second listening task to monitor the execution result of the generated identity information command of the second state machine, and changing the alliance state of the first state machine to an alliance identity information ready state after monitoring that all second state machines corresponding to the accepted invitation coalition organizers generate identity information and enter an identity information generated state; building a third listening task to monitor the execution result of the start node command of the second state machine, and changing the alliance state of the first state machine to an alliance node ready state after monitoring that all second state machines corresponding to the accepted invitation coalition organizers start all nodes and enter a node started state; and building a fourth listening task to monitor the execution result of the join channel command of the second state machine, and changing the alliance state of the first state machine to an alliance constructed state after monitoring that all second state machines corresponding to the accepted invitation coalition organizers join the channel and enter a joined channel state.

5. The method of claim 4, wherein, Further comprising: generating an exception message when an exception occurs in the alliance chain creation process; sending the exception message to an exception handling sub-state machine to call the exception handling sub-state machine to process the exception message; sending the exception state to the first state machine when the second state machine is set to an exception state by the exception handling sub-state machine. 6.A state machine-based consortium chain construction method, applied to an exception handling sub-state machine, characterized in that, The method comprises: receiving an exception message sent by a first state machine corresponding to an alliance creator or a second state machine corresponding to any coalition organizer after an exception occurs in an alliance chain creation process, the first state machine obtaining creation information of a target alliance chain submitted by an alliance creator; sending corresponding commands to each second state machine corresponding to an alliance organizer according to the creation information based on the creation information according to the alliance chain creation process; The construction monitoring task monitors the alliance state progress changed after the second state machine executes corresponding commands in the alliance chain creation process, and changes its own alliance state progress according to the alliance state progress of the second state machine, until the alliance chain creation process ends, and the construction of the target alliance chain is completed; the commands include: alliance invitation command, identity information generation command, node startup command, channel joining command, the alliance chain creation process includes an alliance invitation stage, an identity information generation stage, a node startup stage, and a channel joining stage corresponding to the commands one by one, and the construction monitoring task monitors the alliance state progress changed after the second state machine executes each command, and changes its own alliance state progress according to the alliance state progress of the second state machine, including: the first monitoring task monitors the execution result of the alliance invitation command of the second state machine, and changes the alliance state of the first state machine to the organization invited state after monitoring that a preset number of second state machines accept the alliance invitation and enter the alliance invitation accepted state; the second monitoring task monitors the execution result of the identity information generation command of the second state machine, and changes the alliance state of the first state machine to the alliance identity information ready state after monitoring that all second state machines corresponding to the alliance organizers who accept the invitation generate identity information and enter the identity information generated state; the third monitoring task monitors the execution result of the node startup command of the second state machine, and changes the alliance state of the first state machine to the alliance node ready state after monitoring that all nodes of all second state machines corresponding to the alliance organizers who accept the invitation are started and enter the node started state; the fourth monitoring task monitors the execution result of the channel joining command of the second state machine, and changes the alliance state of the first state machine to the alliance constructed state after monitoring that all second state machines corresponding to the alliance organizers who accept the invitation have joined the channel and enter the channel joined state; Based on the abnormal message, the state of the sub-machine is changed to an abnormal receiving state, and it is judged whether the abnormal message affects the change of the alliance state progress of the first state machine and each second state machine; When the abnormal message affects the change of the alliance state progress of the first state machine and / or the second state machine, the first state machine and / or the second state machine affected by the abnormal message are placed in an abnormal state, the state of the sub-machine is changed to an abnormal state, and the current alliance state progress of the first state machine and / or the second state machine is saved, and the first state machine and / or the second state machine in the abnormal state suspends the alliance creation process.

7. The method of claim 6, wherein, When the first state machine and / or the second state machine are in the abnormal state, the method further comprises: Monitoring whether the abnormal message is eliminated within a predetermined time; If the abnormal message is eliminated within a predetermined time, the state of the sub-machine is changed to an end state; If the abnormal message is not eliminated within a predetermined time, the state of the sub-machine is changed to a manual processing state to notify manual abnormal processing.

8. The method of claim 7, wherein, When the first state machine or the second state machine is in an abnormal state, the method further comprises: periodically monitoring whether the sub-machine state of the abnormal processing sub-state machine changes to an end state; when it is monitored that the sub-machine state of the abnormal processing sub-state machine changes to the end state, resuming the current alliance state progress of the first state machine and / or the second state machine based on the current alliance state progress of the first state machine and / or the second state machine, so that the first state machine and / or the second state machine continue to execute the alliance creation process on the basis of the current alliance state progress.

9. The method of claim 6, wherein, Further comprising: when the abnormal message does not affect the change of the first state machine and each second state machine alliance state, changing the sub-machine state to the end state, and sending the abnormal message to the abnormal queue. 10.A state machine based consortium chain construction system, characterized in that, Comprise: an abnormal processing sub-state machine, a first state machine corresponding to an alliance creator, and a second state machine corresponding to each alliance organizer one by one, wherein, the first state machine is used to obtain the creation information of the target alliance chain submitted by the alliance creator; based on the creation information, the corresponding command is sent to the second state machine corresponding to each alliance organizer according to the alliance chain creation process; the second state machine is used to receive the command sent by the first state machine corresponding to the alliance creator; execute the command, and change the alliance state progress of itself according to the execution result of the command; send the alliance state progress of itself to the first state machine; The first state machine is also used to build a monitoring task to monitor the alliance state progress changed after the second state machine executes a corresponding command in the alliance chain creation process, and to change its own alliance state progress according to the alliance state progress of the second state machine until the alliance chain creation process ends and the construction of the target alliance chain is completed; the command includes: an alliance invitation command, an identity information generation command, a node start command, and a channel joining command, and the alliance chain creation process includes an alliance invitation stage, an identity information generation stage, a node start stage, and a channel joining stage corresponding to the commands one by one, and the monitoring task changes its own alliance state progress according to the alliance state progress of the second state machine after the second state machine executes each command in the alliance chain creation process, including: building a first monitoring task to monitor the execution result of the alliance invitation command of the second state machine, and changing the alliance state of the first state machine to an organization invited state after monitoring that a preset number of second state machines accept the alliance invitation and enter an alliance invitation accepted state; building a second monitoring task to monitor the execution result of the identity information generation command of the second state machine, and changing the alliance state of the first state machine to an alliance identity information ready state after monitoring that all second state machines corresponding to the alliance organizers who accept the invitation generate identity information and enter an identity information generated state; building a third monitoring task to monitor the execution result of the node start command of the second state machine, and changing the alliance state of the first state machine to an alliance node ready state after monitoring that all nodes of the second state machines corresponding to the alliance organizers who accept the invitation are started and enter a node started state; and building a fourth monitoring task to monitor the execution result of the channel joining command of the second state machine, and changing the alliance state of the first state machine to an alliance constructed state after monitoring that all second state machines corresponding to the alliance organizers who accept the invitation have joined the channel and enter a channel joined state. The exception processing sub-state machine is used to receive an exception message sent by the first state machine corresponding to an alliance creator or any second state machine corresponding to an alliance organizer after an exception occurs in the alliance chain creation process; the exception message is sent after an exception occurs in the alliance chain creation process; based on the exception message, the sub-state machine changes its own sub-state to an exception receiving state, and judges whether the exception message affects the change of the alliance state progress of the first state machine and each second state machine; when the exception message affects the change of the alliance state progress of the first state machine and / or the second state machine, the first state machine and / or the second state machine affected by the exception message is placed in an exception state, the sub-state of the exception processing sub-state machine is changed to an exception state, and the current alliance state progress of the first state machine and / or the second state machine is saved, and the first state machine and / or the second state machine in the exception state suspends the alliance creation process.

11. A computer readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are executed by the processor to implement the method of any one of claims 1-9.

12. An electronic device, comprising: It comprises: A memory and a processor, which are connected in communication with each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the method of any one of claims 1-9.

Citation Information

Patent Citations

  • Method, system, storage medium and device for quickly deploying alliance chain

    CN110113185A