CPC H04L 9/50 (2022.05) [H04L 9/3239 (2013.01); G06Q 30/0185 (2013.01)] | 12 Claims |
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.
|