Movatterモバイル変換


[0]ホーム

URL:


CN115309704A - Blockchain data processing method, server and medium - Google Patents

Blockchain data processing method, server and medium
Download PDF

Info

Publication number
CN115309704A
CN115309704ACN202210851734.5ACN202210851734ACN115309704ACN 115309704 ACN115309704 ACN 115309704ACN 202210851734 ACN202210851734 ACN 202210851734ACN 115309704 ACN115309704 ACN 115309704A
Authority
CN
China
Prior art keywords
handle
file
target
pool
active
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
CN202210851734.5A
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.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian 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 Hangzhou Qulian Technology Co LtdfiledCriticalHangzhou Qulian Technology Co Ltd
Priority to CN202210851734.5ApriorityCriticalpatent/CN115309704A/en
Publication of CN115309704ApublicationCriticalpatent/CN115309704A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

The application is applicable to the technical field of computers, and provides a block chain data processing method, a server and a medium, wherein the method comprises the following steps: receiving operation request information, wherein the operation request information is used for indicating that target operation is executed on a target file on a target block chain; according to the operation request information, searching a target handle corresponding to the target file from a target position, wherein the target handle comprises a target address corresponding to the target file, and the target position comprises any one of the following items: active files, handle pool group; and searching a target file according to the target handle, and executing target operation on the target file. According to the method and the device, the target handle corresponding to the target file can be searched from the active file or the handle pool group, so that the target file can be quickly searched through the target handle, the target file to be operated can be quickly and accurately searched, and the processing efficiency of block chain data is improved.

Description

Translated fromChinese
区块链数据处理方法、服务器及介质Blockchain data processing method, server and medium

技术领域technical field

本申请属于计算机技术领域,尤其涉及一种区块链数据处理方法、服务器及介质。The present application belongs to the field of computer technology, and in particular relates to a block chain data processing method, server and medium.

背景技术Background technique

区块链是一个分布式的共享账本和数据库,具有去中心化、不可篡改、全程留痕、可以追溯、集体维护、公开透明等特点。实践中,一条区块链通常具有多个区块链节点,各区块链节点上所存储的数据相同,且每个区块链节点通常具有一个完整的账本。Blockchain is a distributed shared ledger and database, which has the characteristics of decentralization, non-tampering, traceability throughout the process, traceability, collective maintenance, and openness and transparency. In practice, a blockchain usually has multiple blockchain nodes, the data stored on each blockchain node is the same, and each blockchain node usually has a complete ledger.

相关技术中,需要对区块链中的某个数据进行操作时,通常通过遍历查找的方式从区块链上查找得到该数据,然后对区块链上的该数据进行操作处理。由于区块链中存储的数据量通常非常大,遍历查找的方式容易导致对区块链上的数据的处理效率较低。In related technologies, when it is necessary to operate on certain data in the blockchain, the data is usually searched from the blockchain by means of traversal search, and then the data on the blockchain is operated and processed. Since the amount of data stored in the blockchain is usually very large, the way of traversal search can easily lead to low processing efficiency of the data on the blockchain.

发明内容Contents of the invention

本申请实施例提供了区块链数据处理方法、服务器及介质,旨在解决相关技术中需要对区块链中的某个数据进行操作时,通常通过遍历查找的方式从区块链上查找得到该数据,然后对区块链上的该数据进行操作处理,容易导致对区块链上的数据的处理效率较低的问题。The embodiment of the present application provides a block chain data processing method, server, and medium, aiming to solve the problem that when a certain data in the block chain needs to be operated in related technologies, it is usually found from the block chain by traversal search. The data, and then the data on the block chain is operated and processed, which easily leads to the problem of low processing efficiency of the data on the block chain.

第一方面,本申请实施例提供了一种区块链数据处理方法,该方法包括:接收操作请求信息,操作请求信息用于指示对目标区块链上的目标文件执行目标操作;In the first aspect, the embodiment of the present application provides a block chain data processing method, the method includes: receiving operation request information, the operation request information is used to indicate the target operation is performed on the target file on the target block chain;

根据操作请求信息,从目标位置查找与目标文件对应的目标句柄,其中,目标句柄包括目标文件对应的目标地址,目标位置包括以下任一项:活跃文件、句柄池组;Find the target handle corresponding to the target file from the target location according to the operation request information, wherein the target handle includes the target address corresponding to the target file, and the target location includes any of the following: active file, handle pool group;

根据目标句柄,查找目标文件,以及对目标文件执行目标操作。According to the target handle, find the target file, and perform the target operation on the target file.

在一些实施例中,方法还包括:根据预先确定的句柄池尺寸,创建句柄池组;In some embodiments, the method further includes: creating a handle pool group according to a predetermined size of the handle pool;

其中,句柄池组中包括工作状态相异的两个句柄池,工作状态包括活跃状态和空闲状态,各句柄池中的文件句柄包括文件标识、文件地址和动态引用次数,其中,动态引用次数用于记录相应文件句柄当前被引用的次数。Among them, the handle pool group includes two handle pools with different working states. The working state includes active state and idle state. The file handles in each handle pool include file identification, file address and dynamic reference times. Used to record the number of times the corresponding file handle is currently referenced.

在一些实施例中,根据操作请求信息,从目标位置查找与目标文件对应的目标句柄,包括:In some embodiments, searching for the target handle corresponding to the target file from the target location according to the operation request information includes:

若操作请求信息与活跃文件的文件描述信息相适配,则将活跃文件的文件句柄确定为目标句柄;If the operation request information matches the file description information of the active file, the file handle of the active file is determined as the target handle;

若操作请求信息与活跃文件的文件描述信息不适配,则从句柄池组中查找与操作请求信息相匹配的文件句柄,以及将查找到的文件句柄确定为目标句柄。If the operation request information does not match the file description information of the active file, search for a file handle matching the operation request information from the handle pool group, and determine the found file handle as the target handle.

在一些实施例中,若句柄池组中包括工作状态相异的两个句柄池,则从句柄池组中查找与操作请求信息相匹配的文件句柄,以及将查找到的文件句柄确定为目标句柄,包括:In some embodiments, if the handle pool group includes two handle pools with different working states, search for a file handle matching the operation request information from the handle pool group, and determine the found file handle as the target handle ,include:

从处于活跃状态的句柄池中查找目标句柄,和/或若处于活跃状态的句柄池中不存在目标句柄,则从处于空闲状态的句柄池中查找目标句柄。Look up the target handle from the active handle pool, and/or if the target handle does not exist in the active handle pool, look up the target handle from the idle handle pool.

在一些实施例中,方法还包括:In some embodiments, the method also includes:

若从处于活跃状态的句柄池中查找到目标句柄,则增加处于活跃状态的句柄池中的相应文件句柄的动态引用次数;If the target handle is found from the handle pool in the active state, increase the number of dynamic references of the corresponding file handle in the handle pool in the active state;

若处于活跃状态的句柄池中不存在目标句柄,则根据操作请求信息创建目标句柄,以及将创建的目标句柄存入处于活跃状态的句柄池中。If the target handle does not exist in the handle pool in the active state, the target handle is created according to the operation request information, and the created target handle is stored in the handle pool in the active state.

在一些实施例中,在根据操作请求信息,从目标位置查找与目标文件对应的目标句柄之后,方法还包括:In some embodiments, after searching for the target handle corresponding to the target file from the target location according to the operation request information, the method further includes:

若目标位置不存在与目标文件对应的目标句柄,则遍历目标区块链上存储的区块数据,直至查询得到与操作请求信息相匹配的目标文件;If there is no target handle corresponding to the target file at the target location, traverse the block data stored on the target blockchain until the target file that matches the operation request information is found;

将查询得到的目标文件的文件地址确定为目标地址,以及根据目标文件的文件标识、目标地址和预设引用次数,创建与目标文件对应的目标句柄,以及将目标句柄存入处于活跃状态的句柄池。Determine the file address of the target file obtained from the query as the target address, and create a target handle corresponding to the target file according to the file ID, target address and preset reference times of the target file, and store the target handle into the active handle pool.

在一些实施例中,方法还包括:In some embodiments, the method also includes:

在对目标文件执行目标操作之后,若检测到处于空闲状态的句柄池中还存在目标句柄,则减少处于空闲状态的句柄池中的相应文件句柄的动态引用次数;若检测到处于空闲状态的句柄池中不存在目标句柄,则减少处于活跃状态的句柄池中的相应文件句柄的动态引用次数;After performing the target operation on the target file, if it is detected that there is still a target handle in the handle pool in the idle state, then reduce the number of dynamic references of the corresponding file handle in the handle pool in the idle state; if the handle in the idle state is detected If there is no target handle in the pool, reduce the number of dynamic references of the corresponding file handle in the active handle pool;

将处于空闲状态的句柄池中的、对应动态引用次数为零的文件句柄删除。Delete the file handle whose dynamic reference count is zero in the idle handle pool.

在一些实施例中,方法还包括:In some embodiments, the method also includes:

若句柄池组中包括工作状态相异的两个句柄池,则在预设触发条件被触发时,对两个句柄池的工作状态进行调换,其中,预设触发条件包括以下至少一项:到达预设调换周期、处于活跃状态的句柄池中的文件句柄数目超过预设数目阈值;If the handle pool group includes two handle pools with different working states, the working states of the two handle pools are exchanged when the preset trigger condition is triggered, wherein the preset trigger condition includes at least one of the following: arrival The number of file handles in the preset exchange cycle and the active handle pool exceeds the preset number threshold;

在活跃文件被写满时,上链存储活跃文件以及将活跃文件的文件句柄写入处于活跃状态的句柄池中,创建对应有文件句柄的新的文件,将新的文件切换为活跃文件。When the active file is full, store the active file on the chain and write the file handle of the active file into the active handle pool, create a new file corresponding to the file handle, and switch the new file to the active file.

第二方面,本申请实施例提供了一种区块链数据处理装置,该装置包括:In the second aspect, the embodiment of the present application provides a block chain data processing device, the device comprising:

信息接收单元,用于接收操作请求信息,操作请求信息用于指示对目标区块链上的目标文件执行目标操作;An information receiving unit, configured to receive operation request information, where the operation request information is used to instruct the target operation to be performed on the target file on the target block chain;

句柄查找单元,用于根据操作请求信息,从目标位置查找与目标文件对应的目标句柄,其中,目标句柄包括目标文件对应的目标地址,目标位置包括以下任一项:活跃文件、句柄池组;The handle search unit is used to search the target handle corresponding to the target file from the target location according to the operation request information, wherein the target handle includes the target address corresponding to the target file, and the target location includes any of the following: active file, handle pool group;

操作执行单元,用于根据目标句柄,查找目标文件,以及对目标文件执行目标操作。The operation execution unit is used for searching the target file according to the target handle, and performing the target operation on the target file.

第三方面,本申请实施例提供了一种服务器,包括存储器、处理器以及存储在存储器中并可在处理器上运行的计算机程序,处理器执行计算机程序时实现上述任一项区块链数据处理方法的步骤。In the third aspect, the embodiment of the present application provides a server, including a memory, a processor, and a computer program stored in the memory and operable on the processor. When the processor executes the computer program, any of the above-mentioned blockchain data The steps of the processing method.

第四方面,本申请实施例提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,上述计算机程序被处理器执行时实现上述任一项区块链数据处理方法的步骤。In the fourth aspect, the embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of any one of the above-mentioned blockchain data processing methods are implemented.

第五方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在服务器上运行时,使得服务器执行上述任一项区块链数据处理方法。In the fifth aspect, the embodiment of the present application provides a computer program product, which, when the computer program product runs on the server, causes the server to execute any one of the above-mentioned blockchain data processing methods.

本申请实施例与相关技术相比存在的有益效果是:由于文件句柄通常可以指向相对应的文件的文件地址,因此,从活跃文件或者是句柄池组查找与目标文件对应的目标句柄,从而通过目标句柄快速查找到目标文件,可以实现快速准确地查找到需要被操作的目标文件,有助于提高对区块链数据的处理效率。Compared with the related art, the embodiment of the present application has the beneficial effect that: since the file handle can usually point to the file address of the corresponding file, the target handle corresponding to the target file is searched from the active file or the handle pool group, thereby passing The target handle quickly finds the target file, which can quickly and accurately find the target file that needs to be operated, which helps to improve the processing efficiency of blockchain data.

可以理解的是,上述第二方面至第五方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。It can be understood that, for the beneficial effects of the above-mentioned second aspect to the fifth aspect, reference can be made to the relevant description in the above-mentioned first aspect, and details will not be repeated here.

附图说明Description of drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings that need to be used in the descriptions of the embodiments or related technologies. Obviously, the accompanying drawings in the following description are only some of the present application. Embodiments, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.

图1是本申请一实施例提供的区块链数据处理方法的流程示意图;Fig. 1 is a schematic flow diagram of a block chain data processing method provided by an embodiment of the present application;

图2是本申请另一实施例提供的区块链数据处理方法的流程示意图;Fig. 2 is a schematic flow diagram of a block chain data processing method provided by another embodiment of the present application;

图3是本申请又一实施例提供的区块链数据处理方法的流程示意图;Fig. 3 is a schematic flow diagram of a block chain data processing method provided by another embodiment of the present application;

图4是本申请一实施例提供的区块链数据处理装置的结构示意图;Fig. 4 is a schematic structural diagram of a block chain data processing device provided by an embodiment of the present application;

图5是本申请一实施例提供的服务器的结构示意图。Fig. 5 is a schematic structural diagram of a server provided by an embodiment of the present application.

具体实施方式Detailed ways

以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。In the following description, specific details such as specific system structures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.

应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and/or components, but does not exclude one or more other Presence or addition of features, wholes, steps, operations, elements, components and/or collections thereof.

还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It should also be understood that the term "and/or" used in the description of the present application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

如在本申请说明书和所附权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。As used in this specification and the appended claims, the term "if" may be construed, depending on the context, as "when" or "once" or "in response to determining" or "in response to detecting ". Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be construed, depending on the context, to mean "once determined" or "in response to the determination" or "once detected [the described condition or event] ]” or “in response to detection of [described condition or event]”.

另外,在本申请说明书和所附权利要求书的描述中,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。In addition, in the description of the specification and appended claims of the present application, the terms "first", "second", "third" and so on are only used to distinguish descriptions, and should not be understood as indicating or implying relative importance.

在本申请说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。Reference to "one embodiment" or "some embodiments" or the like in the specification of the present application means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in other embodiments," etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean "one or more but not all embodiments" unless specifically stated otherwise. The terms "including", "comprising", "having" and variations thereof mean "including but not limited to", unless specifically stated otherwise.

为了说明本申请的技术方案,下面通过以下实施例来进行说明。In order to illustrate the technical solution of the present application, the following examples are used for illustration.

继续参阅图1,本申请实施例提供一种区块链数据处理方法,包括:Continuing to refer to Figure 1, the embodiment of the present application provides a blockchain data processing method, including:

步骤101,接收操作请求信息。Step 101, receiving operation request information.

其中,上述操作请求信息用于指示对目标区块链上的目标文件执行目标操作。Wherein, the above-mentioned operation request information is used to indicate to execute the target operation on the target file on the target blockchain.

实践中,操作请求信息中通常包括目标文件的文件标识和用于对目标操作进行描述的操作描述信息。实践中,上述文件标识通常为文件名。上述目标操作可以是对目标文件整体进行操作,也可以是对目标文件中的一个或多个数据进行操作。在上述目标操作为对目标文件中的一个或多个数据进行操作时,上述操作请求信息中还可以包括待操作的数据的数据标识。上述目标文件中的数据可以是交易数据,也可以是日志数据,还可以是其它数据。实际应用中,对目标文件或者是目标文件中的数据所执行的操作可以包括但不限于:回滚操作(reset)、删除操作(delete)、复制操作(copy)、恢复操作(restore)等。In practice, the operation request information usually includes the file identifier of the target file and operation description information used to describe the target operation. In practice, the above-mentioned file identification is usually a file name. The above target operation may be performed on the entire target file, or may be performed on one or more pieces of data in the target file. When the target operation is to operate on one or more data in the target file, the operation request information may further include a data identifier of the data to be operated. The data in the above target file may be transaction data, log data, or other data. In practical applications, the operations performed on the target file or the data in the target file may include but not limited to: rollback operation (reset), delete operation (delete), copy operation (copy), restore operation (restore) and so on.

在本实施例中,上述区块链数据处理方法的执行主体通常为上述目标区块链,具体可以为上述目标区块链上的各个区块链节点。实际应用中,每个区块链节点可以实现成终端也可以实现成服务器。In this embodiment, the execution subject of the above-mentioned blockchain data processing method is usually the above-mentioned target blockchain, specifically each blockchain node on the above-mentioned target blockchain. In practical applications, each blockchain node can be implemented as a terminal or as a server.

实践中,上述执行主体可以从通信连接的用户端接收到上述操作请求信息,也可以从其它区块链接收到上述操作请求信息。In practice, the above-mentioned execution subject may receive the above-mentioned operation request information from the communication-connected client, or may receive the above-mentioned operation request information from other blockchain links.

步骤102,根据操作请求信息,从目标位置查找与目标文件对应的目标句柄。Step 102, according to the operation request information, search for the target handle corresponding to the target file from the target location.

其中,目标句柄包括目标文件对应的目标地址。目标位置包括以下任一项:活跃文件、句柄池组。Wherein, the target handle includes the target address corresponding to the target file. Destinations include any of the following: active files, handle pool groups.

其中,上述目标句柄通常是目标文件对应的文件句柄。上述目标地址通常是上述目标文件的文件地址。上述活跃文件通常是区块链节点中尚未上链存储的处于被写入状态的文件。Wherein, the above target handle is usually a file handle corresponding to the target file. The above-mentioned target address is usually the file address of the above-mentioned target file. The above-mentioned active files are usually files in the state of being written that have not yet been stored on the chain in the blockchain node.

实践中,上述句柄池组通常是预先建立的多个句柄池的组合。句柄池组中的句柄池可以有两个也可以有多个。设置多个句柄池,可以实现对各个句柄池中的文件句柄进行独立管理,比如,在某个时间段,可以让一些句柄池正常使用,以及让另一些句柄池对长期未被使用的文件句柄清除。多个句柄池并行工作,可以及时对长期未被使用的文件句柄清除,这样,每个句柄池的容量无需太大。一方面可以保障对目标文件的查找效率,另一方面可以节省所有句柄池所占的存储空间。需要指出的是,上述句柄池通常是用于存放文件句柄的存储空间。句柄池组中的每个句柄池可以实现成数据队列。In practice, the above handle pool group is usually a combination of multiple handle pools established in advance. There can be two or more handle pools in a handle pool group. Setting multiple handle pools can realize independent management of file handles in each handle pool. For example, in a certain period of time, some handle pools can be used normally, and other handle pools can be used for file handles that have not been used for a long time. clear. Multiple handle pools work in parallel, and the file handles that have not been used for a long time can be cleared in time, so that the capacity of each handle pool does not need to be too large. On the one hand, it can guarantee the search efficiency of the target file, and on the other hand, it can save the storage space occupied by all handle pools. It should be pointed out that the above-mentioned handle pool is usually a storage space for storing file handles. Each handle pool in the handle pool group can be implemented as a data queue.

实际应用中,句柄池组中通常包括工作状态相异的两个句柄池,且通常是一个处于活跃状态,另一个处于空闲状态。处于空闲状态的句柄池负责及时清除长期未被使用的文件句柄。处于活跃状态的句柄池负责新的文件句柄的添加及引用等。两个句柄池的工作状态通常可以相互调换。比如,可以在间隔2分钟之后,将原本处于活跃状态的句柄池切换为处于空闲状态,以及将原本处于空闲状态的句柄池切换为处于活跃状态。这样可以实现及时有效地对未使用的文件句柄进行清除,可以进一步节约存储空间。In practical applications, the handle pool group usually includes two handle pools with different working states, and usually one is in an active state and the other is in an idle state. The handle pool in the idle state is responsible for clearing the file handles that have not been used for a long time in time. The active handle pool is responsible for adding and referencing new file handles. The working status of the two handle pools can usually be exchanged with each other. For example, after an interval of 2 minutes, the handle pool that was originally in an active state can be switched to an idle state, and the handle pool that was originally in an idle state can be switched to an active state. In this way, unused file handles can be cleared in a timely and effective manner, and storage space can be further saved.

另外,在每个句柄池中的文件句柄包括文件标识、文件地址和动态引用次数的情况下,可以及时将处于空闲状态的句柄池中动态引用次数为零的文件句柄删除。其中,动态引用次数用于记录相应文件句柄当前被引用的次数。举例来说,若句柄池A中的一个文件句柄1的动态引用次数为5,则表明该文件句柄1当前正在被5个请求方调用。每个文件句柄支持同时被多个请求方调用,实用性高灵活性较好。实际应用中,文件句柄中还可以包括其它信息,比如,还可以包括文件当前状态。文件当前状态可以用于标识该文件句柄对应的文件当前被操作的状态。文件当前状态可以包括操作状态和空闲状态。举例来说,在即将对某个文件进行操作之时,可以将该文件的文件当前状态标记为操作状态,在对该文件执行操作之后,可以将该文件的文件当前状态标记为空闲状态。In addition, when the file handles in each handle pool include file identifiers, file addresses, and dynamic reference times, file handles with zero dynamic reference times in the idle handle pool can be deleted in time. Wherein, the dynamic reference count is used to record the current reference count of the corresponding file handle. For example, if the number of dynamic references of a file handle 1 in the handle pool A is 5, it indicates that the file handle 1 is currently being called by 5 requesters. Each file handle supports being called by multiple requesters at the same time, which has high practicability and good flexibility. In practical applications, the file handle may also include other information, for example, the current status of the file may also be included. The current state of the file can be used to identify the current state of the file corresponding to the file handle being operated. The current state of the file may include an operating state and an idle state. For example, when an operation is about to be performed on a certain file, the current state of the file may be marked as the operating state, and after the operation is performed on the file, the current state of the file may be marked as the idle state.

其中,上述活跃文件,通常是区块链节点中尚未上链存储的处于被写入状态的文件。活跃文件中可以被先后写入多条数据。在活跃文件被写满时,上述执行主体可以将活跃文件的文件句柄写入处于活跃状态的句柄池中。实际应用中,活跃文件的文件句柄写入处于活跃状态的句柄池时,新添加至处于活跃状态的句柄池中的文件句柄可以包括该活跃文件的文件名、该活跃文件被存储在区块链上的文件地址、初始引用次数。其中,初始引用次数通常是预先设定的次数值。实际应用中,初始引用次数通常为0。Among them, the above-mentioned active files are usually files in the state of being written that have not been stored on the chain in the blockchain node. Multiple pieces of data can be written successively in the active file. When the active file is full, the execution subject may write the file handle of the active file into the handle pool in an active state. In practical applications, when the file handle of the active file is written into the handle pool in the active state, the file handle newly added to the handle pool in the active state can include the file name of the active file, the active file is stored in the blockchain The file address and initial reference count on the . Wherein, the initial number of references is usually a preset number of times. In practical applications, the initial reference count is usually 0.

需要指出的是,在当前的活跃文件被写满以及被上链存储时,上述执行主体可以生成用于写入数据的新的活跃文件,以及给新的活跃文件创建对应的文件句柄,以此类推。It should be pointed out that when the current active file is full and stored on the chain, the above execution subject can generate a new active file for writing data, and create a corresponding file handle for the new active file, so as to analogy.

这里,上述执行主体可以采用操作请求信息,从目标位置查找与目标文件对应的目标句柄。Here, the execution subject may use the operation request information to search for the target handle corresponding to the target file from the target location.

作为一个示例,上述执行主体可以采用操作请求信息所包括的文件标识,与活跃文件的文件标识进行比较,若二者相一致,则可以确定当前的活跃文件即为为上述目标文件,此时,可以直接将活跃文件对应的文件句柄确定为上述目标句柄。As an example, the above-mentioned execution subject may use the file identifier included in the operation request information to compare it with the file identifier of the active file. If the two are consistent, it can be determined that the current active file is the above-mentioned target file. At this time, The file handle corresponding to the active file may be directly determined as the above-mentioned target handle.

作为另一个示例,上述执行主体可以采用操作请求信息所包括的文件标识,从句柄池组中,查找对应文件标识与目标文件的文件标识相同的文件句柄,以及将查找到的文件句柄确定为上述目标句柄。As another example, the above execution subject may use the file identifier included in the operation request information to search for a file handle whose corresponding file identifier is the same as the file identifier of the target file from the handle pool group, and determine the found file handle as the above-mentioned target handle.

步骤103,根据目标句柄,查找目标文件,以及对目标文件执行目标操作。Step 103, according to the target handle, search for the target file, and execute the target operation on the target file.

这里,在得到目标文件对应的目标句柄之后,由于目标句柄可以指向目标文件的文件地址,故而上述执行主体可以直接采用目标句柄找到目标文件,以及对目标文件执行上述目标操作。Here, after obtaining the target handle corresponding to the target file, since the target handle can point to the file address of the target file, the execution subject can directly use the target handle to find the target file, and perform the above target operation on the target file.

本实施例提供的方法,由于文件句柄通常可以指向相对应的文件的文件地址,因此,从活跃文件或者是句柄池组查找与目标文件对应的目标句柄,从而通过目标句柄快速查找到目标文件,可以实现快速准确地查找到需要被操作的目标文件,有助于提高对区块链数据的处理效率。In the method provided by this embodiment, since the file handle can usually point to the file address of the corresponding file, the target handle corresponding to the target file is searched from the active file or the handle pool group, thereby quickly finding the target file through the target handle, It can quickly and accurately find the target file that needs to be operated, which helps to improve the processing efficiency of blockchain data.

继续参考图2,为本申请实施例提供的一种区块链数据处理方法的流程示意图。如图2所示的区块链数据处理方法,可以包括如下步骤201至步骤204。Continue to refer to FIG. 2 , which is a schematic flowchart of a blockchain data processing method provided by the embodiment of the present application. The blockchain data processing method shown in FIG. 2 may include the followingsteps 201 to 204.

步骤201,根据预先确定的句柄池尺寸,创建句柄池组。Step 201, create a handle pool group according to a predetermined size of the handle pool.

其中,句柄池组中包括工作状态相异的两个句柄池。工作状态可以包括活跃状态和空闲状态。各句柄池中的文件句柄包括文件标识、文件地址和动态引用次数。其中,动态引用次数用于记录相应文件句柄当前被引用的次数。需要指出的是,在某个句柄池中的某个句柄文件的动态引用次数不为1时,表明该文件句柄正在被多个请求方调用。举例来说,若句柄池A中的一个文件句柄1的动态引用次数为5,则表明该文件句柄1当前正在被5个请求方调用。每个文件句柄支持同时被多个请求方调用,实用性高灵活性较好。Wherein, the handle pool group includes two handle pools with different working states. Working states may include active states and idle states. The file handles in each handle pool include file identifiers, file addresses and dynamic reference times. Wherein, the dynamic reference count is used to record the current reference count of the corresponding file handle. It should be pointed out that when the number of dynamic references of a handle file in a handle pool is not 1, it indicates that the file handle is being called by multiple requesters. For example, if the number of dynamic references of a file handle 1 in the handle pool A is 5, it indicates that the file handle 1 is currently being called by 5 requesters. Each file handle supports being called by multiple requesters at the same time, which has high practicability and good flexibility.

实际应用中,句柄池组中通常包括工作状态相异的两个句柄池,且通常是一个处于活跃状态,另一个处于空闲状态。处于空闲状态的句柄池负责及时清除长期未被使用的文件句柄。处于活跃状态的句柄池负责新的文件句柄的添加及引用等。两个句柄池的工作状态通常可以相互调换。比如,在间隔一段时间后,可以将原本处于活跃状态的句柄池切换为处于空闲状态,以及将原本处于空闲状态的句柄池切换为处于活跃状态。这样可以实现及时有效地对未使用的文件句柄进行清除,可以进一步节约存储空间。In practical applications, the handle pool group usually includes two handle pools with different working states, and usually one is in an active state and the other is in an idle state. The handle pool in the idle state is responsible for clearing the file handles that have not been used for a long time in time. The active handle pool is responsible for adding and referencing new file handles. The working status of the two handle pools can usually be exchanged with each other. For example, after a period of time, the handle pool that was originally in an active state can be switched to be in an idle state, and the handle pool that was originally in an idle state can be switched to be in an active state. In this way, unused file handles can be cleared in a timely and effective manner, and storage space can be further saved.

另外,在每个句柄池中的文件句柄包括文件标识、文件地址和动态引用次数的情况下,可以及时将处于空闲状态的句柄池中动态引用次数为零的文件句柄删除。在每个句柄池中的文件句柄还包括文件当前状态的情况下,可以及时将处于空闲状态的句柄池中的、动态引用次数为零且对应文件当前状态为空闲状态的文件句柄删除。In addition, when the file handles in each handle pool include file identifiers, file addresses, and dynamic reference times, file handles with zero dynamic reference times in the idle handle pool can be deleted in time. In the case that the file handles in each handle pool also include the current state of the file, the file handles in the handle pool in the idle state, whose dynamic reference count is zero and whose current state is idle, can be deleted in time.

其中,上述句柄池尺寸通常可以指示句柄池的容量大小。实践中,上述句柄池尺寸可以是用户端输入的,也可以是默认设置的。需要指出的是,句柄池的容量通常是指句柄池所能容量的文件句柄的数量。Wherein, the above handle pool size may generally indicate the capacity of the handle pool. In practice, the size of the above handle pool may be input by the user terminal, or may be set by default. It should be pointed out that the capacity of the handle pool usually refers to the number of file handles that the handle pool can hold.

实践中,上述句柄池通常是用于存放文件句柄的存储空间。句柄池组中的每个句柄池可以实现成数据队列。In practice, the above-mentioned handle pool is usually a storage space for storing file handles. Each handle pool in the handle pool group can be implemented as a data queue.

这里,上述执行主体可以采用上述句柄池尺寸,创建多个句柄池,从而得到上述句柄池组。举例来说,若句柄池尺寸指示句柄池的容量大小为100,则上述执行主体可以分配一块能够容纳100个文件句柄的存储空间,该存储空间即为句柄池。Here, the above-mentioned execution subject may use the size of the above-mentioned handle pool to create multiple handle pools, so as to obtain the above-mentioned handle pool group. For example, if the size of the handle pool indicates that the capacity of the handle pool is 100, the execution subject may allocate a storage space capable of accommodating 100 file handles, and the storage space is the handle pool.

需要指出的是,句柄池组中的每个句柄池的大小相同,便于管理与维护。另外,缺省情况下,句柄池为空,也即是,未被使用的情况下,句柄池中没有存储文件句柄。It should be pointed out that the size of each handle pool in the handle pool group is the same, which is convenient for management and maintenance. In addition, by default, the handle pool is empty, that is, if it is not used, no file handle is stored in the handle pool.

步骤202,接收操作请求信息。Step 202, receiving operation request information.

其中,操作请求信息用于指示对目标区块链上的目标文件执行目标操作。Wherein, the operation request information is used to indicate to execute the target operation on the target file on the target blockchain.

步骤203,根据操作请求信息,从目标位置查找与目标文件对应的目标句柄。Step 203, according to the operation request information, search for the target handle corresponding to the target file from the target location.

其中,目标句柄包括目标文件对应的目标地址,目标位置包括以下任一项:活跃文件、句柄池组。Wherein, the target handle includes the target address corresponding to the target file, and the target location includes any of the following items: active file, handle pool group.

步骤204,根据目标句柄,查找目标文件,以及对目标文件执行目标操作。Step 204, according to the target handle, search for the target file, and execute the target operation on the target file.

在本实施例中,步骤202-步骤204的具体操作与图1所示的实施例中步骤101-步骤103的操作基本相同,在此不做赘述。In this embodiment, the specific operations ofsteps 202 to 204 are basically the same as the operations ofsteps 101 to 103 in the embodiment shown in FIG. 1 , and will not be repeated here.

本实施例可以创建两个工作状态相异的句柄池,一个处于活跃状态,另一个处于空闲状态。处于空闲状态的句柄池负责及时清除长期未被使用的文件句柄。处于活跃状态的句柄池负责新的文件句柄的添加及引用等。两个句柄池并行工作,且两个句柄池的工作状态可以相互调换,可以实现及时将不被使用的文件句柄清除。这样,每个句柄池的容量无需太大,一方面可以保障对目标文件的查找效率,另一方面可以进一步节省所有句柄池所占的存储空间。In this embodiment, two handle pools with different working states can be created, one is active and the other is idle. The handle pool in the idle state is responsible for clearing the file handles that have not been used for a long time in time. The active handle pool is responsible for adding and referencing new file handles. The two handle pools work in parallel, and the working status of the two handle pools can be exchanged with each other, which can realize timely clearing of unused file handles. In this way, the capacity of each handle pool does not need to be too large. On the one hand, the search efficiency of the target file can be guaranteed, and on the other hand, the storage space occupied by all the handle pools can be further saved.

在一些可选的实现方式中,上述根据操作请求信息,从目标位置查找与目标文件对应的目标句柄,可以包括如下第一步和第二步。In some optional implementation manners, searching for the target handle corresponding to the target file from the target location according to the operation request information may include the following first and second steps.

第一步,若操作请求信息与活跃文件的文件描述信息相适配,则将活跃文件的文件句柄确定为目标句柄。In the first step, if the operation request information matches the file description information of the active file, the file handle of the active file is determined as the target handle.

其中,上述活跃文件的文件描述信息通常是用于对活跃文件进行描述的信息。实践中,活跃文件的文件描述信息通常包括活跃文件的文件标识。Wherein, the above-mentioned file description information of the active file is generally information used to describe the active file. In practice, the file description information of the active file usually includes the file identifier of the active file.

这里,上述执行主体可以采用操作请求信息所包括的目标文件的文件标识,与活跃文件的文件描述信息所包括的文件标识进行比较,若二者一致,则可以认为活跃文件即为所需查找的目标文件。此时,可以将活跃文件对应的文件句柄确定为上述目标句柄。Here, the above-mentioned execution subject can use the file identification of the target file included in the operation request information to compare with the file identification included in the file description information of the active file. If the two are consistent, it can be considered that the active file is the one to be searched. target document. At this point, the file handle corresponding to the active file may be determined as the above-mentioned target handle.

第二步,若操作请求信息与活跃文件的文件描述信息不适配,则从句柄池组中查找与操作请求信息相匹配的文件句柄,以及将查找到的文件句柄确定为目标句柄。In the second step, if the operation request information does not match the file description information of the active file, search for a file handle matching the operation request information from the handle pool group, and determine the found file handle as the target handle.

这里,在操作请求信息与活跃文件的文件描述信息不适配时,表明所需查找的目标文件并非当前的活跃文件。此时,上述执行主体可以采用操作请求信息所包括的文件标识,继续从句柄池组中,查找对应文件标识与目标文件的文件标识相同的文件句柄。在从句柄池组中查找到对应文件标识与目标文件的文件标识相同的文件句柄的情况下,可以将查找到的文件句柄确定为上述目标句柄。Here, when the operation request information does not match the file description information of the active file, it indicates that the target file to be searched is not the current active file. At this time, the above-mentioned execution subject may use the file identifier included in the operation request information to continue to search for a file handle whose corresponding file identifier is the same as the file identifier of the target file from the handle pool group. In the case that a file handle whose corresponding file ID is the same as that of the target file is found from the handle pool group, the found file handle may be determined as the above-mentioned target handle.

本实现方式中,优先从活跃文件处查找目标句柄,在活跃文件的文件句柄不为目标句柄的情况下,再从句柄池组中查找目标句柄,可以实现从多个位置有序查找,有助于提高查找效率。In this implementation, the target handle is first searched from the active file, and when the file handle of the active file is not the target handle, the target handle is searched from the handle pool group, which can realize orderly search from multiple locations, which is helpful to improve search efficiency.

在一些可选的实现方式中,上述第二步中,从句柄池组中查找与操作请求信息相匹配的文件句柄,以及将查找到的文件句柄确定为目标句柄,可以包括:从处于活跃状态的句柄池中查找目标句柄,和/或若处于活跃状态的句柄池中不存在目标句柄,则从处于空闲状态的句柄池中查找目标句柄。In some optional implementations, in the above second step, searching for a file handle matching the operation request information from the handle pool group, and determining the found file handle as the target handle may include: Look up the target handle in the handle pool of the active state, and/or if the target handle does not exist in the handle pool in the active state, look for the target handle in the handle pool in the idle state.

这里,句柄池组中包括工作状态相异的两个句柄池。此时,上述执行主体可以仅从处于活跃状态的句柄池中查找目标句柄。也可以先从处于活跃状态的句柄池中查找目标句柄。在处于活跃状态的句柄池中不存在该目标句柄的情况下,再从处于空闲状态的句柄池中查找目标句柄。Here, the handle pool group includes two handle pools with different working states. At this point, the above execution subject may only search for the target handle from the handle pool in an active state. Alternatively, the target handle can be searched first from the active handle pool. If the target handle does not exist in the handle pool in the active state, look for the target handle in the handle pool in the idle state.

在仅从处于活跃状态的句柄池中查找目标句柄的情况下,若处于活跃状态的句柄池中不存在目标句柄,则上述执行主体可以认为目标位置不存在与目标文件对应的目标句柄。此时,上述执行主体可以通过遍历区块链上存储的区块数据的方式,查找得到目标文件及用于存储目标文件的文件地址,以及针对查找到的该目标文件创建目标句柄。由于处于空闲状态的句柄池负责及时清除长期未被使用的文件句柄,且处于活跃状态的句柄池负责新的文件句柄的添加及引用等。因此,仅从处于活跃状态的句柄池中查找目标句柄,两个句柄池分工无交叉,可以简化操作,保障两个句柄池高效地进行并行工作。In the case of searching for the target handle only from the handle pool in the active state, if the target handle does not exist in the handle pool in the active state, the execution subject may consider that there is no target handle corresponding to the target file in the target location. At this point, the execution subject can find the target file and the file address used to store the target file by traversing the block data stored on the blockchain, and create a target handle for the found target file. Because the handle pool in the idle state is responsible for clearing the file handles that have not been used for a long time in time, and the handle pool in the active state is responsible for adding and referencing new file handles. Therefore, the target handle is only searched from the handle pool in the active state, and the division of labor between the two handle pools does not overlap, which can simplify operations and ensure that the two handle pools can work efficiently in parallel.

需要指出的是,由于目标句柄可能同时存在于多个句柄池中的情况,优先从处于活跃状态的句柄池中查找的方式,可以实现更加高效有序地进行信息查找,有助于进一步提高查找效率。另外,由于处于空闲状态的句柄池的主要职责在于及时对不使用的文件句柄进行清理,优先从处于活跃状态的句柄池中查找的方式,可以保障两个句柄池更加高效地进行并行工作。It should be pointed out that since the target handle may exist in multiple handle pools at the same time, the method of searching from the handle pool in the active state can be used to search for information more efficiently and orderly, which helps to further improve the search process. efficiency. In addition, since the main responsibility of the handle pool in the idle state is to clean up unused file handles in a timely manner, the method of searching from the handle pool in the active state first can ensure that the two handle pools can work in parallel more efficiently.

在一些实施例的可选的实现方式中,若句柄池组中包括工作状态相异的两个句柄池,则上述执行主体在采用操作请求信息,从目标位置查找与目标文件对应的目标句柄的过程中,通常遵循如下查找顺序:首先,从活跃文件的文件句柄处查找目标句柄。之后,若活跃文件的文件句柄不为目标句柄,则从处于活跃状态的句柄池中查找目标句柄。最后,若处于活跃状态的句柄池中不存在目标句柄,则从处于空闲状态的句柄池中查找目标句柄。In an optional implementation of some embodiments, if the handle pool group includes two handle pools with different working states, the execution subject uses the operation request information to search for the target handle corresponding to the target file from the target location During the process, the following search order is usually followed: First, the target handle is searched from the file handle of the active file. Afterwards, if the file handle of the active file is not the target handle, the target handle is searched from the active handle pool. Finally, if the target handle does not exist in the handle pool in the active state, the target handle is searched from the handle pool in the idle state.

另外,在各个目标位置均不存在上述目标句柄的情况下,上述执行主体可以通过遍历区块链上存储的区块数据的方式,查找得到目标文件及用于存储目标文件的文件地址。此时,上述执行主体还可以针对查找到的该目标文件创建目标句柄,并存入处于活跃状态的句柄池中。这样,在下一次需要对该目标文件进行操作时,可以通过该目标文件对应的文件句柄快速查找到该目标文件,从而提高区块链数据处理效率。In addition, in the case that the above-mentioned target handle does not exist in each target location, the above-mentioned execution subject can find the target file and the file address used to store the target file by traversing the block data stored on the blockchain. At this time, the above-mentioned execution subject may also create a target handle for the found target file, and store it in an active handle pool. In this way, when the target file needs to be operated next time, the target file can be quickly found through the file handle corresponding to the target file, thereby improving the blockchain data processing efficiency.

在各个实施例的可选的实现方式中,若句柄池组中包括工作状态相异的两个句柄池,且各句柄池中的文件句柄包括文件标识、文件地址和动态引用次数,则上述区块链数据处理方法还可以包括如下步骤一和步骤二。In an optional implementation of each embodiment, if the handle pool group includes two handle pools with different working states, and the file handles in each handle pool include file identifiers, file addresses, and dynamic reference times, the above-mentioned area The block chain data processing method may also include the following steps 1 and 2.

步骤一,若从处于活跃状态的句柄池中查找到目标句柄,则增加处于活跃状态的句柄池中的相应文件句柄的动态引用次数。Step 1: If the target handle is found from the handle pool in the active state, increase the number of dynamic references of the corresponding file handle in the handle pool in the active state.

这里,若目标句柄存在于处于活跃状态的句柄池中,则在查找到该目标句柄时,上述执行主体可以按照预先设定的增加方式,增加处于活跃状态的句柄池中的相应文件句柄的动态引用次数。其中,上述增加方式可以为每次增加1,也可以是每次增加2,还可以是其它增加方式。实践中,通常是每次增加1。Here, if the target handle exists in the handle pool in the active state, when the target handle is found, the execution subject can increase the dynamics of the corresponding file handle in the handle pool in the active state according to the preset increase method. Citations. Wherein, the above-mentioned increasing manner may be 1 each time, or 2 each time, or other increasing manners. In practice, it is usually increased by 1 each time.

举例来说,若目标句柄存在于处于活跃状态的句柄池A中,且具体为句柄池A中的文件句柄1,那么,在查找得到该目标句柄时,可以对句柄池A中的文件句柄1的动态引用次数增加1。For example, if the target handle exists in handle pool A that is active, and is specifically file handle 1 in handle pool A, then, when the target handle is found, the file handle 1 in handle pool A can be The dynamic reference count of is increased by 1.

步骤二,若处于活跃状态的句柄池中不存在目标句柄,则根据操作请求信息创建目标句柄,以及将创建的目标句柄存入处于活跃状态的句柄池中。Step 2: If the target handle does not exist in the handle pool in the active state, create a target handle according to the operation request information, and store the created target handle in the handle pool in the active state.

这里,在仅从处于活跃状态的句柄池中查找目标句柄的情况下,若处于活跃状态的句柄池中不存在目标句柄,则上述执行主体可以认为目标位置不存在与目标文件对应的目标句柄。此时,上述执行主体可以通过如下方式创建目标句柄:遍历区块链上存储的区块数据,以查找得到与操作请求信息相匹配的目标文件及用于存储目标文件的文件地址,然后,采用目标文件的文件地址、文件标识和预设引用次数创建得到上述目标句柄。其中,上述预设引用次数通常是预先设定的次数。实践中,上述预设引用次数通常是1。Here, in the case of only looking for the target handle from the handle pool in the active state, if the target handle does not exist in the handle pool in the active state, the execution subject may consider that there is no target handle corresponding to the target file in the target location. At this time, the above execution subject can create the target handle in the following way: traverse the block data stored on the blockchain to find the target file matching the operation request information and the file address used to store the target file, and then use The file address, file identifier and preset reference count of the target file are created to obtain the above target handle. Wherein, the above-mentioned preset number of references is usually a preset number of times. In practice, the above preset number of references is usually 1.

另外,在可以先后从两个句柄池中查找目标句柄的情况下,若目标句柄不存在于处于活跃状态的句柄池中,但存在于处于空闲状态的句柄池中。此时,上述执行主体可以通过如下方式创建目标句柄:从处于空闲状态的句柄池中查找到与操作请求信息相匹配的目标句柄,然后,基于查找到的目标句柄和预设引用次数创建得到上述目标句柄。其中,新创建的上述目标句柄的动态引用次数通常为预设引用次数。In addition, in the case that the target handle can be searched from the two handle pools successively, if the target handle does not exist in the handle pool in the active state, but exists in the handle pool in the idle state. At this point, the above execution subject can create the target handle in the following way: Find the target handle that matches the operation request information from the handle pool in the idle state, and then create the above-mentioned target handle based on the found target handle and the preset number of references target handle. Wherein, the dynamic reference count of the above-mentioned newly created target handle is usually a preset reference count.

需要指出的是,由于处于活跃状态的句柄池的主要职责在于对新的文件句柄进行添加及引用。在目标句柄不存在于处于活跃状态的句柄池,但存在于处于空闲状态的句柄池的情况下,基于从处于空闲状态的句柄池查找到的目标句柄,创建目标句柄并放入处于活跃状态的句柄池中,可以实现及时在处于活跃状态的句柄池中创建目标句柄,可以保障两个句柄池更加高效地进行并行工作。It should be pointed out that the main responsibility of the active handle pool is to add and reference new file handles. If the target handle does not exist in the active handle pool but exists in the idle handle pool, based on the target handle found from the idle handle pool, create the target handle and put it in the active In the handle pool, the target handle can be created in the active handle pool in time, which can ensure that the two handle pools can work in parallel more efficiently.

在一些可选的实现方式中,上述区块链数据处理方法还可以包括如下步骤三和步骤四。In some optional implementation manners, the above block chain data processing method may also include the following steps 3 and 4.

步骤三,在对目标文件执行目标操作之后,根据目标句柄在处于空闲状态的句柄池中的存在情况,减少目标句柄池中的相应文件句柄的动态引用次数。其中,目标句柄池,可以包括处于空闲状态的句柄池和处于活跃状态的句柄池。Step 3: After the target operation is performed on the target file, according to the existence of the target handle in the idle handle pool, the number of dynamic references of the corresponding file handle in the target handle pool is reduced. Wherein, the target handle pool may include a handle pool in an idle state and a handle pool in an active state.

实践中,上述根据目标句柄在处于空闲状态的句柄池中的存在情况,减少目标句柄池中的相应文件句柄的动态引用次数,包括:若检测到处于空闲状态的句柄池中还存在目标句柄,则减少处于空闲状态的句柄池中的相应文件句柄的动态引用次数。若检测到处于空闲状态的句柄池中不存在目标句柄,则减少处于活跃状态的句柄池中的相应文件句柄的动态引用次数。In practice, according to the existence of the target handle in the handle pool in the idle state, the number of dynamic references of the corresponding file handle in the target handle pool is reduced, including: if it is detected that the target handle still exists in the handle pool in the idle state, Then reduce the number of dynamic references of the corresponding file handle in the handle pool in the idle state. If it is detected that the target handle does not exist in the handle pool in the idle state, then reduce the number of dynamic references of the corresponding file handle in the handle pool in the active state.

这里,在对目标文件执行目标操作之后,上述执行主体可以判断处于空闲状态的句柄池中是否还存在该目标句柄,若存在,则上述执行主体可以对处于空闲状态的句柄池中的相应文件句柄的动态引用次数减少。若不存,则上述执行主体可以减少处于活跃状态的句柄池中的相应文件句柄的动态引用次数。这样,可以实现对两个句柄池进行及时有效管理。在节约存储空间的同时,保障两个句柄池更加高效地进行并行工作。Here, after executing the target operation on the target file, the above-mentioned execution subject can judge whether the target handle still exists in the handle pool in the idle state, and if it exists, the above-mentioned execution subject can check the corresponding file handle in the handle pool in the idle state. The number of dynamic citations for is reduced. If not, the above-mentioned execution subject may reduce the number of dynamic references of the corresponding file handle in the handle pool in an active state. In this way, timely and effective management of the two handle pools can be realized. While saving storage space, it ensures that the two handle pools can work in parallel more efficiently.

需要指出的是,对文件句柄的动态引用次数进行增加的方式,可以与对文件句柄的动态引用次数进行减少的方式相对应,也可以不相对应。It should be pointed out that the manner of increasing the dynamic reference count of the file handle may or may not correspond to the manner of decreasing the dynamic reference count of the file handle.

举例来说,可以在查找到目标句柄时,对处于活跃状态的句柄池中的对应文件句柄的动态引用次数增加1,以及在对目标文件操作结束时,对处于空闲状态的句柄池中的对应文件句柄的动态引用次数减少1。也可以在查找到目标句柄时,对处于活跃状态的句柄池中的对应文件句柄的动态引用次数增加2,以及在对目标文件操作结束时,对处于空闲状态的句柄池中的对应文件句柄的动态引用次数减少1。实践中,对文件句柄的动态引用次数进行增加的方式,通常与对文件句柄的动态引用次数进行减少的方式相对应,且通常增加和减少的数量都为1,这样可以比较明确地获悉,每个句柄文件当前同时被调用的次数。For example, when the target handle is found, the number of dynamic references to the corresponding file handle in the handle pool in the active state is increased by 1, and when the operation on the target file ends, the number of references to the corresponding file handle in the handle pool in the idle state is increased by 1. The dynamic reference count of the file handle is reduced by 1. It is also possible to increase the number of dynamic references to the corresponding file handle in the handle pool in the active state by 2 when the target handle is found, and to increase the number of dynamic references to the corresponding file handle in the handle pool in the idle state when the operation on the target file ends. The number of dynamic references is reduced by 1. In practice, the method of increasing the number of dynamic references to the file handle usually corresponds to the method of reducing the number of dynamic references to the file handle, and usually the number of increases and decreases is 1, so that it can be clearly learned that every The number of times that handle files are currently called at the same time.

实践中,在对目标文件执行目标操作之后,在对目标句柄池中的相应文件句柄的动态引用次数减少的过程中,若检测到两个句柄池中均不存在目标句柄,此时,上述执行主体可以发出报错信息。该报错信息可以提示找不到待归还的目标句柄。及时对程序故障进行报错,可以使得工作人员及时发现问题并处理。In practice, after the target operation is performed on the target file, in the process of reducing the number of dynamic references to the corresponding file handle in the target handle pool, if it is detected that the target handle does not exist in the two handle pools, at this time, the above execution The subject can issue error messages. The error message may indicate that the target handle to be returned cannot be found. Reporting errors to program failures in a timely manner can enable staff to discover and deal with problems in a timely manner.

步骤四,将处于空闲状态的句柄池中的、对应动态引用次数为零的文件句柄删除。Step 4, delete the file handle corresponding to the dynamic reference count of zero in the handle pool in the idle state.

这里,上述执行主体可以及时将处于空闲状态的句柄池中的不使用的文件句柄清除。可以节约存储空间。Here, the above-mentioned execution subject may clear unused file handles in the handle pool in an idle state in time. Can save storage space.

需要指出的是,由于处于空闲状态的句柄池的主要职责在于及时对不使用的文件句柄进行清理。在目标句柄还存在于处于空闲状态的句柄池的情况下,在对目标文件执行完目标操作时,减少处于空闲状态的句柄池中的相应文件句柄的动态引用次数,有助于实现更快地从处于空闲状态的句柄池中减少重复文件句柄的动态引用次数,从而及时清除掉上述重复文件句柄,既可以节约存储空间,还可以保障两个句柄池更加高效地进行并行工作。其中,上述重复文件句柄,通常是指同时存在于处于空闲状态的句柄池和处于活跃状态的句柄池中的文件句柄。It should be pointed out that the main responsibility of the handle pool in the idle state is to clean up unused file handles in a timely manner. In the case that the target handle still exists in the handle pool in the idle state, when the target operation is performed on the target file, reducing the number of dynamic references of the corresponding file handle in the handle pool in the idle state helps to achieve faster Reduce the number of dynamic references of duplicate file handles from the handle pool in the idle state, so as to clear the above-mentioned duplicate file handles in time, which can not only save storage space, but also ensure that the two handle pools can work in parallel more efficiently. Wherein, the above-mentioned repeated file handle generally refers to a file handle that exists in both the handle pool in the idle state and the handle pool in the active state.

在一些实施例的可选的实现方式中,若句柄池组中包括工作状态相异的两个句柄池,且各句柄池中的文件句柄包括文件标识、文件地址和动态引用次数,则在根据操作请求信息,从目标位置查找与目标文件对应的目标句柄之后,上述区块链数据处理方法还可以包括如下步骤。In an optional implementation of some embodiments, if the handle pool group includes two handle pools with different working states, and the file handles in each handle pool include file identifiers, file addresses, and dynamic reference times, then according to After the operation request information is searched for the target handle corresponding to the target file from the target location, the above block chain data processing method may further include the following steps.

首先,若目标位置不存在与目标文件对应的目标句柄,则遍历目标区块链上存储的区块数据,直至查询得到与操作请求信息相匹配的目标文件。First, if there is no target handle corresponding to the target file at the target location, the block data stored on the target blockchain is traversed until the target file matching the operation request information is queried.

这里,在各个目标位置均不存在上述目标句柄的情况下,上述执行主体可以通过遍历区块链上存储的区块数据的方式,查找得到目标文件及用于存储目标文件的文件地址。之后,可以对目标文件执行目标操作。Here, in the case that the above-mentioned target handle does not exist in each target location, the above-mentioned execution subject can find the target file and the file address for storing the target file by traversing the block data stored on the blockchain. Afterwards, target operations can be performed on the target file.

然后,将查询得到的目标文件的文件地址确定为目标地址,以及根据目标文件的文件标识、目标地址和预设引用次数,创建与目标文件对应的目标句柄,以及将目标句柄存入处于活跃状态的句柄池。Then, determine the file address of the target file obtained from the query as the target address, and create a target handle corresponding to the target file according to the file identifier, target address and preset reference times of the target file, and store the target handle in the active state handle pool.

其中,上述预设引用次数通常是预先设定的次数。实践中,上述预设引用次数通常是1。Wherein, the above-mentioned preset number of references is usually a preset number of times. In practice, the above preset number of references is usually 1.

这里,在从区块链上遍历查找得到目标文件及目标文件的文件地址时,上述执行主体可以采用目标文件的文件标识、目标文件的文件地址和预设引用次数,组合生成与目标文件对应的上述目标句柄。之后,可以将目标句柄存入处于活跃状态的句柄池中。这样,在下一次需要对该目标文件进行操作时,可以通过该目标文件对应的文件句柄快速查找到该目标文件,从而提高区块链数据处理效率。Here, when traversing the block chain to obtain the target file and the file address of the target file, the above-mentioned execution subject can use the file identification of the target file, the file address of the target file and the preset number of references to generate a combination of The above target handle. Afterwards, the target handle can be stored in the pool of active handles. In this way, when the target file needs to be operated next time, the target file can be quickly found through the file handle corresponding to the target file, thereby improving the blockchain data processing efficiency.

在一些实施例的可选的实现方式中,上述区块链数据处理方法还可以包括如下步骤:若句柄池组中包括工作状态相异的两个句柄池,则在预设触发条件被触发时,对两个句柄池的工作状态进行调换。In an optional implementation of some embodiments, the above blockchain data processing method may also include the following steps: if the handle pool group includes two handle pools with different working states, when the preset trigger condition is triggered , to exchange the working status of the two handle pools.

其中,预设触发条件包括以下至少一项:到达预设调换周期、处于活跃状态的句柄池中的文件句柄数目超过预设数目阈值。其中,上述预设触发条件通常是预先设定的用于触发两个句柄池调换工作状态的条件。上述预设调换周期通常是预先设定的周期值,比如,可以为5分钟。上述预设数目阈值通常是预先设定的数目值,比如,可以为50个。需要指出的是,上述预设触发条件中,还可以包括除上述所列举的两个条件之外的其它条件。Wherein, the preset triggering conditions include at least one of the following: reaching a preset exchange period, and the number of file handles in the active handle pool exceeding a preset number threshold. Wherein, the above-mentioned preset triggering condition is usually a preset condition for triggering the switching of the working states of the two handle pools. The aforementioned preset exchange cycle is usually a preset cycle value, for example, it may be 5 minutes. The aforementioned preset number threshold is usually a preset number value, for example, it may be 50. It should be noted that the above preset trigger conditions may also include other conditions besides the two conditions listed above.

这里,上述执行主体可以在预设触发条件被触发的情况下,及时对两个句柄池的工作状态进行调换。具体地,将原本处于活跃状态的句柄池切换为处于空闲状态,以及将原本处于空闲状态的句柄池切换为处于活跃状态。这样可以实现及时有效地对处于空闲状态的句柄池中的未使用的文件句柄进行清除,可以进一步节约存储空间。Here, the above-mentioned execution subject can switch the working states of the two handle pools in time when the preset trigger condition is triggered. Specifically, switch the handle pool that was originally in the active state to be in the idle state, and switch the handle pool that was originally in the idle state to be in the active state. In this way, unused file handles in the handle pool in the idle state can be cleared in a timely and effective manner, which can further save storage space.

另外,两个句柄池并行工作,且两个句柄池的工作状态可以相互调换,一个保障数据处理任务有序进行,另一个保障及时清除未使用的文件句柄。这样,每个句柄池的容量无需太大,一方面可以保障对目标文件的查找效率,另一方面可以进一步节省所有句柄池所占的存储空间。In addition, the two handle pools work in parallel, and the working status of the two handle pools can be exchanged with each other. One ensures that data processing tasks are carried out in an orderly manner, and the other ensures that unused file handles are cleared in time. In this way, the capacity of each handle pool does not need to be too large. On the one hand, the search efficiency of the target file can be guaranteed, and on the other hand, the storage space occupied by all the handle pools can be further saved.

在一些实施例的可选的实现方式中,上述区块链数据处理方法还可以包括如下步骤:在活跃文件被写满时,上链存储活跃文件以及将活跃文件的文件句柄写入处于活跃状态的句柄池中,创建对应有文件句柄的新的文件,将新的文件切换为活跃文件。In an optional implementation of some embodiments, the above block chain data processing method may also include the following steps: when the active file is full, store the active file on the chain and write the file handle of the active file into the active state In the handle pool, create a new file corresponding to the file handle, and switch the new file to the active file.

其中,上述活跃文件,通常是区块链节点中尚未上链存储的处于被写入状态的文件。活跃文件中可以被先后写入多条数据。在活跃文件被写满时,上述执行主体可以将活跃文件的文件句柄写入处于活跃状态的句柄池中。Among them, the above-mentioned active files are usually files in the state of being written that have not been stored on the chain in the blockchain node. Multiple pieces of data can be written successively in the active file. When the active file is full, the execution subject may write the file handle of the active file into the handle pool in an active state.

实际应用中,活跃文件的文件句柄写入处于活跃状态的句柄池时,新添加至处于活跃状态的句柄池中的文件句柄可以包括该活跃文件的文件名、该活跃文件被存储在区块链上的文件地址、初始引用次数。其中,初始引用次数通常是预先设定的次数值。实际应用中,初始引用次数通常为0。In practical applications, when the file handle of the active file is written into the handle pool in the active state, the file handle newly added to the handle pool in the active state can include the file name of the active file, the active file is stored in the blockchain The file address and initial reference count on the . Wherein, the initial number of references is usually a preset number of times. In practical applications, the initial reference count is usually 0.

需要指出的是,在当前的活跃文件被写满以及被上链存储时,上述执行主体可以生成用于写入数据的新的活跃文件,以及给新的活跃文件创建对应的文件句柄。It should be pointed out that when the current active file is full and stored on the chain, the above execution subject can generate a new active file for writing data, and create a corresponding file handle for the new active file.

继续参考图3,为本申请实施例提供的一种区块链数据处理方法的流程示意图。如图3所示的区块链数据处理方法,可以包括如下步骤301至步骤313。需要指出的是,上述步骤301至步骤313的执行主体为上述目标区块链,具体可以为上述目标区块链上的各个区块链节点。实际应用中,每个区块链节点可以实现成终端也可以实现成服务器。Continue to refer to FIG. 3 , which is a schematic flowchart of a blockchain data processing method provided by the embodiment of the present application. The blockchain data processing method shown in FIG. 3 may include the followingsteps 301 to 313. It should be pointed out that the execution subject of the above-mentionedsteps 301 to 313 is the above-mentioned target blockchain, specifically, each blockchain node on the above-mentioned target blockchain. In practical applications, each blockchain node can be implemented as a terminal or as a server.

步骤301,接收文件读取请求。Step 301, receiving a file reading request.

这里,上述文件读取请求与前述操作请求信息概念相同。这里,文件读取请求指示对目标文件执行文件读取操作。这里,目标操作为文件读取操作,且目标文件为待读取的文件。Here, the aforementioned file read request has the same concept as the aforementioned operation request information. Here, the file read request indicates to perform a file read operation on a target file. Here, the target operation is a file reading operation, and the target file is a file to be read.

步骤302,校验文件读取请求是否合法。Step 302, checking whether the file reading request is legal.

在文件读取请求合法的情况下,可以执行步骤303,反之,执行步骤313。In the case that the file reading request is legal, step 303 may be performed; otherwise, step 313 may be performed.

步骤303,判断是否在活跃文件中找到句柄。Step 303, judging whether the handle is found in the active file.

这里,可以采用文件读取请求所包括的文件名,与活跃文件的文件名进行比较,实现判断活跃文件是否为目标文件。若活跃文件为目标文件,则可以将活跃文件的文件句柄确定为目标文件的文件句柄。为了便于描述,可以将目标文件的文件句柄记作目标句柄。在活跃文件即为目标文件时,可以认为在活跃文件中找到句柄,也即是在活跃文件中找到目标句柄。Here, the file name included in the file read request may be used and compared with the file name of the active file to realize whether the active file is the target file. If the active file is the target file, the file handle of the active file may be determined as the file handle of the target file. For the convenience of description, the file handle of the target file can be recorded as the target handle. When the active file is the target file, it can be considered that the handle is found in the active file, that is, the target handle is found in the active file.

之后,在活跃文件中找到目标句柄的情况下,可以执行步骤306。否则,在活跃文件中不存在目标句柄的情况下,可以执行步骤304。Afterwards, in case the target handle is found in the active file,step 306 may be performed. Otherwise, if the target handle does not exist in the active file,step 304 may be executed.

需要指出的是,步骤301-步骤313所提及的要查找的句柄,通常指目标句柄,也即是目标文件对应的文件句柄。It should be pointed out that the handle to be searched mentioned insteps 301 to 313 usually refers to the target handle, that is, the file handle corresponding to the target file.

步骤304,判断是否在活跃句柄池中找到句柄。Step 304, judging whether the handle is found in the active handle pool.

其中,上述活跃句柄池为前述处于活跃状态的句柄池。Wherein, the above-mentioned active handle pool is the aforementioned handle pool in an active state.

这里,在活跃文件中不存在目标句柄的情况下,可以采用文件读取请求所包括的文件名,从活跃句柄池中查找与该文件名对应的文件句柄。若查找到,则可以确定在活跃句柄池中找到句柄,也即是,在活跃句柄池中找到目标句柄。Here, if the target handle does not exist in the active file, the file name included in the file read request may be used to search for a file handle corresponding to the file name from the active handle pool. If found, it can be determined that the handle is found in the active handle pool, that is, the target handle is found in the active handle pool.

之后,在活跃句柄池中找到目标句柄的情况下,可以执行步骤307。否则,在活跃句柄池中不存在目标句柄的情况下,可以执行步骤305。Afterwards, if the target handle is found in the active handle pool, step 307 may be executed. Otherwise, if there is no target handle in the active handle pool, step 305 may be executed.

步骤305,在活跃句柄池中创建读取请求对应的句柄。Step 305, create a handle corresponding to the read request in the active handle pool.

这里,在活跃句柄池中不存在目标句柄的情况下,可以继续查找空闲句柄池中是否存在目标句柄。若存在,则可以根据空闲句柄池中的目标句柄,在活跃句柄池中创建该目标句柄。若不存在,则可以通过遍历区块链上存储的区块数据的方式,查找得到目标文件及用于存储目标文件的文件地址,以及针对查找到的该目标文件创建目标句柄,并存入处于活跃状态的句柄池中。其中,上述空闲句柄池为前述处于空闲状态的句柄池。Here, in the case that the target handle does not exist in the active handle pool, it may continue to search for whether the target handle exists in the free handle pool. If it exists, the target handle can be created in the active handle pool according to the target handle in the free handle pool. If it does not exist, you can find the target file and the file address used to store the target file by traversing the block data stored on the blockchain, and create a target handle for the found target file, and store it in the Active handle pool. Wherein, the above-mentioned free handle pool is the aforementioned handle pool in an idle state.

步骤306,根据获取到的句柄进行文件读取操作。Step 306, perform a file reading operation according to the obtained handle.

这里,可以根据目标句柄指向的目标文件的文件地址,查找得到目标文件,以及对目标文件执行文件读取操作。Here, the target file can be found according to the file address of the target file pointed to by the target handle, and a file read operation can be performed on the target file.

步骤307,句柄池中的句柄引用计数+1。Instep 307, the handle reference count in the handle pool is increased by 1.

这里,上述引用计数与前述动态引用次数概念相同。在活跃句柄池中找到目标句柄的情况下,可以对活跃句柄池中的相应文件句柄的动态引用次数加1。Here, the aforementioned reference count has the same concept as the aforementioned dynamic reference count. If the target handle is found in the active handle pool, 1 may be added to the dynamic reference count of the corresponding file handle in the active handle pool.

步骤308,文件读取操作完成。Step 308, the file reading operation is completed.

步骤309,在读取请求对应的句柄来自句柄池时,进入句柄池操作。Step 309, when the handle corresponding to the read request comes from the handle pool, enter the handle pool operation.

这里,在目标句柄来自活跃句柄池或者是空闲句柄池的情况下,上述执行主体可以继续执行步骤310-步骤312。Here, in the case that the target handle is from the active handle pool or the idle handle pool, the execution subject may continue to execute steps 310 - 312 .

另外,在目标句柄来自活跃文件的情况下,可以执行步骤313。In addition,step 313 can be performed in the case that the target handle is from the active file.

步骤310,判断是否能在空闲句柄池中找到句柄。Step 310, judging whether the handle can be found in the free handle pool.

这里,若空闲句柄池中存在目标句柄,则可以对空闲句柄池执行步骤312。Here, if the target handle exists in the free handle pool, step 312 may be performed on the free handle pool.

若空闲句柄池中不存在目标句柄,则可以执行步骤311。If there is no target handle in the free handle pool, step 311 may be executed.

步骤311,在活跃句柄池中找到句柄。Step 311, find the handle in the active handle pool.

在读取请求对应的目标句柄来自句柄池,且目标句柄不存在于空闲句柄池的情况下,说明目标句柄存在于活跃句柄池。此时,可以在活跃句柄池中找到目标句柄。在活跃句柄池中找到目标句柄的情况下,可以对活跃句柄池执行步骤312。If the target handle corresponding to the read request comes from the handle pool, and the target handle does not exist in the free handle pool, it means that the target handle exists in the active handle pool. At this point, the target handle can be found in the active handle pool. In case the target handle is found in the active handle pool, step 312 may be performed on the active handle pool.

步骤312,对句柄池中的句柄引用计数-1。Step 312, the handle reference count in the handle pool is -1.

这里,在读取请求对应的目标句柄来自句柄池的情况下,若目标句柄来自空闲句柄池,则对空闲句柄池中的相应文件句柄的动态引用次数减1。Here, in the case that the target handle corresponding to the read request comes from the handle pool, if the target handle comes from the free handle pool, the number of dynamic references to the corresponding file handle in the free handle pool is decremented by 1.

在读取请求对应的目标句柄来自句柄池的情况下,若目标句柄来自活跃句柄池,则对活跃句柄池中的相应文件句柄的动态引用次数减1。In the case that the target handle corresponding to the read request comes from the handle pool, if the target handle comes from the active handle pool, the number of dynamic references to the corresponding file handle in the active handle pool is decremented by 1.

步骤313,结束执行上述区块链数据处理方法。Step 313, end execution of the above blockchain data processing method.

本实施例提供的方法,由于文件句柄通常可以指向相对应的文件的文件地址,因此,从活跃文件或者是句柄池组查找与目标文件对应的目标句柄,从而通过目标句柄快速查找到目标文件,可以实现快速准确地查找到需要被操作的目标文件,有助于提高对区块链数据的处理效率。In the method provided by this embodiment, since the file handle can usually point to the file address of the corresponding file, the target handle corresponding to the target file is searched from the active file or the handle pool group, thereby quickly finding the target file through the target handle, It can quickly and accurately find the target file that needs to be operated, which helps to improve the processing efficiency of blockchain data.

对应于上文实施例一的区块链数据处理方法,图4示出了本申请实施例提供的区块链数据处理装置400的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。Corresponding to the block chain data processing method in the first embodiment above, Fig. 4 shows a block diagram of the block chaindata processing device 400 provided by the embodiment of the present application. relevant part.

参照图4,该装置包括:Referring to Figure 4, the device includes:

信息接收单元401,用于接收操作请求信息,操作请求信息用于指示对目标区块链上的目标文件执行目标操作;Theinformation receiving unit 401 is configured to receive operation request information, and the operation request information is used to indicate to perform a target operation on the target file on the target block chain;

句柄查找单元402,用于根据操作请求信息,从目标位置查找与目标文件对应的目标句柄,其中,目标句柄包括目标文件对应的目标地址,目标位置包括以下任一项:活跃文件、句柄池组;Thehandle search unit 402 is used to search the target handle corresponding to the target file from the target location according to the operation request information, wherein the target handle includes the target address corresponding to the target file, and the target location includes any of the following: active file, handle pool group ;

操作执行单元403,用于根据目标句柄,查找目标文件,以及对目标文件执行目标操作。Theoperation executing unit 403 is configured to search for the target file according to the target handle, and execute the target operation on the target file.

在一些实施例中,装置还包括信息创建单元。信息创建单元用于:根据预先确定的句柄池尺寸,创建句柄池组。其中,句柄池组中包括工作状态相异的两个句柄池,工作状态包括活跃状态和空闲状态,各句柄池中的文件句柄包括文件标识、文件地址和动态引用次数,其中,动态引用次数用于记录相应文件句柄当前被引用的次数。In some embodiments, the apparatus further includes an information creation unit. The information creating unit is used for: creating a handle pool group according to a predetermined size of the handle pool. Among them, the handle pool group includes two handle pools with different working states. The working state includes active state and idle state. The file handles in each handle pool include file identification, file address and dynamic reference times. Used to record the number of times the corresponding file handle is currently referenced.

在一些实施例中,句柄查找单元402包括第一查找模块、第二查找模块。第一查找模块,用于若操作请求信息与活跃文件的文件描述信息相适配,则将活跃文件的文件句柄确定为目标句柄。第二查找模块,用于若操作请求信息与活跃文件的文件描述信息不适配,则从句柄池组中查找与操作请求信息相匹配的文件句柄,以及将查找到的文件句柄确定为目标句柄。In some embodiments, thehandle lookup unit 402 includes a first lookup module and a second lookup module. The first search module is configured to determine the file handle of the active file as the target handle if the operation request information matches the file description information of the active file. The second search module is used to search for a file handle matching the operation request information from the handle pool group if the operation request information does not match the file description information of the active file, and determine the found file handle as the target handle .

在一些实施例中,第二查找模块中,从句柄池组中查找与操作请求信息相匹配的文件句柄,以及将查找到的文件句柄确定为目标句柄,包括:从处于活跃状态的句柄池中查找目标句柄,和/或若处于活跃状态的句柄池中不存在目标句柄,则从处于空闲状态的句柄池中查找目标句柄。In some embodiments, in the second search module, searching for a file handle matching the operation request information from the handle pool group, and determining the found file handle as the target handle includes: from the handle pool in an active state Look up the target handle, and/or if the target handle does not exist in the active handle pool, look up the target handle from the idle handle pool.

在一些实施例中,装置还包括第一更新单元、第二更新单元。第一更新单元,用于若从处于活跃状态的句柄池中查找到目标句柄,则增加处于活跃状态的句柄池中的相应文件句柄的动态引用次数。第二更新单元,用于若处于活跃状态的句柄池中不存在目标句柄,则根据操作请求信息创建目标句柄,以及将创建的目标句柄存入处于活跃状态的句柄池中。In some embodiments, the device further includes a first updating unit and a second updating unit. The first updating unit is configured to increase the number of dynamic references of the corresponding file handle in the handle pool in the active state if the target handle is found from the handle pool in the active state. The second update unit is configured to create a target handle according to the operation request information if the target handle does not exist in the active handle pool, and store the created target handle in the active handle pool.

在一些实施例中,装置还包括文件查找单元、句柄创建单元。文件查找单元,用于若目标位置不存在与目标文件对应的目标句柄,则遍历目标区块链上存储的区块数据,直至查询得到与操作请求信息相匹配的目标文件。句柄创建单元,用于将查询得到的目标文件的文件地址确定为目标地址,以及根据目标文件的文件标识、目标地址和预设引用次数,创建与目标文件对应的目标句柄,以及将目标句柄存入处于活跃状态的句柄池。In some embodiments, the device further includes a file search unit and a handle creation unit. The file search unit is used for traversing the block data stored on the target block chain if there is no target handle corresponding to the target file at the target location until the target file matching the operation request information is queried. The handle creation unit is used to determine the file address of the target file obtained from the query as the target address, and create a target handle corresponding to the target file according to the file identifier, target address and preset reference times of the target file, and store the target handle into the active handle pool.

在一些实施例中,装置还包括第三更新单元、第四更新单元。第三更新单元,用于在对目标文件执行目标操作之后,若检测到处于空闲状态的句柄池中还存在目标句柄,则减少处于空闲状态的句柄池中的相应文件句柄的动态引用次数;若检测到处于空闲状态的句柄池中不存在目标句柄,则减少处于活跃状态的句柄池中的相应文件句柄的动态引用次数。第四更新单元,用于将处于空闲状态的句柄池中的、对应动态引用次数为零的文件句柄删除。In some embodiments, the device further includes a third updating unit and a fourth updating unit. The 3rd updating unit is used for after target operation is carried out to target file, if detect that target handle also exists in the handle pool that is in idle state, then reduce the number of dynamic references of the corresponding file handle in the handle pool that is in idle state; If If it is detected that the target handle does not exist in the handle pool in the idle state, then reduce the number of dynamic references of the corresponding file handle in the handle pool in the active state. The fourth updating unit is configured to delete a file handle corresponding to a dynamic reference count of zero in the handle pool in an idle state.

在一些实施例中,装置还包括状态切换单元、文件切换单元。状态切换单元,用于若句柄池组中包括工作状态相异的两个句柄池,则在预设触发条件被触发时,对两个句柄池的工作状态进行调换,其中,预设触发条件包括以下至少一项:到达预设调换周期、处于活跃状态的句柄池中的文件句柄数目超过预设数目阈值。文件切换单元,用于在活跃文件被写满时,上链存储活跃文件以及将活跃文件的文件句柄写入处于活跃状态的句柄池中,创建对应有文件句柄的新的文件,将新的文件切换为活跃文件。In some embodiments, the device further includes a state switching unit and a file switching unit. The state switching unit is used to switch the working states of the two handle pools when the preset trigger condition is triggered if the handle pool group includes two handle pools with different working states, wherein the preset trigger condition includes At least one of the following: the preset exchange cycle is reached, and the number of file handles in the active handle pool exceeds the preset number threshold. The file switching unit is used to store the active file on the chain and write the file handle of the active file into the handle pool in the active state when the active file is full, create a new file corresponding to the file handle, and write the new file Switch to active file.

本实施例提供的装置,由于文件句柄通常可以指向相对应的文件的文件地址,因此,从活跃文件或者是句柄池组查找与目标文件对应的目标句柄,从而通过目标句柄快速查找到目标文件,可以实现快速准确地查找到需要被操作的目标文件,有助于提高对区块链数据的处理效率。The device provided by this embodiment, since the file handle can usually point to the file address of the corresponding file, therefore, the target handle corresponding to the target file is searched from the active file or the handle pool group, thereby quickly finding the target file through the target handle, It can quickly and accurately find the target file that needs to be operated, which helps to improve the processing efficiency of blockchain data.

需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例一基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。It should be noted that the information interaction and execution process between the above-mentioned devices/units are based on the same idea as the method embodiment 1 of this application, and its specific functions and technical effects can be found in the method embodiment section. I won't repeat them here.

图5为本申请一实施例提供的服务器500的结构示意图。如图5所示,该实施例的服务器500包括:至少一个处理器501(图5中仅示出一个处理器)、存储器502以及存储在存储器502中并可在至少一个处理器501上运行的计算机程序503,例如区块链数据处理程序。处理器501执行计算机程序503时实现上述任意各个方法实施例中的步骤。处理器501执行计算机程序503时实现上述各个区块链数据处理方法的实施例中的步骤。处理器501执行计算机程序503时实现上述各装置实施例中各模块/单元的功能,例如图4所示信息接收单元401至操作执行单元403的功能。FIG. 5 is a schematic structural diagram of aserver 500 provided by an embodiment of the present application. As shown in FIG. 5 , theserver 500 of this embodiment includes: at least one processor 501 (only one processor is shown in FIG. 5 ), amemory 502, and a server stored in thememory 502 and capable of running on the at least oneprocessor 501. Acomputer program 503, such as a block chain data processing program. When theprocessor 501 executes thecomputer program 503, the steps in any of the foregoing method embodiments are implemented. When theprocessor 501 executes thecomputer program 503, it realizes the steps in the above-mentioned embodiments of each block chain data processing method. When theprocessor 501 executes thecomputer program 503, it realizes the functions of the modules/units in the above-mentioned device embodiments, for example, the functions of theinformation receiving unit 401 to theoperation executing unit 403 shown in FIG. 4 .

示例性的,计算机程序503可以被分割成一个或多个模块/单元,一个或者多个模块/单元被存储在存储器502中,并由处理器501执行,以完成本申请。一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述计算机程序503在服务器500中的执行过程。例如,计算机程序503可以被分割成信息接收单元,句柄查找单元,操作执行单元,各单元具体功能在上述实施例中已有描述,此处不再赘述。Exemplarily, thecomputer program 503 can be divided into one or more modules/units, and one or more modules/units are stored in thememory 502 and executed by theprocessor 501 to complete the present application. One or more modules/units may be a series of computer program instruction segments capable of accomplishing specific functions, and the instruction segments are used to describe the execution process of thecomputer program 503 in theserver 500 . For example, thecomputer program 503 may be divided into an information receiving unit, a handle search unit, and an operation execution unit. The specific functions of each unit have been described in the above embodiments, and will not be repeated here.

服务器500可以是服务器、台式电脑、平板电脑、云端服务器和移动终端等计算设备。服务器500可包括,但不仅限于,处理器501,存储器502。本领域技术人员可以理解,图5仅仅是服务器500的示例,并不构成对服务器500的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如服务器还可以包括输入输出设备、网络接入设备、总线等。Theserver 500 may be computing devices such as servers, desktop computers, tablet computers, cloud servers, and mobile terminals. Theserver 500 may include, but not limited to, aprocessor 501 and amemory 502 . Those skilled in the art can understand that FIG. 5 is only an example of theserver 500, and does not constitute a limitation to theserver 500. It may include more or less components than those shown in the illustration, or combine some components, or different components, such as The server may also include input and output devices, network access devices, buses, and the like.

所称处理器501可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The so-calledprocessor 501 may be a central processing unit (Central Processing Unit, CPU), and may also be other general-purpose processors, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.

存储器502可以是服务器500的内部存储单元,例如服务器500的硬盘或内存。存储器502也可以是服务器500的外部存储设备,例如服务器500上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,存储器502还可以既包括服务器500的内部存储单元也包括外部存储设备。存储器502用于存储计算机程序以及服务器所需的其他程序和数据。存储器502还可以用于暂时地存储已经输出或者将要输出的数据。Thestorage 502 may be an internal storage unit of theserver 500 , such as a hard disk or memory of theserver 500 . Thememory 502 can also be an external storage device of theserver 500, such as a plug-in hard disk equipped on theserver 500, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash memory card (Flash Card) Wait. Further, thestorage 502 may also include both an internal storage unit of theserver 500 and an external storage device. Thememory 502 is used to store computer programs and other programs and data required by the server. Thememory 502 can also be used to temporarily store data that has been output or will be output.

所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used for illustration. In practical applications, the above-mentioned functions can be assigned to different functional units, Completion of modules means that the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment may be integrated into one processing unit, or each unit may exist separately physically, or two or more units may be integrated into one unit, and the above-mentioned integrated units may adopt hardware It can also be implemented in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the present application. For the specific working process of the units and modules in the above system, reference may be made to the corresponding process in the foregoing method embodiments, and details will not be repeated here.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the descriptions of each embodiment have their own emphases, and for parts that are not detailed or recorded in a certain embodiment, refer to the relevant descriptions of other embodiments.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those skilled in the art can appreciate that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present application.

在本申请所提供的实施例中,应该理解到,所揭露的装置/服务器和方法,可以通过其它的方式实现。例如,以上所描述的装置/服务器实施例仅仅是示意性的,例如,模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed device/server and method may be implemented in other ways. For example, the device/server embodiments described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be Incorporation may either be integrated into another system, or some features may be omitted, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.

作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。A unit described as a separate component may or may not be physically separated, and a component displayed as a unit may or may not be a physical unit, that is, it may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

集成的模块如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,计算机程序包括计算机程序代码,计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。计算机可读介质可以包括:能够携带计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。需要说明的是,计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。If the integrated modules are realized in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the present application realizes all or part of the processes in the methods of the above embodiments, and can also be completed by instructing related hardware through computer programs, and the computer programs can be stored in a computer-readable storage medium. When executed by the processor, the steps in the above-mentioned various method embodiments can be realized. Wherein, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, removable hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access Memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content contained on computer readable media may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer readable media does not include Electrical carrier signals and telecommunication signals.

以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: it can still apply to the foregoing embodiments Modifications to the technical solutions recorded, or equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of each embodiment of the application, and should be included in this application. within the scope of protection.

Claims (10)

CN202210851734.5A2022-07-202022-07-20 Blockchain data processing method, server and mediumPendingCN115309704A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202210851734.5ACN115309704A (en)2022-07-202022-07-20 Blockchain data processing method, server and medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202210851734.5ACN115309704A (en)2022-07-202022-07-20 Blockchain data processing method, server and medium

Publications (1)

Publication NumberPublication Date
CN115309704Atrue CN115309704A (en)2022-11-08

Family

ID=83856140

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202210851734.5APendingCN115309704A (en)2022-07-202022-07-20 Blockchain data processing method, server and medium

Country Status (1)

CountryLink
CN (1)CN115309704A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116401205A (en)*2023-03-242023-07-07苏州浪潮智能科技有限公司Method, system, device and computer readable storage medium for snapshot rollback

Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20140201177A1 (en)*2013-01-112014-07-17Red Hat, Inc.Accessing a file system using a hard link mapped to a file handle
CN107992504A (en)*2016-10-262018-05-04中兴通讯股份有限公司A kind of document handling method and device
CN112445763A (en)*2019-09-022021-03-05阿里巴巴集团控股有限公司File operation method and device, electronic equipment and storage medium
CN113901362A (en)*2021-11-252022-01-07企查查科技有限公司Webpage display method, device, equipment, storage medium and program product
CN114756509A (en)*2022-05-192022-07-15北京百度网讯科技有限公司Operation method, system, device and storage medium of file system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20140201177A1 (en)*2013-01-112014-07-17Red Hat, Inc.Accessing a file system using a hard link mapped to a file handle
CN107992504A (en)*2016-10-262018-05-04中兴通讯股份有限公司A kind of document handling method and device
CN112445763A (en)*2019-09-022021-03-05阿里巴巴集团控股有限公司File operation method and device, electronic equipment and storage medium
CN113901362A (en)*2021-11-252022-01-07企查查科技有限公司Webpage display method, device, equipment, storage medium and program product
CN114756509A (en)*2022-05-192022-07-15北京百度网讯科技有限公司Operation method, system, device and storage medium of file system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116401205A (en)*2023-03-242023-07-07苏州浪潮智能科技有限公司Method, system, device and computer readable storage medium for snapshot rollback

Similar Documents

PublicationPublication DateTitle
US11474972B2 (en)Metadata query method and apparatus
CN111352902B (en) Log processing method, device, terminal equipment and storage medium
CN109271343B (en) A data merging method and device applied in a key-value storage system
CN111831350B (en)Application process configuration updating method, system, terminal equipment and storage medium
WO2020140622A1 (en)Distributed storage system, storage node device and data duplicate deletion method
CN107832062A (en)A kind of method for updating program and terminal device
CN115878027B (en) A storage object processing method, device, terminal and storage medium
CN114490060A (en) Memory allocation method, apparatus, computer device, and computer-readable storage medium
CN113392082A (en)Log duplicate removal method and device, electronic equipment and storage medium
US12169639B2 (en)Data exchange between host and storage device using compute functions
CN110928941B (en) A data fragmentation extraction method and device
CN115309704A (en) Blockchain data processing method, server and medium
CN111221468B (en) Storage block data deletion method, device, electronic equipment and cloud storage system
CN109542860B (en)Service data management method based on HDFS and terminal equipment
CN113806249B (en)Object storage sequence lifting method, device, terminal and storage medium
CN110245130A (en) Data deduplication method, device, computer equipment and storage medium
CN110083509B (en)Method and device for arranging log data
CN117632527A (en)Data writing method, device, equipment and medium based on primary key conflict detection
CN117873916A (en) A retrieval method based on disk-level cache data redirection
CN110209347A (en)A kind of retrospective date storage method
CN113220992B (en) A method, system and medium for recommending information flow content
CN114138187A (en) Method and device for managing volume mapping copy service plug-in timed snapshot volumes
CN111198900B (en)Data caching method and device for industrial control network, terminal equipment and medium
CN113535714A (en) Data storage method, reading method and computer equipment
US20200371849A1 (en)Systems and methods for efficient management of advanced functions in software defined storage systems

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp