Summary of the invention
In view of the above-mentioned problems, one aspect of the present invention provides a kind of method for handling the state of the node of block chain,The described method includes: being linked into unit from block receives request;Detect the state of the node;When the node is in abnormalWhen state, unit is linked into block and is sent for indicating out of repair first feedback information of the node.
In one embodiment, the request is transaction request.
In one embodiment, the state for detecting the node includes: to execute the transaction of request;And it detects transaction to holdCapable state.
In one embodiment, when the number that prompting message occurs in the given time is more than or equal to specified threshold,The node is in abnormal state.
In one embodiment, the prompting message includes any type in following various information: warning prompt, mistakeAccidentally prompt, abnormal prompt and fatal error prompt, and the specified threshold is associated with the classification of the prompting message.
In one embodiment, the state for detecting the node includes: to detect the hardware resource utilization rate of the node,Wherein, the hardware resource utilization rate includes at least one of the following: CPU usage, memory usage, network bandwidthUtilization rate and disk utilization rate, and when any one of described hardware resource utilization rate is more than its respective threshold, the sectionPoint is in abnormal state.
In one embodiment, the state for detecting the node includes: detecting whether the relevant failure of block chain occur,Wherein, the relevant failure of the block chain includes at least one of the following: common recognition failure, failure of data synchronization, sign testFailure, network communication failure and database purchase failure, and when there is any one of relevant failure of the block chain,The node is in abnormal state.
In a kind of embodiment, the method also includes: when the node reverts to normal condition, to the block chainAccess unit is sent for indicating that the node reverts to the second feedback information of normal condition.
In a kind of embodiment, the request is the request that detects the state of the node.
In a kind of embodiment, the state for detecting the node includes: detection at least one of the following: the sectionThe operating status of point;The network communication status of the node;The hardware resource utilization of the node;With the history of the nodeTransaction executes abnormal number, and wherein, when the node is in delay machine state, or at the network communication of the nodeIn abnormal state, or when the historical trading of the node executes abnormal number and is more than or equal to respective threshold, the sectionPoint is in abnormal state.
Another aspect of the present invention additionally provides a kind of method of the state of node for handling block chain, which comprisesIt sends and requests at least one node;Based on from the received feedback information of each of at least one node node come moreThe state of new each node;When receiving for indicating out of repair first feedback information of the nodeWhen, the state of each of the node for sending first feedback information node is updated to not be available.
In one embodiment, the request is asking for the state of transaction request or detection at least one nodeIt asks.
In one embodiment, the state that will send each of the node of first feedback information node updatesIt include: by information associated with each of the node that sends first feedback information node from described not to be availableThe transaction that block is linked into unit executes to be removed in list.
In one embodiment, the method also includes: when receiving for indicating that the node reverts to normal shapeWhen the second feedback information of state, the state of the node of each of the node of second feedback information block chain will be sent moreNew is that can be used.
In one embodiment, each of the node of block chain of second feedback information node will be sentIt includes: by letter associated with each of the node that sends second feedback information node that state, which is updated to can be used,Breath is added to the block and is linked into the transaction execution list of unit.
Another aspect of the present invention additionally provides a kind of device of the state of node for handling block chain, comprising: memory,For storing instruction;And processor, it is coupled to the memory, described instruction makes institute when being executed by the processorIt states device and executes method described in any of the above embodiments.
Another aspect of the present invention additionally provides a kind of computer storage medium, and the storage medium includes instruction, the fingerOrder is performed, so that the processor of the computer executes method described in any of the above embodiments.
Whether present invention node from the viewpoint of the business scenario of block chain can be used, so as to dynamic for business scenarioThe availability for utilizing to state node achievees the purpose that the maximum extent and reasonably to utilize parameter.Block link of the inventionEnter unit and can send request to detect node to obtain the state of node and node or detect itself simultaneouslyAnd be linked into unit to block and feed back the status message of itself, to reach the mesh for carrying out double check to the availability of node's.
Specific embodiment
Below with reference to each exemplary embodiment of the attached drawing detailed description disclosure.Flow chart and block diagram in attached drawing are shownThe architecture, function and operation in the cards of method and system according to various embodiments of the present disclosure.It should be noted thatEach box in flowchart or block diagram can represent a part of a module, program segment or code, the module, programSection or a part of code may include one or more holding for realizing the logic function of defined in each embodimentRow instruction.It should also be noted that in some alternative implementations, function marked in the box can also be attached according to being different fromThe sequence marked in figure occurs.For example, two boxes succeedingly indicated can actually be basically executed in parallel or itCan also execute in a reverse order sometimes, this depend on related function.It should also be noted that flow chartAnd/or the combination of each box in block diagram and the box in flowchart and or block diagram, function as defined in execution can be usedCan or the dedicated hardware based system of operation realize, or specialized hardware can be used and the combination of computer instruction comesIt realizes.
Term as used herein "include", "comprise" and similar terms are understood to open term, i.e.," including/including but not limited to ", expression can also include other content.Term "based" is " being based at least partially on ".Term" one embodiment " expression " at least one embodiment ";Term " another embodiment " expression " at least one other embodiment ",Etc..
Technology, method and apparatus known to person of ordinary skill in the relevant may be not discussed in detail, but suitableIn the case of, the technology, method and apparatus should be considered as part of specification.For between each unit in attached drawingLine, it is only for convenient for explanation, indicate that the unit at least line both ends is in communication with each other, it is not intended that limitation does not connectIt can not be communicated between the unit of line.
Below in conjunction with attached drawing, the present invention will be described in detail
Fig. 1 shows the schematic diagram at the network 100 of the state of the node of the processing block chain of embodiment according to the present invention,Network 100 includes block chain 101 and block is linked into unit 102, and block chain 101 is by multiple nodes of mutual connection (for example, sectionPoint 1, node 2, node 3 ..., node N) composition, it should be understood that N can be the arbitrary value more than or equal to 1 here.Block chainBe connected on access unit 102 and each meshed network in block chain 101 (it should be understood that can by wired or wireless way intoRow connection).Block be linked into unit 102 can at least one node into block chain send transaction request or send detectionThe request of the state of at least one node;At least one node in response to the transaction request that receives or detection request detection fromThe state of body;Later, which can be linked into unit 102 to block and send feedback information, and block is linked into unit102 are updated the state of at least one node according to the feedback information of node.It should be understood that block chain hereIt is not limited to a certain type, can be any type of block chain.In a kind of embodiment, block is linked into unit 102 can be withIt is the unit based on load balancing, is also possible to be also possible to any other conjunction based on the unit of general block chain clientSuitable unit.
Fig. 2 is the flow chart of the method for the state of the node of the node side processing block chain of embodiment according to the present invention200, the specific steps are as follows:
Step S201: unit 102 is linked into from block and receives request.
Step S202: the state of detection node.
Step S203: when node is in abnormal state, unit is linked into block and is sent for indicating that node is inFirst feedback information of abnormal state.
Fig. 3 is the method for the state that the block of embodiment according to the present invention is linked into the node of unit survey processing block chainFlow chart 300, the specific steps are as follows:
Step S301: it sends and requests at least one node.
Step S302: each section is updated based on from the received feedback information of each of at least one node nodeThe state of point.
Step S303: when receiving for indicating out of repair first feedback information of node, will be sentThe state of each of the node of one feedback information node is updated to not be available.
Fig. 4 is that node side according to an embodiment of the invention and block are linked into cell side cooperation and complete processing blockThe flow chart 400 of the method for the state of the node of chain.It is described in detail below with reference to Fig. 1 and Fig. 4.
Step S401: user is linked into unit to block and initiates transaction request.
Step S402: block is linked into unit and which node can be used to execute currently according to transaction execution list confirmationBusiness scenario, these nodes are referred to as the node that can be used.It should be understood that transaction herein, which executes list, is located at block linkEnter in unit and record the relevant information for the node that can be used, and the correlation of node all in original records block chainInformation, i.e., all nodes are initially that can be used.It should also be understood that can also can be made by other suitable modes to confirmWhich node to execute current business scenario with.
Step S403: block is linked into unit and transaction request is sent to the node that currently can be used confirmed.
Step S404: the node that each currently can be used executes the friendship of request based on the transaction request received respectivelyEasily.
Step S405: if it is abnormal that the nodal test that currently can be used, which goes out the state that itself current transaction executes,, S406 is thened follow the steps, it is no to then follow the steps S409.
Step S406: if the number that prompting message occurs in the given time is more than or equal to specified threshold, step is executedRapid S407, it is no to then follow the steps S410.It should be understood that prompting message here includes any type in following various information: alertAccuse prompt, miscue, abnormal prompt and fatal error prompt, and the classification phase of the specified threshold and the prompting messageAssociation, for example, the number and first threshold that warning prompt occurs are (in one embodiment, when prompt information is warning promptFirst threshold is to occur 5 times in 5 seconds.) be compared;When prompt information is miscue, the number of miscue appearance(in one embodiment, second threshold is to occur 3 times in 5 seconds with second threshold.) be compared;When prompt information is abnormalWhen prompt, number and third threshold value that abnormal prompt occurs (in one embodiment, second threshold is to occur 3 times in 5 seconds)It is compared;When prompt information is that fatal error prompts, the number of fatal error appearance and the 4th threshold value are (in one embodimentIn, the 4th threshold value is to occur 1 time in 5 seconds) it is compared.It should be understood that time occurred in predetermined time, predetermined timeNumber, first threshold, second threshold, third threshold value and the 4th threshold value can be adjusted as needed.
Step S407: node is linked into unit to block and sends for indicating that the node out of repair first is anti-Feedforward information.
Step S408: when block is linked into unit and receives the first feedback information, by with the section that sends the first feedback informationThe associated information of point is executed in list from the transaction that block is linked into unit and is removed.
Step S409: it returns to block and is linked into unit currently and can be used node to execute normal state of trading normalFeedback information.
Step S410: it returns to block and is linked into cell node execution transaction exception but still can be used.
In one embodiment, when node receives transaction request can hardware resource utilization rate to itself (including but notIt is limited to CPU usage, memory usage, network bandwidth utilization rate, disk utilization rate) it is detected;When CPU usage, memoryAt least one is more than that (CPU usage, memory make its respective threshold in utilization rate, network bandwidth utilization rate and disk utilization rateThere is respective threshold value with rate, network bandwidth utilization rate and disk utilization rate, and threshold value is adjustable, it is preferable that setting CPU is usedRate threshold value is 70%, and memory usage threshold value is 90%, and network bandwidth utilization rate is 80%, and disk utilization rate threshold value is 80%)When, node is linked into unit to block and sends for indicating out of repair first feedback information of node;Then it repeatsStep S408.
In another embodiment, it can detect whether failure relevant to block chain occur when node receives transaction request(including but not limited to: common recognition failure, failure of data synchronization, sign test failure, network communication failure, database purchase failure);Such asAt least one of in fruit failure, then node is linked into unit to block and sends for indicating that the node is in abnormal stateThe first feedback information;Then step S408 is repeated.
It should be understood that in one embodiment, when node reverts to normal condition, unit being linked into block and sends useThe second feedback information of normal condition is reverted in expression node, and block is linked into unit and is receiving the second feedback informationWhen will execute in list with sending the associated information of the node of the second feedback information and be added to block and be linked into the transaction of unit.
It should be understood that information associated with the node of the first feedback information is sent to be linked into the friendship of unit from blockEasily executing removal in list is that the node state for sending the first feedback information is updated to a kind of implementation not being available;AlsoThe node state for sending the first feedback information can be updated to not be available by other suitable modes.It equally, will be with hairSend the associated information of the node of the second feedback information be added to block be linked into unit transaction execute list in be that will sendThe state of the node of second feedback information is updated to a kind of implementation that can be used, and can also pass through other suitable modesThe state for sending the node of the second feedback information is updated to can be used.
It will also be appreciated that different threads can be used in each node, it is also possible to which identical thread detects itselfThe state or detection failure relevant to block chain that hardware resource utilization rate, detection transaction execute.
It is from the viewpoint of the business scenario of block chain that the node of above-mentioned block chain, which carries out detection to the state of itself,Whether node can be used, and so as to dynamically utilize the availability of node for business scenario, reach to the maximum extent and rationallyGround utilizes the purpose of parameter.
Fig. 5 is that node side according to another embodiment of the invention and block chain are linked into cell side cooperation completion processingThe method flow diagram 500 of the state of the node of block chain, the specific steps are as follows:
Step S501: block is linked at least one node of unit into block chain and initiates to detect at least one nodeThe request of state.
Step S502: at least one node detects itself state after receiving request respectively.
Step S503: if the operating status of node is delay machine state, thening follow the steps S507, no to then follow the stepsS504.Step S504: if the network communication of the node of block chain is in normal condition, S505 is thened follow the steps, is otherwise executedStep S507.
Step S505: if node hardware resource utilization rate (including but not limited to: CPU usage, memory usage,Network bandwidth utilization rate, disk utilization rate) at least one of be more than respective threshold, then follow the steps S507, otherwise execute stepRapid S506.It should be understood that can according to need to each single item given threshold in hardware resource, i.e. setting CPU usage threshold value, interiorDeposit utilization rate threshold value, network bandwidth utilization rate threshold value, disk utilization rate threshold value.In one embodiment, CPU usage threshold value is70%, it is 80% that memory usage 90%, network bandwidth, which load, disk utilization rate threshold value is 80%.
Step S506: if the number that transaction executes exception in the given time (has several transactions in the given timeExecute abnormal) it is more than or equal to the 5th threshold value, S507 is thened follow the steps, it is no to then follow the steps S509.In one embodiment,Five threshold values occur 5 times in 5 seconds.It should be understood that predetermined time here, transaction execute abnormal number and the 5th threshold value can be withAdjustment.
Step S507: node is linked into unit to block and sends for indicating out of repair first feedback of nodeInformation.
Step S508: block is linked into unit and removes information associated with node from transaction execution list, Ying LiSolution, transaction execution list here are located at block and are linked into unit and for listing which node can be usedNode.
Step S509: node is linked into the information that unit return node can be used to block.
In addition, although in the present embodiment, according to the operating status of node, the network communication status of node, node hardwareWhether the state that the sequence that resource utilization, transaction execute abnormal number carries out node normally judge, it should be understood thatIt is the mode for judging the state of node and whether normally being sequentially not limited to enumerate, the sequence of this four judgements can according to needIt is adjusted.
It should be understood that restoring normal and node network communication when the operating status of node reverts to normal condition simultaneouslyAnd the hardware resource utilization rate of node restores that equal each single item is respectively less than respective threshold and historical trading in the given time is heldWhen the abnormal number of row is less than five threshold values, i.e., when node reverts to normal condition, node can be linked into unit transmission to blockFor indicating that node reverts to the second feedback information of normal condition;And block is linked into unit and receives the second feedback informationWhen by information associated with node be added to transaction execute list in.
It will also be appreciated that will execute removal in list from transaction with the associated information of node is realized the state of nodeIt is updated to a kind of mode not being available, can also realize that the state by node is updated to by other suitable modes can notIt uses.Equally, will be added to transaction with the associated information of node and execute in list is to realize that be updated to the state of node can be withA kind of mode used can also realize that the state by node is updated to can be used by other suitable modes.
Above-mentioned block is linked into unit and can be also detected to node to obtain the state of node, to reach to nodeAvailability carry out double check purpose.
Fig. 6 shows the schematic diagram of the device 600 of the state of the node of the acquisition block chain of embodiment according to the present invention.Device 600 may include: memory 601 and the processor 602 for being coupled to memory 601.Memory 601 for storing instruction,Processor 602 is configured as the instruction stored based on memory 601 to realize for side described in Fig. 2, Fig. 3, Fig. 4 and Fig. 5One or more of any step in the step of method.
As shown in fig. 6, device 600 can also include communication interface 603, for carrying out information exchange with other devices.ThisOutside, device 600 can also include bus 606, and memory 601, processor 602 and communication interface 603 are by bus 604 come each otherIt is communicated.
Memory 601 may include volatile memory, also may include nonvolatile memory.Processor 602 can be withIt is central processing unit (CPU), microcontroller, specific integrated circuit (ASIC), digital signal processor (DSP), field-programmableGate array (FPGA) or other programmable logic device or the one or more collection for being configured as realization the embodiment of the present inventionAt circuit.
Alternatively, the method for the state of the node of above-mentioned acquisition block chain can have by computer program productThe computer readable storage medium of shape embodies.Computer program product may include computer readable storage medium, uploadThere are the computer-readable program instructions for executing various aspects of the disclosure.Computer readable storage medium, which can be, to be protectedHold and store the physical device of the instruction used by instruction executing device.Computer readable storage medium for example can be but unlimitedIn electrical storage device, magnetic memory apparatus, light storage device, electromagnetic storage device, semiconductor storage or above-mentioned anySuitable combination.The more specific example (non exhaustive list) of computer readable storage medium include: portable computer diskette,Hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM or flash memory),Static random access memory (SRAM), Portable compressed disk read-only memory (CD-ROM), digital versatile disc (DVD), noteRecall stick, floppy disk, mechanical coding device, the punch card for being for example stored thereon with instruction or groove internal projection structure and above-mentionedAny appropriate combination.Computer readable storage medium used herein above is not interpreted instantaneous signal itself, such as wirelesslyThe electromagnetic wave of electric wave or other Free propagations, the electromagnetic wave propagated by waveguide or other transmission mediums are (for example, pass through optical fiberThe light pulse of cable) or pass through electric wire transmit electric signal.
It should be noted that the above list is only specific embodiments of the present invention, it is clear that the present invention is not limited to above realExample is applied, there are many similar variations therewith.If those skilled in the art directly exported from present disclosure orAll deformations associated, are within the scope of protection of the invention.