IP Library Granted Patent US 12,081,682
Granted Patent B2
US 12,081,682 · App. 16/962,713 · Granted Sep 3, 2024

Method for determining main chain of blockchain, device, and storage medium

Inventor: Wei Xiao (Beijing, CN)
Assignee: BAIDU ONLINE NETWORK TECHNOLOGY (BEIJING) CO., LTD.
H04L9/50H04L9/3239G06Q30/0185
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,081,682
App. No.
16/962,713
Granted
Sep 3, 2024
Kind
B2
Abstract

A method for determining a main chain of a blockchain, a device, and a storage medium. The method comprises: determining, on the basis of a detection result that it is detected that a blockchain has at least two fork chains, weights of blocks in the fork chains ( 110 ); determining, on the basis of the weights of the blocks comprised in the fork chains, the weights of the fork chains ( 120 ); and determining a main chain from the fork chains on the basis of the weights of the fork chains, and rolling back the fork chains except for the main chain ( 130 ).

Claims (54)

1. A method for determining a main chain of a blockchain, comprising:

determining a weight of each block in each fork chain of the blockchain based on a block generation node of each block in each fork chain in response to detecting that at least two fork chains exist in the blockchain;

determining a weight of each fork chain according to the weight of each block included in the fork chain;

determining a main chain from the fork chains according to the weight of each fork chain, and rolling back the fork chains other than the main chain;

wherein determining the weight of each block in each fork chain comprises, for any block in the fork chain,

setting a weight of the block as a first value in response to determining that a block generation node of the block is different from a block generation node of a previous block of the block;

setting the weight of the block as the first value in response to determining that the block generation node of the block is the same as the block generation node of the previous block of the block and that the previous block is a fork block; and

setting the weight of the block as a second value in response to determining that the block generation node of the block is the same as the block generation node of the previous block of the block and that the previous block is not a fork block;

wherein the first value is greater than the second value.

2. The method of claim 1 , wherein determining the weight of each block in each fork chain comprises:

determining a target attack type according to block information included in the fork chain;

determining a target weight setting rule associated with the target attack type according to an association relationship between preset attack types and weight setting rules; and

determining the weight of each block in the fork chain according to the target weight setting rule.

3. The method of claim 1 , wherein determining the weight of each fork chain according to the weight of each block included in the fork chain comprises:

summing the weight of each block included in the fork chain to obtain the weight of the fork chain.

4. The method of claim 1 , wherein determining the main chain from the fork chains according to the weight of each fork chain comprises:

determine the fork chain with a largest weight as the main chain.

5. A device, comprising:

one or more processors;

a memory configured to store one or more programs;

when the one or more programs are executed by the one or more processors, the one or more processors are caused to carry out a method for determining a main chain of a blockchain comprising:

determining a weight of each block in each fork chain of the blockchain based on a block generation node of each block in each fork chain in response to detecting that at least two fork chains exist in the blockchain;

determining a weight of each fork chain according to the weight of each block included in the fork chain;

determining a main chain from the fork chains according to the weight of each fork chain, and rolling back the fork chains other than the main chain;

wherein determining the weight of each block in each fork chain comprises, for any block in the fork chain,

setting a weight of the block as a first value in response to determining that the block generation node of the block is different from a block generation node of a previous block of the block;

setting the weight of the block as the first value in response to determining that the block generation node of the block is the same as the block generation node of the previous block of the block and that the previous block is a fork block; and

setting the weight of the block as a second value in response to determining that the block generation node of the block is the same as the block generation node of the previous block of the block and that the previous block is not a fork block;

wherein the first value is greater than the second value.

6. The device of claim 5 , wherein determining the weight of each block in each fork chain comprises:

determining a target attack type according to block information included in the fork chain;

determining a target weight setting rule associated with the target attack type according to an association relationship between preset attack types and weight setting rules; and

determining the weight of each block in the fork chain according to the target weight setting rule.

7. The device of claim 5 , wherein determining the weight of each fork chain according to the weight of each block included in the fork chain comprises:

summing the weight of each block included in the fork chain to obtain the weight of the fork chain.

8. The device of claim 5 , wherein determining the main chain from the fork chains according to the weight of each fork chain comprises:

determine the fork chain with a largest weight as the main chain.

9. A non-transitory computer-readable storage medium having a computer program stored thereon which, when is executed by a processor, the processor is caused to carry out a method for determining a main chain of a blockchain comprising:

determining a weight of each block in each fork chain of the blockchain based on a block generation node of each block in each fork chain in response to detecting that at least two fork chains exist in the blockchain;

determining a weight of each fork chain according to the weight of each block included in the fork chain;

determining a main chain from the fork chains according to the weight of each fork chain, and rolling back the fork chains other than the main chain;

wherein determining the weight of each block in each fork chain comprises, for any block in the fork chain,

setting a weight of the block as a first value in response to determining that the block generation node of the block is different from a block generation node of a previous block of the block;

setting the weight of the block as the first value in response to determining that the block generation node of the block is the same as the block generation node of the previous block of the block and that the previous block is a fork block; and

setting the weight of the block as a second value in response to determining that the block generation node of the block is the same as the block generation node of the previous block of the block and that the previous block is not a fork block;

wherein the first value is greater than the second value.

10. The non-transitory computer-readable storage medium of claim 9 , wherein determining the weight of each block in each fork chain comprises:

determining a target attack type according to block information included in the fork chain;

determining a target weight setting rule associated with the target attack type according to an association relationship between preset attack types and weight setting rules; and

determining the weight of each block in the fork chain according to the target weight setting rule.

11. The non-transitory computer-readable storage medium of claim 9 , wherein determining the weight of each fork chain according to the weight of each block included in the fork chain comprises:

summing the weight of each block included in the fork chain to obtain the weight of the fork chain.

12. The non-transitory computer-readable storage medium of claim 9 , wherein determining the main chain from the fork chains according to the weight of each fork chain comprises:

determine the fork chain with a largest weight as the main chain.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 16, 2020
From: XIAO, WEI
To: BAIDU ONLINE NETWORK TECHNOLOGY (BEIJING) CO., LTD.
Reel/Frame 053230/0682 →
Priority Claims (1)
CN 201810411049.4 · May 2, 2018 · national
Continuity (1)
Related Publication 20200358812A1 · Nov 12, 2020