CN113326141A - Memory management method and device for block chain nodes - Google Patents

Memory management method and device for block chain nodes Download PDF

Info

Publication number
CN113326141A
CN113326141A CN202110810593.8A CN202110810593A CN113326141A CN 113326141 A CN113326141 A CN 113326141A CN 202110810593 A CN202110810593 A CN 202110810593A CN 113326141 A CN113326141 A CN 113326141A
Authority
CN
China
Prior art keywords
memory
block
data
recovery
current
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110810593.8A
Other languages
Chinese (zh)
Inventor
张锦喜
梁增健
陈胜俭
陈志伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Zhuoqi Cloud Chain Technology Co ltd
Original Assignee
Guangdong Zhuoqi Cloud Chain Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Zhuoqi Cloud Chain Technology Co ltd filed Critical Guangdong Zhuoqi Cloud Chain Technology Co ltd
Priority to CN202110810593.8A priority Critical patent/CN113326141A/en
Publication of CN113326141A publication Critical patent/CN113326141A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a memory management method and a memory management device for a block chain node, wherein the method comprises the following steps: acquiring a data query request; acquiring block data to be inquired according to the data inquiry request; when the block data to be inquired exists in the memory of the block chain node, reading the block data to be inquired from the memory; and when the current first available memory capacity of the memory is judged to be smaller than a preset memory threshold value, performing memory recovery on the memory. The technical problem that the memory use exceeds standard or the data query speed is slow in the existing memory management method of the block chain node is solved.

Description

Memory management method and device for block chain nodes
Technical Field
The present application relates to the field of blockchain technologies, and in particular, to a method and an apparatus for managing memory of blockchain nodes.
Background
With the development of computer technology, the blockchain technology has been widely applied due to the characteristics of decentralization, openness, information non-falsification and the like.
In the block chain technology, the block chain nodes running the block chain procedure often need to query local data, however, due to the randomness of the query data, the block chain nodes cannot determine which data are most frequently used. Therefore, in the memory management method of the existing blockchain node, all data of the whole blockchain is added to the memory, or the data is added to the memory from the hard disk when certain data is inquired. Thus, memory usage is over-standard or data query speed is slow.
Disclosure of Invention
The application provides a memory management method and device for a blockchain node, which avoid the use of exceeding the standard of a memory on the basis of quickly inquiring data through the memory management of the blockchain node, and partially solve the technical problems that the memory use of the existing memory management method for the blockchain node exceeds the standard or the data inquiry speed is slow.
In view of this, a first aspect of the present application provides a memory management method for a blockchain node, including:
acquiring a data query request;
acquiring block data to be inquired according to the data inquiry request;
when the block data to be inquired exists in the memory of the block chain node, reading the block data to be inquired from the memory;
and when the current first available memory capacity of the memory is judged to be smaller than a preset memory threshold value, performing memory recovery on the memory.
Optionally, when it is determined that the current first available memory capacity of the memory is smaller than the preset memory threshold, performing memory recycling on the memory specifically includes:
when the current first available memory capacity of the memory is judged to be smaller than a preset memory threshold value, determining a corresponding memory recovery mode in the current memory recovery according to a memory recovery sequence;
and performing memory recovery on the memory according to the memory recovery mode.
Optionally, the memory recovery sequence is: the forward recovery and the backward recovery are alternately performed.
Optionally, the obtaining block data to be queried according to the data query request specifically includes:
analyzing the data query request to obtain a hash value to be queried;
and acquiring the block data to be inquired corresponding to the hash value to be inquired based on the corresponding relation between the block data to be inquired and the hash value to be inquired according to the hash value to be inquired.
Optionally, the hash value is a data content of the block data to be queried and a latest update time of the block data to be queried in the memory.
Optionally, the memory management method further includes:
when the initialization operation is executed on the block chain link point, the current second memory capacity of the memory is obtained;
acquiring the current block size of a block chain program running in the block chain node;
reading the block data in the block chain into the memory according to the size relationship between the second memory capacity and the current block size;
and updating the updating time of the block data in the memory according to the time for reading the block data into the memory.
Optionally, the reading the block data in the block chain into the memory according to the size relationship between the second memory capacity and the current block size specifically includes:
and judging whether the second memory capacity is larger than the current block size, if so, reading all block data of the block chain into the memory, and if not, reading part of the block data in the block chain into the memory from the tail end of the block chain until the available memory capacity of the block chain is not enough to read a new block.
Optionally, the memory management method further includes:
acquiring a data adding request;
analyzing the data adding request to obtain block data to be added;
when the to-be-added block data does not exist in the memory, adding the to-be-added block data into the memory, and updating the updating time of the to-be-added block in the memory;
and when the data of the block to be added exists in the memory, ending the current process.
Optionally, the adding the data of the block to be added to the memory, and updating the update time of the block to be added in the memory specifically include:
judging whether the current third available memory capacity of the memory is smaller than the preset memory threshold value or not;
when the third available memory capacity is judged to be larger than the preset memory threshold value, adding the data of the block to be added into the memory, and updating the updating time of the block to be added in the memory;
and when the third available memory capacity is judged to be smaller than the preset memory threshold value, after memory recovery is carried out on the memory, adding the block data to be added into the memory, and updating the updating time of the block to be added in the memory.
A second aspect of the present application provides a memory management device for a blockchain node, including:
the first acquisition unit is used for acquiring a data query request;
the first analysis unit is used for acquiring block data to be queried according to the data query request;
the reading unit is used for reading the block data to be inquired from the memory when the block data to be inquired exists in the memory of the block chain node;
the first recovery unit is configured to perform memory recovery on the memory when it is determined that the current first available memory capacity of the memory is smaller than a preset memory threshold.
From the above technical method, the present application has the following advantages:
according to the memory management method, when data needs to be inquired, a data inquiry request is firstly acquired, then block data to be inquired is acquired according to the data inquiry request, whether the block data to be inquired exists in a memory of a block chain node or not is judged, if the block data to be inquired exists, the block data to be inquired is directly read from the memory, the data inquiry speed is guaranteed, and meanwhile when the current first available memory capacity of the memory is judged to be smaller than a preset memory threshold value, memory recycling is conducted on the memory, namely, memory space is released when the memory is insufficient, excessive use of the memory is avoided, and therefore the technical problem that the memory use exceeds the standard or the data inquiry speed is slow in the existing memory management method of the block chain node is solved.
Drawings
In order to more clearly illustrate the technical method in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without inventive labor.
Fig. 1 is a schematic flowchart of a first embodiment of a memory management method for a blockchain node in an embodiment of the present application;
FIG. 2 is a schematic illustration of memory reclamation for blockchain nodes;
FIG. 3 is a specific judgment manner of forward recycling and backward recycling in the embodiment of the present application;
fig. 4 is an explanatory diagram of an initialization process of block link points in the embodiment of the present application;
fig. 5 is an explanatory diagram of addition of block data of block link points in the embodiment of the present application;
fig. 6 is a schematic structural diagram of an embodiment of a memory management device for block link points according to an embodiment of the present disclosure.
Detailed Description
The embodiment of the application provides a memory management method and device for a blockchain node, which solve the technical problems of over standard memory use or slow data query speed of the existing memory management method for the blockchain node.
In order to make the method of the present application better understood, the technical method in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
To facilitate understanding, please refer to fig. 1, where fig. 1 is a schematic flowchart of a first embodiment of a memory management method for a blockchain node in an embodiment of the present application.
In this embodiment, a method for managing a memory of a blockchain node includes:
step 101, obtaining a data query request.
The memory management method in this embodiment may be performed in block link points. It is to be understood that, for example, the preceding block chain node, that is, the running carrier for running the block chain program, may be a computer or a server, and this is not particularly limited in this embodiment.
The data query request may be initiated by other blockchain nodes, that is, one blockchain node obtains data from another blockchain node, and the block chain link node requesting to obtain data initiates a data query request to the requested blockchain node.
And 102, acquiring block data to be inquired according to the data inquiry request.
After the data query request is obtained, the block data to be queried can be obtained according to the data query request.
It is understood that, according to the data query request, the obtaining of the block data to be queried may be:
analyzing the data query request to obtain a hash value to be queried;
and acquiring the block data to be inquired corresponding to the hash value to be inquired based on the corresponding relation between the block data to be inquired and the hash value to be inquired according to the hash value to be inquired.
Specifically, the hash value is the data content of the block data to be queried and the latest update time of the block data to be queried in the memory.
And 103, reading the block data to be inquired from the memory when the block data to be inquired exists in the memory of the block link point.
After the block data to be inquired is determined, whether the block data to be inquired exists in the memory of the block link point is judged, and if the block data to be inquired exists, the block data to be inquired can be read from the memory. And when the data of the block to be inquired does not exist, returning an error and ending the process of the data inquiry request.
And step 104, when the current first available memory capacity of the memory is judged to be smaller than the preset memory threshold value, performing memory recycling on the memory.
When the current first available memory capacity of the memory is judged to be smaller than the preset memory threshold, the fact that the memory of the block chain node is insufficient is described, the memory needs to be recycled at the moment, and the excessive use of the memory is avoided.
In the memory management method in this embodiment, when data needs to be queried, a data query request is first obtained, then block data to be queried can be obtained according to the data query request, then it is determined whether the block data to be queried exists in a memory of a block chain node, if so, the block data to be queried is directly read from the memory, so that a data query speed is ensured, and meanwhile, when it is determined that a current first available memory capacity of the memory is smaller than a preset memory threshold, memory recycling is performed on the memory, that is, a memory space is released when the memory is insufficient, so that excessive use of the memory is avoided, thereby solving the technical problems that the memory use exceeds the standard or the data query speed is slower in the existing memory management method of the block chain node.
The above is a first embodiment of the memory management method for a blockchain node provided in the present embodiment, and the following is a second embodiment of the memory management method for a blockchain node provided in the present embodiment, where the second embodiment describes memory reclamation in detail on the basis of the first embodiment.
Referring to fig. 2, fig. 2 is a schematic diagram illustrating memory reclamation of a blockchain node in the embodiment, where the memory reclamation specifically includes:
step 201, when it is determined that the current first available memory capacity of the memory is smaller than the preset memory threshold, determining a corresponding memory recovery mode in the current memory recovery according to the memory recovery sequence.
It can be understood that the memory recycling sequence in this embodiment may be: the forward recovery and the backward recovery are alternately performed. Namely, after determining the memory recovery starting block, performing forward recovery again, and then performing backward recovery next time. In the embodiment, when the memory is recycled, the principle of alternately updating forwards and backwards is adopted, so that the expired blocks can be updated uniformly, and the memory searching hit rate is improved.
The forward recycling is to select a plurality of blocks from the starting block forward, and recycle the block data of the selected blocks, for example: for the block chain composed of 1-7 blocks connected in sequence, the initial block is block 4, the recovery number is 3, and at this time, the block data of block 4, block 3 and block 2 are recovered when the memory recovery is performed.
And the backward recovery is to recover a plurality of blocks from the starting block backward, and the selected blocks are subjected to the recovery of the block data. For example: for the block chain composed of 1-7 blocks connected in sequence, the initial block is block 4, the recovery number is 3, and at this time, the block data of block 4, block 5 and block 6 are recovered when the memory recovery is performed.
It should be noted that, in different memory reclamation processes, the memory start block may be the same block or different blocks.
Specifically, referring to fig. 3, for a specific judgment manner for specifically performing the forward recycling and the backward recycling, the following manner is set:
the new starting block _ curr, the block start value block _ pre that has been updated are read in.
If block _ pre is less than or equal to block _ curr, recovering memory with RECYCLE _ NUM block sizes from the block _ pre to the block _ curr, and setting the block _ pre as the block _ curr. Otherwise, recovering the memory with the RECYCLE _ NUM block sizes from the block _ curr to the block _ pre, and setting the block _ pre as the block _ curr.
It is understood that RECYCLE _ NUM described above is the number of blocks recovered per round, and is a global constant.
Step 202, performing memory recycle on the memory according to the memory recycle mode.
In this embodiment, the memory of the block link point is recovered by adopting an alternate recovery mode of forward recovery and backward recovery, so that the expired block can be updated uniformly, and the memory search hit rate is improved.
The above embodiment two of the memory management method for a blockchain node provided in the embodiment of the present application is described below as an embodiment three of the memory management method for a blockchain node provided in the embodiment of the present application, and the embodiment three describes in detail an initialization process of a blockchain node on the basis of the embodiment one.
Referring to fig. 4, fig. 4 is an explanatory diagram of an initialization process of a blockchain node in the present embodiment, where the initialization process of the blockchain node in the present embodiment specifically includes:
in step 401, when the initialization operation is executed at the block link point, the current second memory capacity of the memory is obtained.
Step 402, obtaining the current block size of the block chain program running in the block chain node.
Step 403, reading the block data in the block chain into the memory according to the size relationship between the second memory capacity and the current block size.
Specifically, reading the block data in the block chain into the memory according to the size relationship between the second memory capacity and the current block size includes:
and judging whether the second memory capacity is larger than the size of the current block, if so, reading all block data of the block chain into the memory, and if not, reading part of the block data in the block chain into the memory from the tail end of the block chain until the available memory capacity of the block chain is not enough to read a new block.
It can be understood that, in the process of specifically reading the data of the block chain into the memory, the data is read in by means of a hash table. The hash table is used as a basic data structure, so that the hash table is a data structure which is very beneficial to data searching. The search operation in the block chain is the most common operation, and the block data in the block chain is read in a hash table mode, so that the query efficiency of the block data is fundamentally improved, and the memory management of the block chain node is facilitated.
Step 404, updating the update time of the block data in the memory according to the time for reading the block data into the memory.
It can be understood that, when querying data in the blockchain node, the query is based on the aforementioned hash value, and the hash value includes the latest update time of the data to be queried in the memory. Therefore, in order to facilitate the accuracy of subsequent searching, when the block data is read or added into the memory, the update time of the block data in the memory is updated according to the read time or the addition time of the block data.
The above embodiment three of the memory management method for a block chain node provided in the embodiment of the present application is described below as an embodiment four of the memory management method for a block chain node provided in the embodiment of the present application, and the embodiment four describes in detail the process of inserting (adding) block data in a block link point on the basis of the embodiment one.
Referring to fig. 5, fig. 5 is an explanatory diagram of adding block data of a block chain node in the present embodiment, and when data is added to the block chain node in the present embodiment, the adding includes:
step 501, a data adding request is obtained.
It is understood that the data addition request is similar to the data query request, and reference may be specifically made to the description of the data query request, which is not described herein again.
Step 502, analyzing the data adding request to obtain the block data to be added.
For the analysis of the data addition request and the analysis of the data query request are similar, refer to the description of the data query request analysis, which is not described herein again.
Step 503, when it is determined that the block data to be added does not exist in the memory, adding the block data to be added to the memory, and updating the update time of the block to be added in the memory.
Specifically, adding the block data to be added to the memory, and updating the update time of the block to be added in the memory includes:
judging whether the current third available memory capacity of the memory is smaller than a preset memory threshold value or not;
when the third available memory capacity is judged to be larger than the preset memory threshold value, adding the data of the block to be added into the memory, and updating the updating time of the block to be added in the memory;
and when the third available memory capacity is judged to be smaller than the preset memory threshold, adding the data of the block to be added into the memory after the memory is recycled, and updating the updating time of the block to be added in the memory.
It can be understood that, after the block data to be added is added to the memory in step 503, the block data to be added is added to the hard disk corresponding to the block link point.
And step 504, when the block data to be added exists in the memory, ending the current process.
When the block data to be added exists in the memory, it is described that the block data to be added does not need to be added in the block chain node, and the current process is ended at this time.
The above embodiments of the method for managing a memory of a blockchain node according to the present invention are described below in detail with reference to the accompanying drawings.
Referring to fig. 6, the memory management device for a blockchain node in the present embodiment specifically includes:
a first obtaining unit 601, configured to obtain a data query request;
a first parsing unit 602, configured to obtain block data to be queried according to a data query request;
a reading unit 603, configured to read block data to be queried from the memory when it is determined that the block data to be queried exists in the memory of the block link point;
the first recycling unit 604 is configured to recycle the memory of the memory when it is determined that the current first available memory capacity of the memory is smaller than the preset memory threshold.
Further, the first recovery unit 604 specifically includes:
the determining subunit is used for determining a corresponding memory recovery mode in the current memory recovery according to the memory recovery sequence when the current first available memory capacity of the memory is judged to be smaller than the preset memory threshold;
and the memory recovery subunit is used for performing memory recovery on the memory according to the memory recovery mode.
Further, the memory recovery sequence is: the forward recovery and the backward recovery are alternately performed.
Further, the first parsing unit 602 specifically includes:
the analysis subunit is used for analyzing the data query request to obtain a hash value to be queried;
and the acquiring subunit is used for acquiring the block data to be queried corresponding to the hash value to be queried based on the corresponding relation between the block data to be queried and the hash value to be queried according to the hash value to be queried.
Further, the hash value is the data content of the block data to be queried and the latest update time of the block data to be queried in the memory.
Further, the memory management device in this embodiment further includes:
the second obtaining unit is used for obtaining the current second memory capacity of the memory when the initialization operation is executed on the block chain link point;
a third obtaining unit, configured to obtain a current block size of a block chain program running in a block chain node;
the data reading unit is used for reading the block data in the block chain into the memory according to the size relationship between the second memory capacity and the current block size;
and the time updating unit is used for updating the updating time of the block in the memory according to the time for reading the block data into the memory.
Further, the data reading unit is specifically configured to determine whether the second memory capacity is larger than the current block size, if so, add all block data of the block chain to the memory, and if not, add part of the block data in the block chain to the memory from the end of the block chain until the available memory capacity of the block chain is not enough to read in a new block.
Further, the memory management device in this embodiment further includes:
a fourth obtaining unit, configured to obtain a data addition request;
the second analysis unit is used for analyzing the data addition request to obtain block data to be added;
the adding unit is used for adding the block data to be added into the memory and updating the updating time of the block to be added in the memory when the block data to be added does not exist in the memory;
and the ending unit is used for ending the current process when the block data to be added exists in the memory.
Specifically, the adding unit specifically includes:
the judging subunit is configured to judge whether a current third available memory capacity of the memory is smaller than a preset memory threshold;
the first adding subunit is used for adding the data of the block to be added into the memory and updating the updating time of the block to be added in the memory when the third available memory capacity is judged to be larger than the preset memory threshold;
and the second adding subunit is used for adding the block data to be added to the memory and updating the updating time of the block to be added in the memory after the memory is recycled when the third available memory capacity is judged to be smaller than the preset memory threshold.
It can be understood that the embodiment adopts a dynamic memory management method, that is, the memory is monitored during operations such as data initialization, reading, adding, and the like, and when the memory is insufficient, the corresponding memory space is released. Because the node usually causes the memory use change only when the data is read and written, the method avoids newly opening a daemon process for monitoring the memory, reduces the resource waste and simultaneously ensures that the memory resource can not be used beyond the standard.
In the memory management device in this embodiment, when data needs to be queried, a data query request is first obtained, then block data to be queried can be obtained according to the data query request, then it is determined whether the block data to be queried exists in a memory of a block chain node, if so, the block data to be queried is directly read from the memory, so that a data query speed is ensured, and meanwhile, when it is determined that a current first available memory capacity of the memory is smaller than a preset memory threshold, memory recycling is performed on the memory, that is, a memory space is released when the memory is insufficient, so that excessive use of the memory is avoided, thereby solving the technical problems that the memory use exceeds the standard or the data query speed is slower in the existing memory management method of the block chain node.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The terms "first," "second," "third," "fourth," and the like in the description of the application and the above-described figures, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method of the embodiments of the present application. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (9)

1. A memory management method for a blockchain node is characterized by comprising the following steps:
acquiring a data query request;
acquiring block data to be inquired according to the data inquiry request;
when the block data to be inquired exists in the memory of the block chain node, reading the block data to be inquired from the memory;
when the current first available memory capacity of the memory is judged to be smaller than a preset memory threshold value, memory recycling is carried out on the memory;
when it is determined that the current first available memory capacity of the memory is smaller than the preset memory threshold, performing memory recycling on the memory specifically includes:
when the current first available memory capacity of the memory is judged to be smaller than a preset memory threshold value, determining a corresponding memory recovery mode in the current memory recovery according to a memory recovery sequence;
and performing memory recovery on the memory according to the memory recovery mode.
2. The memory management method according to claim 1, wherein the memory reclamation order is: the forward recovery and the backward recovery are alternately performed.
3. The memory management method according to claim 1, wherein the obtaining block data to be queried according to the data query request specifically includes:
analyzing the data query request to obtain a hash value to be queried;
and acquiring the block data to be inquired corresponding to the hash value to be inquired based on the corresponding relation between the block data to be inquired and the hash value to be inquired according to the hash value to be inquired.
4. The memory management method according to claim 3, wherein the hash value is a data content of the block data to be queried and a latest update time of the block data to be queried in the memory.
5. The memory management method according to claim 1, further comprising:
when the initialization operation is executed on the block chain link point, the current second memory capacity of the memory is obtained;
acquiring the current block size of a block chain program running in the block chain node;
reading the block data in the block chain into the memory according to the size relationship between the second memory capacity and the current block size;
and updating the updating time of the block data in the memory according to the time for reading the block data into the memory.
6. The memory management method according to claim 5, wherein the reading block data in the block chain into the memory according to the size relationship between the second memory capacity and the current block size specifically comprises:
and judging whether the second memory capacity is larger than the current block size, if so, reading all block data of the block chain into the memory, and if not, reading part of the block data in the block chain into the memory from the tail end of the block chain until the available memory capacity of the block chain is not enough to read a new block.
7. The memory management method according to claim 1, further comprising:
acquiring a data adding request;
analyzing the data adding request to obtain block data to be added;
when the to-be-added block data does not exist in the memory, adding the to-be-added block data into the memory, and updating the updating time of the to-be-added block in the memory;
and when the data of the block to be added exists in the memory, ending the current process.
8. The method according to claim 7, wherein the adding the data of the block to be added to the memory and updating the update time of the block to be added in the memory includes:
judging whether the current third available memory capacity of the memory is smaller than the preset memory threshold value or not;
when the third available memory capacity is judged to be larger than the preset memory threshold value, adding the data of the block to be added into the memory, and updating the updating time of the block to be added in the memory;
and when the third available memory capacity is judged to be smaller than the preset memory threshold value, after memory recovery is carried out on the memory, adding the block data to be added into the memory, and updating the updating time of the block to be added in the memory.
9. A memory management device for a blockchain node, comprising:
the first acquisition unit is used for acquiring a data query request;
the first analysis unit is used for acquiring block data to be queried according to the data query request;
the reading unit is used for reading the block data to be inquired from the memory when the block data to be inquired exists in the memory of the block chain node;
the first recovery unit is used for recovering the memory when the current first available memory capacity of the memory is judged to be smaller than a preset memory threshold value;
the first recovery unit specifically includes:
the determining subunit is used for determining a corresponding memory recovery mode in the current memory recovery according to the memory recovery sequence when the current first available memory capacity of the memory is judged to be smaller than the preset memory threshold;
and the memory recovery subunit is used for performing memory recovery on the memory according to the memory recovery mode.
CN202110810593.8A 2021-07-19 2021-07-19 Memory management method and device for block chain nodes Pending CN113326141A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110810593.8A CN113326141A (en) 2021-07-19 2021-07-19 Memory management method and device for block chain nodes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110810593.8A CN113326141A (en) 2021-07-19 2021-07-19 Memory management method and device for block chain nodes

Publications (1)

Publication Number Publication Date
CN113326141A true CN113326141A (en) 2021-08-31

Family

ID=77426368

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110810593.8A Pending CN113326141A (en) 2021-07-19 2021-07-19 Memory management method and device for block chain nodes

Country Status (1)

Country Link
CN (1) CN113326141A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114666334A (en) * 2022-04-28 2022-06-24 深圳嘉业产业发展有限公司 Node management method and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105279213A (en) * 2015-03-13 2016-01-27 中国移动通信集团广东有限公司 Retrieval device and retrieval method for log database
CN106681995A (en) * 2015-11-05 2017-05-17 阿里巴巴集团控股有限公司 Data caching method and data query method and device
US20170279774A1 (en) * 2016-03-28 2017-09-28 International Business Machines Corporation Decentralized Autonomous Edge Compute Coordinated by Smart Contract On A Blockchain
CN107220076A (en) * 2016-09-27 2017-09-29 华为技术有限公司 A kind of method for recovering internal storage and device
CN111723077A (en) * 2020-06-24 2020-09-29 中国平安财产保险股份有限公司 Data dictionary maintenance method and device and computer equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105279213A (en) * 2015-03-13 2016-01-27 中国移动通信集团广东有限公司 Retrieval device and retrieval method for log database
CN106681995A (en) * 2015-11-05 2017-05-17 阿里巴巴集团控股有限公司 Data caching method and data query method and device
US20170279774A1 (en) * 2016-03-28 2017-09-28 International Business Machines Corporation Decentralized Autonomous Edge Compute Coordinated by Smart Contract On A Blockchain
CN107220076A (en) * 2016-09-27 2017-09-29 华为技术有限公司 A kind of method for recovering internal storage and device
CN111723077A (en) * 2020-06-24 2020-09-29 中国平安财产保险股份有限公司 Data dictionary maintenance method and device and computer equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JINGWEN LI等: ""Index Design of Electronic Medical Record Database Using Blockchain"", 《2020 5TH INTERNATIONAL CONFERENCE ON MECHANICAL, CONTROL AND COMPUTER ENGINEERING (ICMCCE)》 *
王千阁等: ""区块链系统的数据存储与查询技术综述"", 《计算机科学》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114666334A (en) * 2022-04-28 2022-06-24 深圳嘉业产业发展有限公司 Node management method and system
CN114666334B (en) * 2022-04-28 2024-01-26 深圳嘉业共创供应链管理有限公司 Node management method and system

Similar Documents

Publication Publication Date Title
CN107911249B (en) Method, device and equipment for sending command line of network equipment
CN110018996B (en) Snapshot rollback method and related device of distributed storage system
CN106874281B (en) Method and device for realizing database read-write separation
CN111447248A (en) File transmission method and device
CN111262726B (en) Configuration information updating method and device and computer readable storage medium
CN107704604B (en) Message persistence method, server and computer readable storage medium
CN108228799B (en) Object index information storage method and device
CN109101599B (en) Incremental index updating method and system
CN112328842B (en) Data processing method and device, electronic equipment and storage medium
CN106681995B (en) Data caching method, data query method and device
CN103678337A (en) Data eliminating method, device and system
CN104750738B (en) A kind of method for updating the data information, back end, management node and system
CN108932271B (en) File management method and device
CN108039960B (en) Configuration information issuing method and server
CN110716924B (en) Method and device for deleting expired data
CN113326141A (en) Memory management method and device for block chain nodes
CN113986313A (en) Software upgrading method and device, electronic equipment and storage medium
CN114116795A (en) Data storage and query method, device, storage medium and electronic equipment
CN112463795A (en) Dynamic hash method, device, equipment and storage medium
CN110442439B (en) Task process processing method and device and computer equipment
CN110765125B (en) Method and device for storing data
CN107704329B (en) Message persistence method, server and computer readable storage medium
CN111625617A (en) Data indexing method and device and computer readable storage medium
CN108121514B (en) Meta information updating method and device, computing equipment and computer storage medium
CN110727895A (en) Sensitive word sending method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210831