A method for controlling the blockchain generation rate

By introducing REDIS task pools and multi-threading technology into the blockchain system, combined with distributed locks, and dynamically adjusting the time interval and the number of packetizers, the problem of unstable blockchain generation rate is solved, achieving balanced transaction processing and system stability.

CN115686833BActive Publication Date: 2026-06-30ZHEJIANG XINLAN NETWORK MEDIA LTD CO +6

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG XINLAN NETWORK MEDIA LTD CO
Filing Date
2022-10-14
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

In existing technologies, blockchain nodes lack interconnected triggering mechanisms during transaction execution and packet generation, resulting in unstable on-chain speeds, uneven transaction volumes, data skew, and hotspot data issues, which affect system stability.

Method used

By using REDIS as a task pool, combined with multi-threading technology and distributed locks, the time interval and number of packetizers are dynamically adjusted to achieve intelligent scheduling of the blockchain generation rate, ensuring balanced transaction processing and efficient resource utilization.

Benefits of technology

It achieves stable control over the blockchain generation rate, avoids transaction backlog and resource waste, and ensures the rationality of block size and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115686833B_ABST
    Figure CN115686833B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of blockchain technology and discloses a method for controlling the blockchain generation rate, including the following steps: Step 1, receiving transactions to be executed and placing them into a task pool; Step 2, periodically scanning the task pool; Step 3, retrieving transactions to be executed and placing them into the blockchain's transaction pool to be packaged; Step 4, maintaining the on / off state of the packetizers; Step 5, dynamically expanding the number of packetizers. This invention, through real-time monitoring and dynamic adjustment of time and space, achieves control over the rate of blockchain block generation and ensures that blocks are generated to their full capacity, avoiding wasted computing power and storage space. Therefore, it not only guarantees the speed of block generation but also effectively controls the block size.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of blockchain technology, and in particular relates to a method for controlling the blockchain generation rate. Background Technology

[0002] Currently, Ethereum-based blockchain nodes execute a transaction after receiving it, and then the PACKETH packetizer generates a block.

[0003] Transaction execution and packet packaging are two separate processes without a mutual triggering mechanism. Under certain conditions, such as when no packetizer is running, there can be an excessive backlog of transactions waiting to be packaged. If the number of transactions waiting to be packaged is zero, the packetizer will print an empty packet, resulting in waste. This situation can lead to unstable on-chain speeds, an imbalance in the number of transactions in a block, data skew, and hotspot data issues, severely impacting system stability. Summary of the Invention

[0004] The purpose of this invention is to provide a method for controlling the blockchain generation rate to solve the above-mentioned technical problems.

[0005] To address the aforementioned technical problems, the specific technical solution of a method for controlling the blockchain generation rate according to the present invention is as follows:

[0006] A method for controlling the blockchain generation rate includes the following steps:

[0007] Step 1: Receive transactions to be executed and add them to the task pool;

[0008] Step 2: Regularly scan the task pool;

[0009] Step 3: Take out the transactions to be executed and put them into the blockchain's transaction pool to be sealed;

[0010] Step 4: Maintain the switch status of the packer;

[0011] Step 5: Quantity of dynamically expanded packetizers.

[0012] Furthermore, step 1 includes the following specific steps:

[0013] The program uses REDIS as a task pool for transactions to be executed. Upon receiving a transaction to be executed, it is first placed into the REDIS task pool, and the program starts a separate thread to periodically scan the task pool.

[0014] Furthermore, the number of transactions to be executed changes dynamically according to the peak and off-peak periods of system transactions.

[0015] Furthermore, step 2 includes the following specific steps:

[0016] Let the time interval for scanning the task pool be T seconds, and let T change dynamically with the number of tasks in the task pool: Let the upper limit of the packet sender be N, and the number of remaining tasks in the task pool after each scan be M. If M is greater than N, the time interval is dynamically shortened. The formula for calculating the time interval of the next scan is T*N / M. As the time interval shortens, M gradually approaches N, and the time interval gradually returns to T.

[0017] Furthermore, step 3 includes the following specific steps:

[0018] The timed scanning thread retrieves transactions to be executed in batches. After execution using multi-threading technology, the transactions are placed into the blockchain transaction pool to be packaged, and the packager performs the packaging and on-chain operation.

[0019] Furthermore, step 4 includes the following specific steps:

[0020] The program uses a REDISS distributed lock to maintain the on / off state of the packetizer. The lock stores the thread number. When uploading a packet to the chain, the program attempts to acquire the lock. If the acquisition is successful, it means that the current packetizer is closed, the method acquires the lock, saves the lock value as the current thread number, and executes the process to open the packetizer. If the acquisition fails, it means that the current packetizer is open, the lock value is replaced with the current thread number, the process skips the opening step, and in the final stage, it attempts to unlock the packetizer with the current thread number. If the unlock is successful, the packetizer is closed.

[0021] Furthermore, step 5 includes the following specific steps:

[0022] During peak system periods, the scanning time T is shortened to the threshold T0, and the scanning thread continuously adds transactions to be packaged into the blockchain transaction pool, dynamically expanding the number of packagers.

[0023] Furthermore, the threshold T0 is determined by stress testing based on the cluster computing power and the impact of on-chain complexity.

[0024] The method for controlling the blockchain generation rate according to the present invention has the following advantages: By real-time monitoring and dynamic adjustment of time and space, the present invention controls the rate at which blockchain blocks are generated, ensuring that blocks occupy the full capacity without wasting computing power and storage space. Therefore, it not only guarantees the speed of block generation but also effectively controls the block size. Attached Figure Description

[0025] Figure 1 This is a flowchart of the method for controlling the blockchain generation rate according to the present invention. Detailed Implementation

[0026] To better understand the purpose, structure, and function of this invention, the following detailed description of a method for controlling the blockchain generation rate is provided in conjunction with the accompanying drawings.

[0027] like Figure 1 As shown, this invention provides a method for controlling the blockchain generation rate, intelligently scheduling the execution of transactions and the generation of blocks from four dimensions: time, space, task pool, and transaction pool. Specifically, it includes the following steps:

[0028] Step 1: Receive and place pending transactions into the task pool: The program uses REDIS as the task pool for pending transactions. Upon receiving a pending transaction, it is first placed into the REDIS task pool. The program then starts a separate thread to periodically scan the task pool. The number of pending transactions dynamically changes according to the peak and off-peak periods of system transactions.

[0029] Step 2: Timed Scan of the Task Pool: Let the time interval for scanning the task pool be T seconds, where T dynamically changes with the number of tasks in the pool. Assume the packet generator's maximum packet capacity is N, and the remaining number of tasks in the pool after each scan is M. If M is greater than N, the time interval is dynamically shortened. The formula for calculating the next scan time interval is T*N / M. As the time interval shortens, M gradually approaches N, and the time interval gradually returns to T.

[0030] Step 3: Take out the transactions to be executed and put them into the blockchain transaction pool to be packaged: The timed scanning thread takes out the transactions to be executed in batches, executes them using multi-threading technology, and puts them into the blockchain transaction pool to be packaged. The packager then performs the packaging and on-chain operation.

[0031] Step 4: Maintain the on / off state of the packetizer: The program uses a REDIS distributed lock to maintain the on / off state of the packetizer, storing the thread ID within the lock. When uploading a packet to the chain, the program attempts to acquire the lock. If successful, it indicates that the current packetizer is closed, the method acquires the lock, saves the lock value as the current thread ID, and executes the process of opening the packetizer. If acquisition fails, it indicates that the current packetizer is open, the lock value is replaced with the current thread ID, and the step of opening the packetizer is skipped. In the final stage, the program attempts to unlock using the current thread ID. If unlocking is successful, the packetizer is closed.

[0032] Step 5: Dynamically Expanding the Number of Packets: During peak system periods, when the scan time T is shortened to a certain threshold T0, the scanning threads continuously add transactions to be packaged into the blockchain transaction pool, which can easily lead to task backlog. The program will dynamically expand the number of packetizers. T0 is affected by the cluster's computing power and the complexity of on-chain processing; the actual value needs to be determined through online stress testing.

[0033] It is understood that the present invention has been described through some embodiments, and those skilled in the art will recognize that various changes or equivalent substitutions can be made to these features and embodiments without departing from the spirit and scope of the invention. Furthermore, under the teachings of the present invention, these features and embodiments can be modified to adapt to specific situations and materials without departing from the spirit and scope of the invention. Therefore, the present invention is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the protection scope of the present invention.

Claims

1. A method for controlling the blockchain generation rate, characterized in that, Includes the following steps: Step 1: Receive transactions to be executed and add them to the task pool; The program uses REDIS as a task pool for transactions to be executed. Upon receiving a transaction to be executed, it is first placed into the REDIS task pool, and the program starts a separate thread to periodically scan the task pool. Step 2: Regularly scan the task pool; Let the time interval for scanning the task pool be T seconds, and let T change dynamically with the number of tasks in the task pool: Let the packet upper limit of the packetizer be N, and the number of remaining tasks in the task pool after each scan be M. If M is greater than N, the time interval is dynamically shortened. The formula for calculating the time interval of the next scan is T*N / M. As the time interval shortens, M gradually approaches N, and the time interval gradually returns to T. Step 3: Take out the transactions to be executed and put them into the blockchain's transaction pool to be sealed; The timed scanning thread retrieves transactions to be executed in batches. After execution using multi-threading technology, the transactions are placed into the blockchain transaction pool to be packaged, and the packager performs the packaging and on-chain operation. Step 4: Maintain the switch status of the packer; The program uses a REDIS distributed lock to maintain the on / off state of the packet opener. The lock stores the thread number. When performing packet uploading, the program attempts to acquire the lock. If the acquisition is successful, it means that the current packet opener is closed. The program controls the "execute packet opener operation" by locking the lock value and storing it as the current thread number. The program then executes the operation to open the packet opener. If the acquisition fails, it means that the current packetizer is open. Replace the lock value with the current thread number; skip the step of opening the packetizer, and try to unlock it with the current thread number in the final stage. If the unlock is successful, close the packetizer. Step 5: Number of dynamically expanded packetizers; During peak system periods, the scanning time T is shortened to the threshold T0, and the scanning thread continuously adds transactions to be packaged into the blockchain transaction pool, dynamically expanding the number of packagers.

2. The method for controlling the blockchain generation rate according to claim 1, characterized in that, The number of transactions to be executed changes dynamically based on the peak and off-peak periods of system transactions.

3. The method for controlling the blockchain generation rate according to claim 1, characterized in that, The threshold T0 is determined by stress testing based on the cluster's computing power and the complexity of on-chain operations.