Virtual resource quota management method and device, electronic equipment and storage medium
By updating the target queue in the blockchain and adjusting the pre-used quota value with the supplementary quota value, the problem of insufficient flexibility in virtual resource quota management is solved. This enables data sharing parties to download flexibly when virtual resources are insufficient, thereby improving the flexibility and fairness of data sharing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA MOBILE FINANCIAL TECHNOLOGY CO LTD
- Filing Date
- 2026-01-04
- Publication Date
- 2026-05-08
AI Technical Summary
In existing technologies, the management of virtual resource quotas in blockchain data sharing schemes is not very flexible, resulting in insufficient flexibility in data sharing and hindering the fairness and efficiency of data sharing.
By acquiring and updating the target queue when the data sharing party uploads data, and adjusting the first-used quota value using the supplementary quota value to form a second target queue, the virtual resource quota is used first and then supplemented, ensuring that the data sharing party can still download data when the available quota is insufficient.
It improves the flexibility and real-time performance of data downloads, enhances the flexibility of virtual resource quota management, ensures that data sharing parties can still download data when virtual resources are insufficient, and improves the flexibility and fairness of data sharing.
Smart Images

Figure CN121996351A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, and in particular to a method, apparatus, electronic device, and storage medium for managing virtual resource quotas. Background Technology
[0002] In the data sharing process of blockchain, blockchain members obtain corresponding virtual resource quotas by uploading data, and consume the corresponding virtual resource quotas when downloading data. To ensure the fairness of data sharing, existing technologies are usually incentive-based data sharing schemes, which strictly limit the virtual resource quotas available to the data sharing party to be greater than or equal to the virtual resource quotas that the data to be downloaded will consume; otherwise, the corresponding data cannot be downloaded.
[0003] While the aforementioned incentive-based data sharing scheme maintains real-time fairness in data sharing, it hinders the realization of the original intention of data sharing to some extent. This is because as subsequent data is uploaded to the blockchain, the available virtual resource quota of the requester will continue to increase. However, the current method of managing virtual resource quotas only determines the available virtual resource quota based on the current data upload and download volume, resulting in poor flexibility in the management of virtual resource quotas and thus poor flexibility in the data sharing scheme. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for managing virtual resource quotas, in order to solve the problem of poor flexibility in virtual resource quota management.
[0005] To solve the above-mentioned technical problems, this application is implemented as follows:
[0006] In a first aspect, embodiments of this application provide a method for managing virtual resource quotas, including:
[0007] When the data sharing party uploads the first data, a first target queue is obtained. The first target queue includes at least one element, which is used to store the pre-use quota value. The pre-use quota value is determined based on the virtual resource quota consumed by the data sharing party when downloading the data.
[0008] The first target queue is updated based on the supplementary quota value to obtain the second target queue. When the supplementary quota value is less than or equal to the first total pre-used quota value, the second total pre-used quota value is the difference between the first total pre-used quota value and the supplementary quota value. When the supplementary quota value is greater than the first total pre-used quota value, the second total pre-used quota value is 0. The first total pre-used quota value is the sum of the pre-used quota values of all elements in the first target queue. The second total pre-used quota value is the sum of the pre-used quota values of all elements in the second target queue. The supplementary quota value is the virtual resource quota obtained by the data sharing party from uploading the first data.
[0009] Optionally, updating the first target queue based on the supplementary quota value to obtain the second target queue includes:
[0010] Perform at least one iterative update operation on the first target queue and the supplementary quota value until the updated first target queue is empty or the updated supplementary quota value is 0;
[0011] The updated first target queue is designated as the second target queue.
[0012] Optionally, the iterative update operation includes:
[0013] Obtain a first element from the first target queue. The first element includes a first priority quota value, which is determined based on the virtual resource quota consumed by the data sharing party when downloading the second data.
[0014] If the current supplementary quota value is greater than or equal to the first pre-used quota value, the first element is removed from the first target queue, and the current supplementary quota value is subtracted from the first pre-used quota value to obtain the updated supplementary quota value.
[0015] If the current supplementary credit limit is less than the first available credit limit, the current first available credit limit is subtracted from the current supplementary credit limit to obtain the updated first available credit limit, and the updated supplementary credit limit is set to 0.
[0016] Optionally, the length of the first target queue is K, and the first target queue includes M elements, where K is a positive integer and M is an integer less than or equal to K; the first element is the element with the smallest pre-use quota value among the M elements.
[0017] Optionally, before obtaining the first target queue when the data sharing party uploads the first data, the method further includes:
[0018] In the event that the data sharing party requests the second data, a third target queue is obtained, the third target queue comprising N elements, where N is an integer less than or equal to K;
[0019] If the third target queue is not empty, determine whether N is less than K;
[0020] When N is less than K, the first element is created based on the first priority quota value, where the first priority quota value is the virtual resource quota consumed for downloading the second data;
[0021] The first element is added to the third target queue to obtain the first target queue.
[0022] Optionally, when N is less than K, before creating the first element based on the first available credit limit value, the method further includes:
[0023] When N equals K, at least one second element is obtained from the N elements, the second element including a second pre-used credit value;
[0024] The current third priority limit value is summed with the second priority limit value to obtain the updated third priority limit value. The third priority limit value is the priority limit value included in the third element. The third element is the element other than the second element among the N elements.
[0025] Remove the second element from the third target queue.
[0026] Optionally, before obtaining the third target queue when the data sharing party requests the second data, the method further includes:
[0027] The credit value of the data sharing party is determined based on the amount of data downloaded and the amount of data uploaded within the preset period.
[0028] If the credit value is greater than the credit threshold, the third target queue corresponding to the data sharing party is constructed.
[0029] Secondly, embodiments of the present invention also provide a virtual resource quota management device, comprising:
[0030] The first acquisition module is used to acquire a first target queue when the data sharing party uploads the first data. The first target queue includes at least one element, which is used to store a pre-use quota value. The pre-use quota value is determined based on the virtual resource quota consumed by the data sharing party when downloading data.
[0031] The update module is used to update the first target queue based on the supplementary quota value to obtain a second target queue. When the supplementary quota value is less than or equal to the first total pre-used quota value, the second total pre-used quota value is the difference between the first total pre-used quota value and the supplementary quota value. When the supplementary quota value is greater than the first total pre-used quota value, the second total pre-used quota value is 0. The first total pre-used quota value is the sum of the pre-used quota values of all elements in the first target queue. The second total pre-used quota value is the sum of the pre-used quota values of all elements in the second target queue. The supplementary quota value is the virtual resource quota obtained by the data sharing party from uploading the first data.
[0032] Thirdly, embodiments of the present invention also provide an electronic device, including: a memory, a processor, and a program stored in the memory and executable on the processor;
[0033] The processor is configured to read a program from memory to implement the steps in the virtual resource quota management method as described in the first aspect.
[0034] Fourthly, embodiments of the present invention also provide a readable storage medium for storing a program, which, when executed by a processor, implements the steps of the virtual resource quota management method as described in the first aspect.
[0035] In this embodiment, when a data sharing party uploads first data, a first target queue is obtained. The first target queue includes at least one element, which stores a pre-used quota value. The pre-used quota value is determined based on the virtual resource quota consumed by the data sharing party when downloading data. The first target queue is updated based on the supplementary quota value to obtain a second target queue. By storing the pre-used quota value in the elements of the first target queue and updating the first target queue with the supplementary quota value, the data sharing party can still download data even when the available virtual resource quota is insufficient, improving the flexibility and real-time performance of data download. Recording the use of virtual resource quota through the first target queue improves the flexibility of virtual resource quota management. Attached Figure Description
[0036] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 A flowchart illustrating the virtual resource quota management method provided in this application embodiment;
[0038] Figure 2 This is a schematic diagram of the structure of the target queue provided in an embodiment of this application;
[0039] Figure 3 A schematic diagram of the structure of a virtual resource quota management device provided in an embodiment of this application;
[0040] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0041] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0042] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms "first," "second," and similar terms used in this application do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, the terms "a" or "one," and similar terms do not indicate a quantity limitation, but rather indicate the presence of at least one. The terms "connected" or "linked," and similar terms, are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right," etc., are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship also changes accordingly.
[0043] The following description, in conjunction with the accompanying drawings, further illustrates the virtual resource quota management method, apparatus, electronic device, and storage medium proposed in the application embodiments.
[0044] Please see Figure 1 , Figure 1 A flowchart illustrating a method for managing virtual resource quotas provided in this application embodiment is shown in the figure. The method includes:
[0045] Step 101: When the data sharing party uploads the first data, obtain the first target queue. The first target queue includes at least one element, which is used to store the pre-use quota value. The pre-use quota value is determined based on the virtual resource quota consumed by the data sharing party when downloading the data.
[0046] The virtual resource quota management method provided in this invention can be applied to manage the available virtual resource quotas of alliance members in a blockchain. Each alliance member in the blockchain can act as a data sharing party, downloading shared data from the blockchain or uploading shared data to the blockchain.
[0047] It should be understood that, to maintain fairness in data sharing, each data sharer has a corresponding available virtual resource quota. Data sharers acquire virtual resource quotas for the corresponding data type by uploading data, while downloading data consumes virtual resource quotas for that data type. Specifically, when uploading data, the data sharer's available virtual resource quota increases based on the virtual resource quota corresponding to the uploaded data; conversely, when downloading data, the data sharer's available virtual resource quota decreases based on the virtual resource quota corresponding to the downloaded data.
[0048] As an optional implementation, in this embodiment, the virtual resource quota can be determined based on the number of data entries. Alternatively, the virtual resource quota can be determined based on the number of data entries and the value of each data entry; the specific calculation method is not limited here.
[0049] For example, assuming the data sharing party currently has an available virtual resource quota of 10, and the virtual resource quota obtained by the data sharing party from uploading data is 5, then the data sharing party's available virtual resource quota is updated to 15. If the data sharing party consumes 13 virtual resource quota to download data, then the data sharing party's available virtual resource quota is updated to 2. At this point, if the data sharing party requests to download data again, and this request is expected to consume 5 virtual resource quota, then the available quota value is stored in the first target queue, and the data sharing party's available virtual resource quota is updated to -3.
[0050] The target queue is used to record the virtual resource quota consumed by the data sharing party when downloading data, referred to as the pre-used quota value. As an optional implementation, when a data sharing party needs to download data but its available virtual resource quota is insufficient, the target queue records the pre-used quota value to achieve a system of replenishing virtual resource quota as needed. Alternatively, as another optional implementation, the target queue can also be used to record the virtual resource quota consumed for each data download; the specific implementation is not limited here.
[0051] It should be understood that for each data sharing party, there is a corresponding target queue. The specific status of the target queue is updated in real time based on the data upload / download status of the data sharing party. In this embodiment, the "first target queue", "second target queue" and "third target queue" are all target queues corresponding to the data sharing party. The different statuses of the target queues are identified and distinguished only by "first", "second", "third" etc.
[0052] In some embodiments, the length of the target queue can be set and adjusted in real time according to actual conditions, thereby improving the flexibility of the target queue. In other embodiments, the length of the target queue is preset to facilitate the management of the target queue. Optionally, the length of the first target queue is K, and the first target queue includes M elements, where K is a positive integer and M is an integer less than or equal to K.
[0053] It should be understood that, in the actual implementation, if the target queue is empty, it is equivalent to removing that element from the target queue, and the number of elements in the target queue decreases by one. In other words, when calculating the number of elements in the target queue, only the number of non-empty elements in the target queue is counted.
[0054] It should be understood that the first target queue includes at least one element indicating that when the data sharing party uploads the first data, the data sharing party has a pre-used quota value. At this time, the available virtual resource quota of the data sharing party is negative. The data sharing party obtains the corresponding virtual resource quota by uploading the first data to complete the pre-used quota value and increase the available virtual resource quota of the data sharing party.
[0055] It should be understood that the specific amount of the pre-use quota value corresponding to each element in the first target queue may be the same or different. In some embodiments, each element is used to record the virtual resource quota consumed in a data download operation. In other embodiments, the maximum value of the pre-use quota value corresponding to each element is the same, and when a data download consumes a large amount of virtual resource quota, the pre-use quota value corresponding to that download can be recorded by multiple elements.
[0056] For example, the virtual resource quota consumed when the data sharing party downloads data A is 10, and the virtual resource quota consumed when downloading data B is 5. As an optional implementation, element 1 stores the virtual resource quota consumed when downloading data A, that is, the pre-used quota value stored in element 1 is 10, and element 2 stores the virtual resource quota consumed when downloading data B, that is, the pre-used quota value stored in element 2 is 5.
[0057] Step 102: Update the first target queue based on the supplementary quota value to obtain a second target queue. If the supplementary quota value is less than or equal to the first total pre-used quota value, the second total pre-used quota value is the difference between the first total pre-used quota value and the supplementary quota value. If the supplementary quota value is greater than the first total pre-used quota value, the second total pre-used quota value is 0. The first total pre-used quota value is the sum of the pre-used quota values of all elements in the first target queue. The second total pre-used quota value is the sum of the pre-used quota values of all elements in the second target queue. The supplementary quota value is the virtual resource quota obtained by the data sharing party from uploading the first data.
[0058] The supplementary quota value is the virtual resource quota obtained by the data sharing party from uploading the first data. The first target queue is updated based on the supplementary quota value. For ease of distinction, the updated first target queue is referred to as the second target queue. It should be understood that, depending on the relationship between the supplementary quota value and the total value of the first pre-used quota, the number of elements in the second target queue and / or the size of the pre-used quota value corresponding to each element may be the same as or different from that in the first target queue.
[0059] It should be understood that after updating the first target queue based on the supplementary quota value to obtain the second target queue, the available virtual resource quota of the data sharing party will also be updated synchronously. Specifically, the specific method of updating the first target queue based on the supplementary quota value, and the method of updating the available virtual resource quota are not limited here.
[0060] To facilitate understanding, a specific embodiment will be used as an example below to illustrate different situations.
[0061] Assuming the first target queue contains 3 elements, element 1 stores a pre-use quota of 5, element 2 stores a pre-use quota of 7, and element 3 stores a pre-use quota of 3, then the total pre-use quota is 15.
[0062] When the supplementary credit limit is 10, the supplementary credit limit is less than the total first-use credit limit. As an optional implementation method, a elements are obtained from M elements, where a is a positive integer less than or equal to M. The sum of the first-use credit limit values of the a elements is greater than the supplementary credit limit value. The first-use credit limit values of the a elements are adjusted so that the sum of the first-use credit limit values of the a elements is less than the supplementary credit limit value.
[0063] For example, given elements 1 and 2, whose combined pre-allocation quota values are 12, we can adjust their pre-allocation quota values to decrease the sum by 10, making it 2. This adjustment can be done by setting element 1's pre-allocation quota value to 0 and element 2's to 2; it can also be done by setting element 1's to 2 and element 2's to 0; or it can be done by setting element 1's to 1 and element 2's to 1. The specific method is not limited here. Using these methods, the total pre-allocation quota value of the second target queue is 5 (the sum of element 1 and element 2's pre-allocation quota values is 2, plus the pre-allocation quota value of 3 stored in element 3).
[0064] For example, we can obtain three elements: element 1, element 2, and element 3. The sum of their pre-use quota values is 15. We can adjust the pre-use quota values of elements 1, 2, and 3 so that their sum decreases by 10, becoming 5. The specific adjustment method is not limited here. Through the above method, the total pre-use quota value of the second target queue is also 5.
[0065] In this scenario, the available virtual resource quota for the data sharing party is -5. It should be understood that since the target queue stores the pre-used quota value, which is equivalent to an overdrawn available virtual resource quota, the available virtual resource quota is negative.
[0066] With a supplementary quota value of 15, the supplementary quota value equals the total value of the first-use quota. At this point, the first-use quota values of all M elements are adjusted to 0. In this situation, the available virtual resource quota for the data sharing party is 0.
[0067] With a supplementary quota value of 20, which is greater than the total first-use quota value, the first-use quota values of all M elements are adjusted to 0. In this case, the available virtual resource quota of the data sharing party is 5. In practical implementation, the available virtual resource quota of the data sharing party can be updated based on the difference between the supplementary quota value and the total first-use quota value.
[0068] Optionally, in some embodiments, step 102 includes:
[0069] Perform at least one iterative update operation on the first target queue and the supplementary quota value until the updated first target queue is empty or the updated supplementary quota value is 0;
[0070] The updated first target queue is designated as the second target queue.
[0071] In this embodiment, at least one iterative update operation is performed on the first target queue and the supplementary quota value. Each time, the first target queue and the supplementary quota value are updated synchronously until the updated first target queue is empty or the updated supplementary quota value is 0.
[0072] If the supplementary quota value is less than or equal to the total first-use quota value, it's equivalent to exhausting the supplementary quota value without being able to replenish all the first-use quota value. Therefore, at least one iterative update operation is performed on the first target queue and the supplementary quota value until the supplementary quota value is 0. The updated total second-use quota value of the first target queue (i.e., the second target queue) is the total first-use quota value minus the supplementary quota value. At this point, the negative of the total second-use quota value is the available virtual resource quota of the data sharing party.
[0073] If the supplementary quota value is greater than the total value of the first pre-used quota, it means that the supplementary quota value can not only fill all the pre-used quota values, but also have a surplus. Therefore, at least one iterative update operation is performed on the first target queue and the supplementary quota value until the first target queue is 0. The updated first target queue (i.e., the second target queue) is empty, and the updated supplementary quota value is the supplementary quota value minus the total value of the first pre-used quota. At this time, the updated supplementary quota value is equal to the available virtual resource quota of the data sharing party.
[0074] In this embodiment, at least one iterative update operation is performed on the first target queue and the supplementary quota value until the updated first target queue is empty or the updated supplementary quota value is 0. By processing only one element at a time, the processing efficiency can be improved, and the number of elements in the target queue can be minimized.
[0075] As an optional implementation, the iterative update operation includes:
[0076] Obtain a first element from the first target queue. The first element includes a first priority quota value, which is determined based on the virtual resource quota consumed by the data sharing party when downloading the second data.
[0077] If the current supplementary quota value is greater than or equal to the first pre-used quota value, the first element is removed from the first target queue, and the current supplementary quota value is subtracted from the first pre-used quota value to obtain the updated supplementary quota value.
[0078] If the current supplementary credit limit is less than the first available credit limit, the current first available credit limit is subtracted from the current supplementary credit limit to obtain the updated first available credit limit, and the updated supplementary credit limit is set to 0.
[0079] To facilitate understanding, a specific embodiment will be used as an example below. The first element is obtained from the first target queue. The first element includes a first used quota value, assumed to be 5, indicating that the previous data sharing party consumed 5 virtual resource quotas when downloading the second data.
[0080] In the first case, the current supplementary quota value is 10, which is greater than the first priority quota value. At this time, the first priority quota value is changed to 0, and the first element becomes empty. This is equivalent to removing the first element from the first target queue. At the same time, the supplementary quota value is updated to 5.
[0081] At this point, if there are no other elements in the first target queue, it is equivalent to satisfying the condition that the first target queue is empty, so the iteration update stops, and the second target queue is obtained. If there are other elements in the first target queue, a new round of iteration begins, and another element is extracted from the updated first target queue as the first element, the details of which are not elaborated here.
[0082] In the second case, the current supplementary quota value is 3, which is less than the first priority quota value. At this time, the first priority quota value is changed to 2 to obtain the updated first priority quota value, and the updated supplementary quota value is set to 0. At this time, the condition that the updated supplementary quota value is 0 is met, so the iterative update stops and the second target queue is obtained.
[0083] It should be understood that the second target queue is actually the first target queue after iterative updates. The number of elements and / or the initial quota value in the second target queue are different from those in the first target queue, so that the total initial quota value corresponding to the second target is the difference between the total initial quota value and the supplementary quota value or 0.
[0084] As an optional implementation, the first element can be randomly selected from the first target queue. Alternatively, the first element can be selected from the first target queue according to a preset rule; for example, the first element can be selected from the first target queue as the first element.
[0085] As another optional implementation, the first element is the element with the smallest pre-use quota value among the M elements. In this embodiment, the element with the smallest pre-use quota value is extracted first, thereby maximizing the number of elements removed, resulting in fewer elements and a larger capacity in the second target queue.
[0086] As a specific implementation, the M elements are arranged in ascending order according to their corresponding first-use quota values, with the element with the smaller first-use quota value being closer to the left side of the first target queue. The step of obtaining the first element from the first target queue includes extracting the first element from the left side of the first target queue as the first element.
[0087] Optionally, in some embodiments, before step 101, the method further includes:
[0088] In the event that the data sharing party requests the second data, a third target queue is obtained, the third target queue comprising N elements, where N is an integer less than or equal to K;
[0089] If the third target queue is not empty, determine whether N is less than K;
[0090] When N is less than K, the first element is created based on the first priority quota value, where the first priority quota value is the virtual resource quota consumed for downloading the second data;
[0091] The first element is added to the third target queue to obtain the first target queue.
[0092] It should be understood that both the third and second target queues are target queues corresponding to the data sharing party. Since the specific content of the data in the target queue will change constantly depending on the data sharing party's operations such as uploading and / or requesting data, the different states of the target queue are distinguished by the terms "first", "second", and "third".
[0093] When the data sharing party requests to download the second data, the third target queue is first obtained. The number of elements in the third target queue at this time is recorded as N. It is then determined whether N is less than K. If N is less than K, it means that there is still space in the third target queue to add new elements. If N equals K, it means that the third target queue is full and no new elements can be added.
[0094] The following explains how to handle different situations.
[0095] If the third target queue is not empty and N is less than K, the first element is created based on the virtual resource quota consumed by the data sharing party when downloading the second data, and the first element is added to the third target queue (this process can also be understood as writing the first quota value into the first element). The updated third target queue is the first target queue.
[0096] If the third target queue is not empty and N equals K, then the third target queue is full and no new element can be added. As an optional implementation, a fourth element is obtained from the third target queue. This fourth element can be any element in the third target queue. The fourth priority quota value stored in the fourth element is added to the first priority quota value to obtain an updated third target queue, which becomes the first target queue. In this embodiment, although no new element is added, the total priority quota value of the target queue is updated, thus achieving the recording of the first priority quota value.
[0097] Optionally, in some embodiments, before creating the first element based on the first pre-allocated limit value when N is less than K, the method further includes:
[0098] When N equals K, at least one second element is obtained from the N elements, the second element including a second pre-used credit value;
[0099] The current third priority limit value is summed with the second priority limit value to obtain the updated third priority limit value. The third priority limit value is the priority limit value included in the third element. The third element is the element other than the second element among the N elements.
[0100] Remove the second element from the third target queue.
[0101] When N equals K, the third target queue is full. To add new elements, the existing elements in the third target queue can be compressed and merged. Specifically, at least one second element is taken from the N elements, its pre-use quota value is added to the other elements, and the second element is removed. In this way, the number of elements in the third target queue decreases, but the total pre-use quota value of the third target queue remains unchanged.
[0102] As one optional implementation, at least one second element is randomly selected from the N elements. As another optional implementation, at least one second element is sequentially selected from the N elements in a preset order. As yet another optional implementation, at least one second element is sequentially selected from the N elements in ascending order of the first-used credit limit value.
[0103] As one optional implementation, the third element can be any element among the N elements other than the second element. As another optional implementation, the third element is the element among the N elements that is closest to the second element, excluding the second element. As yet another optional implementation, the third element is the element among the N elements that has the smallest corresponding first-use limit value, excluding the second element.
[0104] It should be understood that the specific method for compressing and merging the elements in the third target queue is not limited here. In some embodiments, before obtaining at least one second element from the N elements when N equals K, the method further includes pre-determining the compression amount, i.e., the number of second elements to be extracted.
[0105] For ease of understanding, the following is an example using a specific implementation. Two second elements are extracted from N elements, denoted as element 1 and element 2. The second available amount for element 1 is 5, and the second available amount for element 2 is 10.
[0106] As an optional implementation, take any one element from N elements, for example, element 3, whose third priority quota value is 1. Add the second priority quota values of elements 1 and 2 to element 3, update the third priority quota value of element 3 to 16, update the second priority quota values of elements 1 and 2 to 0, and remove elements 1 and 2 from the third target queue.
[0107] As another optional implementation, any two elements are taken from N elements, such as elements 3 and 4. The third priority quota value of element 3 is 1, and the third priority quota value of element 4 is 15. The second priority quota value of element 1 is added to element 3, and the third priority quota value of element 3 is updated to 6. The second priority quota value of element 2 is added to element 4, and the third priority quota value of element 4 is updated to 25. The second priority quota values of elements 1 and 2 are updated to 0. Elements 1 and 2 are removed from the third target queue.
[0108] Optionally, in some embodiments, the element further includes an ordered sequence number and element content, wherein the ordered sequence number is used to record the position of the element in the target queue, and the record of the first-use quota is used for the specific data content corresponding to the first-use quota value.
[0109] In this embodiment, the element includes three fields, which are used to record the ordered sequence number, the first-used quota value, and the element content, respectively. In this way, the element in the target queue can not only record the value of the first-used quota value, but also record the specific data download content, thereby improving the comprehensiveness of virtual resource quota management.
[0110] It should be understood that when processing elements, all fields within the element are typically processed. For example, when merging two elements, it is necessary not only to add the available credit values of the two elements, but also to concatenate the other fields of the two elements.
[0111] Optionally, in some embodiments, before obtaining the third target queue upon the data sharing party requesting the second data, the method further includes:
[0112] The credit value of the data sharing party is determined based on the amount of data downloaded and the amount of data uploaded within the preset period.
[0113] If the credit value is greater than the credit threshold, the third target queue corresponding to the data sharing party is constructed.
[0114] In this embodiment, before constructing a target queue for the data sharing party, the credit score of the data sharing party is evaluated based on its data upload and download volumes. If the credit score is greater than a credit threshold, a third target queue corresponding to the data sharing party is constructed.
[0115] In some embodiments, if the credit value is less than or equal to the credit threshold, a third target queue corresponding to the data sharing party is not constructed. Because the data sharing party does not have a corresponding target queue, it will be unable to implement the "use first, replenish later" virtual resource quota system.
[0116] In some embodiments, the data download volume and data upload volume of the data sharing party within a preset period are obtained, and a credit score is determined based on the ratio of data upload volume to data download volume. In other embodiments, the credit score is determined based on the difference between data upload volume and data download volume; the specific determination method is not limited here.
[0117] As a specific embodiment, a preset period is divided into multiple calculation periods; the determination of the data sharing party's credit value based on the data download volume and data upload volume within the preset period includes:
[0118] The data sharing party acquires the first uploaded data volume within the first calculation period, the second uploaded data volume within the preset period, the first downloaded data volume within the first calculation period, and the second downloaded data volume within the preset period.
[0119] A first value is determined based on the first uploaded data volume and the first downloaded data volume, and a second value is determined based on the second uploaded data volume and the second downloaded data volume;
[0120] The credit value is determined based on the first value and the second data, and the first calculation period is the current calculation period.
[0121] It should be understood that the uploaded data volume refers to the number of data entries uploaded, and the downloaded data volume refers to the number of data entries downloaded. The following is a specific example illustrating the detailed calculation method of the credit score. The credit score of the data sharing party in the i-th calculation period is... :
[0122] ;
[0123] Where i represents the i-th calculation cycle in the preset cycle. An initial default credit value for each data sharing party. Let U be the credit value for the (i-1)th calculation period. U represents the amount of data uploaded by the data sharing party, where... This represents the cumulative amount of data uploaded by the data sharing party within a preset period. represents the amount of data uploaded by the data sharing party during the i-th computation cycle; D represents the amount of data acquired and used by the data sharing party within the blockchain, where, This represents the cumulative amount of data acquired and used within the blockchain by the data-sharing parties over a preset period. This represents the amount of data acquired and used by the data sharing party within the blockchain during the i-th computation cycle.
[0124] In this embodiment, the preset period is divided into multiple calculation periods, and the credit score is calculated in units of these calculation periods. This credit score changes with each calculation period. This approach makes the calculation of the credit score more flexible and reasonable.
[0125] The following describes the specific process of the virtual resource quota management method provided by the present invention, using a complete embodiment as an example.
[0126] First, let's introduce the process of establishing the consortium. Each data-sharing party applies to join the consortium blockchain. These parties request to access shared data and also upload and share it. The blockchain consortium reviews the applications from the data-sharing parties. If the review fails, the process ends. If the review is successful, the consortium blockchain administrator assigns the relevant accounts and public / private keys to the approved data-sharing parties on the consortium node management platform. Newly joined data-sharing parties deploy consortium nodes according to their assigned accounts and code. If the data-sharing party is deployed for the first time along with the consortium blockchain, the data in the consortium blockchain is initially empty. If the data-sharing party joins while the consortium blockchain is running, it first synchronizes existing data from other nodes. After data synchronization is complete, it officially becomes a consortium blockchain node, capable of providing on-chain data read and write capabilities.
[0127] It should be understood that, in practical implementation, after the alliance is established, a smart contract will be released. The smart contract mainly consists of a data area and a function area. The data area mainly includes the ID of the data sharing party, the data type of the data to be uploaded to the chain, the length K of the target queue, the corresponding virtual resource quota that can be obtained for different types of data uploaded to the chain, and the quota required to obtain different types of data. The function area mainly includes the construction and maintenance of an ordered double-ended queue array.
[0128] The following describes the specific process of acquiring and uploading shared data. Each alliance member, as the uploader of shared data, can continuously upload data, accumulating the virtual resource quota for the corresponding data type. Each alliance member, as the acquirer of shared data, can continuously acquire data to fulfill business requirements as long as the virtual resource quota is available. When the virtual resource quota of a data sharing party is insufficient, a smart contract is triggered to begin constructing or maintaining an ordered double-ended queue array with a "use first, replenish later" quota system, i.e., the target queue. The design of the target queue is as follows... Figure 2 As shown.
[0129] like Figure 2 As shown, each alliance member in the blockchain is an ordered double-ended queue in the array corresponding to the data sharing party. The i-th numbered alliance member corresponds to the i-th ordered double-ended queue in the array. That is, the i-th ordered double-ended queue is the target queue corresponding to the i-th numbered alliance member. Here, i starts from 1 and increments.
[0130] Each target queue stores the "use first, replenish later" process of virtual resource quotas. The length of the target queue is K, where K is a pre-defined value in the smart contract data area. Through this method, each alliance member always maintains a record of a maximum of K instances of quota usage, keeping storage space usage controllable. When quota usage occurs, the used quota record is inserted from the left side of the target queue; when quota is replenished later, it is retrieved from the right side of the target queue.
[0131] Each element in the target queue consists of three parts: an ordered sequence number, a first-use quota value, and the element content (i.e., the record of the first-use quota, such as alliance member A reading alliance member B's Cth piece of information and using quota D first). The ordered sequence number identifies the element's position in the target queue by its ascending order. This sequence number resolves the issue of elements entering the target queue in sequence not being able to be sorted. When new data is inserted into the target queue, the sequence numbers of elements already containing data are reordered and updated. When data is removed from the queue, the sequence numbers of all elements in the queue are decremented by one.
[0132] The above method enables efficient data reading and writing, ensuring that the target queues of each alliance member do not interfere with each other and that data is isolated. Furthermore, if data cannot fill the deque or array, no extra space is occupied; empty elements are promptly cleared, saving space.
[0133] It should be understood that, in some embodiments, the target queue also serves to conduct credit assessments of data sharing parties, mainly in two aspects: whether the target queue has been created and whether the target queue is full.
[0134] Taking the creation of the target queue as an example, when the available virtual resource quota for data sharing is insufficient, the smart contract is triggered to prepare to start building or maintaining the target queue with the "use first, replenish later" quota. The smart contract calculates and judges the credit status of the data sharing party. If the credit value is lower than the credit threshold configured in the smart contract, the target queue will not be established, that is, the "use first, replenish later" mechanism will not be opened to the data sharing party. Otherwise, the mechanism will be opened, that is, the target queue will be established for them.
[0135] Specifically, query the number of consortium members in the blockchain, num; construct an array of length num based on the number of consortium members num, where each element of the array is a double-ended queue of length K, and at this time all double-ended queues in the array are empty.
[0136] In the process of determining whether the target queue is full, if the target queue is full but the data sharing party still wants to use the mode, the smart contract determines the creditworthiness of the data sharing party. If the creditworthiness is low, the mode cannot be used first. The method for determining the mode can be found in the description of the target queue creation process. Specifically, when the credit value is greater than a threshold, the data sharing party has a high creditworthiness. In this case, a compression algorithm is applied to the full target queue to achieve the logical effect of "dynamic expansion" of the target queue (without physical capacity expansion).
[0137] For example, the compression rate is related to the credit value (where the credit value is greater than 1). In some embodiments, the compression rate = credit value - 1. That is, if the compression rate = 0.23, the target queue will be compressed to free up space equal to the target queue length × 0.23 (rounded down). As a specific embodiment, the compression of the target queue starts with the data with the smaller sequence number. For example, if the number of spaces calculated by the compression rate (i.e., the number of second elements to be extracted) is 2, then the elements with sequence numbers 1 and 2 are determined as the second elements, and the elements with sequence numbers 3 and 4 are determined as the third elements. The elements with sequence numbers 1 and 2 are merged into the array elements with sequence numbers 3 and 4. After merging, the credit limit is added first, and the queue content field is the concatenation of the contents of the two elements before merging. After merging, the sequence numbers of each element in the target queue are uniformly adjusted. At this time, the target queue is not full and can continue the normal "use first, replenish later" mode.
[0138] The following describes the data insertion process for the target queue.
[0139] When the available virtual resource quota of the data sharing party is insufficient and quota needs to be used first, the target queue Qi with the number i is obtained based on the alliance member number i of the data sharing party. If there is already data at the Kth position of the target queue Qi, it means that the queue is full and the quota use mode can no longer continue, and the process ends.
[0140] If the Kth position of the target queue Qi is empty, a double-ended queue element c is constructed. The pre-used quota record is filled into the element content field of element c, and the pre-used quota value is filled into the pre-used quota quantity field. If the target queue Qi is empty at this time, it means that the first element is about to be inserted, and the ordered sequence number of element c is 1. If the target queue Qi is not full, based on the pre-used quota value of the current element c, the ordered sequence number of all elements in the target queue Qi is updated by comparing the pre-used quota values of the existing elements in the target queue Qi. The update method is to sort the elements in ascending order of pre-used quota values, that is, elements with smaller pre-used quota values have smaller ordered sequence numbers. The element c is then inserted into the target queue Qi.
[0141] The target queue Qi is serialized and packaged into a block, and published to the blockchain for consensus. If consensus is successful, the quota is used successfully first. At this time, the updated available virtual resource quota of the data sharing party is equal to the available virtual resource quota before the update minus the virtual resource quota consumed in this data acquisition. At this time, the available virtual resource quota is negative.
[0142] After the target queue is updated, the data sharing party can obtain the required data. This process is carried out when the available virtual resource quota of the data sharing party is insufficient, so it can be called the "quota first" process.
[0143] When a data sharing party uploads data, it determines whether the available virtual resource quota of the current data sharing party is negative. If the available virtual resource quota is negative, the virtual resource quota corresponding to the currently uploaded data is taken as the supplementary quota value, and the supplementary step is initiated.
[0144] Based on the alliance member ID i of the data sharing party, the target queue Qi with ID i is obtained. At the exit on the right side of the target queue Qi, the elements in the target queue Qi are traversed one by one until the queue element c with the ordered sequence number 1 is found, which is the first element. If the supplementary quota value is less than the pre-used quota value of element c, then supplementary quota cannot be added at this time, the quota is insufficient, the process ends, the target queue Qi is serialized and packaged into a block, and published to the blockchain for consensus. If consensus is successful, the supplementary quota is successfully added, and the supplementary quota value is added to the available virtual resource quota of the alliance member with ID i.
[0145] If the supplementary quota value is greater than or equal to the pre-used quota value of element c, then element c is retrieved from the target queue Qi, thus completing the supplementary quota behavior for the pre-used quota corresponding to that element. The updated supplementary quota value is the original supplementary quota value minus the pre-used quota value of element c. After removing element c, the ordered sequence number fields of all remaining elements in the target queue Qi are decremented by 1.
[0146] If the updated supplementary quota value is greater than 0, and the available virtual resource quota of the data sharing party is also greater than 0, then the available virtual resource quota of the data sharing party is updated by adding the updated supplementary quota value to the original available virtual resource quota of the sharing party. If the updated supplementary quota value is greater than 0, and the available virtual resource quota of the data sharing party is less than or equal to 0, then a new round of supplementation is started based on the updated supplementary quota value. The above operation is repeated from the new first element with ordered sequence number 1 in the target queue Qi until the supplementation is completed. Finally, the target queue Qi is serialized, packaged into a block, and published to the blockchain for consensus. If consensus is successful, the supplementary quota is successfully supplemented.
[0147] In this embodiment, when a data sharing party's available virtual resource quota is insufficient, it can request "quota replenishment after use." After the entire chain reaches a consensus on "quota replenishment after use," the data sharing party can acquire data first, and subsequently update its available virtual resource quota as the data is uploaded to the chain. This solution tracks and records the update status of virtual resource quotas through a target queue, ensuring not only the fairness of data sharing but also flexible, quota-limited support for data sharing, thus improving the real-time performance of data acquisition.
[0148] Taking a real-world application scenario as an example, when a user watches a video for the first time using video software, if the data sharing party has zero available virtual resource quota, it cannot promptly obtain the user's usage behavior from the blockchain and therefore cannot provide targeted services. Using the method provided in this invention, the data sharing party can record the virtual resource quota currently used for downloading data as a pre-used quota value in the target queue. When subsequent data is uploaded to the blockchain and the virtual resource quota increases, the aforementioned process of replenishing the pre-used quota is executed. In this way, the data sharing party can promptly obtain the required data from the blockchain and complete accurate user recommendations.
[0149] Please see Figure 3 This invention also provides a virtual resource quota management device 300. Figure 3 This is one of the structural diagrams of the virtual resource quota management device 300 provided in this embodiment of the invention. Because the principle of the virtual resource quota management device 300 in solving the problem is similar to that in this embodiment of the invention... Figure 1 The method for managing virtual resource quotas shown is similar, so the implementation of the virtual resource quota management device 300 can be found in the implementation of the method, and the repeated parts will not be described again.
[0150] like Figure 3 As shown, the virtual resource quota management device 300 includes:
[0151] The first acquisition module 301 is used to acquire a first target queue when the data sharing party uploads the first data. The first target queue includes at least one element, which is used to store a pre-use quota value. The pre-use quota value is determined based on the virtual resource quota consumed by the data sharing party when downloading data.
[0152] The update module 302 is used to update the first target queue based on the supplementary quota value to obtain a second target queue. When the supplementary quota value is less than or equal to the first total pre-used quota value, the second total pre-used quota value is the difference between the first total pre-used quota value and the supplementary quota value. When the supplementary quota value is greater than the first total pre-used quota value, the second total pre-used quota value is 0. The first total pre-used quota value is the sum of the pre-used quota values of all elements in the first target queue. The second total pre-used quota value is the sum of the pre-used quota values of all elements in the second target queue. The supplementary quota value is the virtual resource quota obtained by the data sharing party from uploading the first data.
[0153] Optionally, the update module 302 includes:
[0154] An iterative update unit is used to perform at least one iterative update operation on the first target queue and the supplementary quota value until the updated first target queue is empty or the updated supplementary quota value is 0.
[0155] A determining unit is used to determine the updated first target queue as the second target queue.
[0156] Optionally, the iterative update operation includes:
[0157] Obtain a first element from the first target queue. The first element includes a first priority quota value, which is determined based on the virtual resource quota consumed by the data sharing party when downloading the second data.
[0158] If the current supplementary quota value is greater than or equal to the first pre-used quota value, the first element is removed from the first target queue, and the current supplementary quota value is subtracted from the first pre-used quota value to obtain the updated supplementary quota value.
[0159] If the current supplementary credit limit is less than the first available credit limit, the current first available credit limit is subtracted from the current supplementary credit limit to obtain the updated first available credit limit, and the updated supplementary credit limit is set to 0.
[0160] Optionally, the length of the first target queue is K, and the first target queue includes M elements, where K is a positive integer and M is an integer less than or equal to K; the first element is the element with the smallest pre-use quota value among the M elements.
[0161] Optionally, the virtual resource quota management device 300 further includes:
[0162] The second acquisition module is used to acquire a third target queue when the data sharing party requests the second data. The third target queue includes N elements, where N is an integer less than or equal to K.
[0163] The judgment module is used to determine whether N is less than K when the third target queue is not empty;
[0164] A creation module is used to create the first element based on a first priority quota value when N is less than K, wherein the first priority quota value is the virtual resource quota consumed for downloading the second data;
[0165] An adding module is used to add the first element to the third target queue to obtain the first target queue.
[0166] Optionally, the virtual resource quota management device 300 further includes:
[0167] The third acquisition module is used to acquire at least one second element from the N elements when N equals K, wherein the second element includes a second pre-used credit value;
[0168] The processing module is used to sum the current third priority quota value with the second priority quota value to obtain the updated third priority quota value. The third priority quota value is the priority quota value included in the third element. The third element is the element other than the second element among the N elements.
[0169] A removal module is used to remove the second element from the third target queue.
[0170] Optionally, the virtual resource quota management device 300 further includes:
[0171] The determination module is used to determine the credit value of the data sharing party based on the data download volume and the data upload volume of the data sharing party within a preset period.
[0172] A construction module is used to construct the third target queue corresponding to the data sharing party when the credit value is greater than the credit threshold.
[0173] The virtual resource quota management device 300 provided in this embodiment of the invention can execute the above-described virtual resource quota management method embodiment. Its implementation principle and technical effect are similar, and will not be described again here.
[0174] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0175] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can be physically comprised separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or in the form of hardware plus software functional units.
[0176] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute some steps of the transmission and reception methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0177] like Figure 4 As shown, this embodiment of the invention also provides an electronic device 400, which includes: a processor 401, configured to read a program from a memory 402 and execute the following steps:
[0178] When the data sharing party uploads the first data, a first target queue is obtained. The first target queue includes at least one element, which is used to store the pre-use quota value. The pre-use quota value is determined based on the virtual resource quota consumed by the data sharing party when downloading the data.
[0179] The first target queue is updated based on the supplementary quota value to obtain the second target queue. When the supplementary quota value is less than or equal to the first total pre-used quota value, the second total pre-used quota value is the difference between the first total pre-used quota value and the supplementary quota value. When the supplementary quota value is greater than the first total pre-used quota value, the second total pre-used quota value is 0. The first total pre-used quota value is the sum of the pre-used quota values of all elements in the first target queue. The second total pre-used quota value is the sum of the pre-used quota values of all elements in the second target queue. The supplementary quota value is the virtual resource quota obtained by the data sharing party from uploading the first data.
[0180] Optionally, the processor 401 is further configured to read the program in the memory 402 and perform the following steps:
[0181] Perform at least one iterative update operation on the first target queue and the supplementary quota value until the updated first target queue is empty or the updated supplementary quota value is 0;
[0182] The updated first target queue is designated as the second target queue.
[0183] Optionally, the processor 401 is further configured to read the program in the memory 402 and perform the following steps:
[0184] Obtain a first element from the first target queue. The first element includes a first priority quota value, which is determined based on the virtual resource quota consumed by the data sharing party when downloading the second data.
[0185] If the current supplementary quota value is greater than or equal to the first pre-used quota value, the first element is removed from the first target queue, and the current supplementary quota value is subtracted from the first pre-used quota value to obtain the updated supplementary quota value.
[0186] If the current supplementary credit limit is less than the first available credit limit, the current first available credit limit is subtracted from the current supplementary credit limit to obtain the updated first available credit limit, and the updated supplementary credit limit is set to 0.
[0187] Optionally, the length of the first target queue is K, and the first target queue includes M elements, where K is a positive integer and M is an integer less than or equal to K; the first element is the element with the smallest pre-use quota value among the M elements.
[0188] Optionally, the processor 401 is further configured to read the program in the memory 402 and perform the following steps:
[0189] In the event that the data sharing party requests the second data, a third target queue is obtained, the third target queue comprising N elements, where N is an integer less than or equal to K;
[0190] If the third target queue is not empty, determine whether N is less than K;
[0191] When N is less than K, the first element is created based on the first priority quota value, where the first priority quota value is the virtual resource quota consumed for downloading the second data;
[0192] The first element is added to the third target queue to obtain the first target queue.
[0193] Optionally, the processor 401 is further configured to read the program in the memory 402 and perform the following steps:
[0194] When N equals K, at least one second element is obtained from the N elements, the second element including a second pre-used credit value;
[0195] The current third priority limit value is summed with the second priority limit value to obtain the updated third priority limit value. The third priority limit value is the priority limit value included in the third element. The third element is the element other than the second element among the N elements.
[0196] Remove the second element from the third target queue.
[0197] Optionally, the processor 401 is further configured to read the program in the memory 402 and perform the following steps:
[0198] The credit value of the data sharing party is determined based on the amount of data downloaded and the amount of data uploaded within the preset period.
[0199] If the credit value is greater than the credit threshold, the third target queue corresponding to the data sharing party is constructed.
[0200] The electronic device 400 provided in this embodiment of the invention can execute the above-described virtual resource quota management method embodiment. Its implementation principle and technical effect are similar, and will not be described again here.
[0201] This application also provides a readable storage medium storing a program. When the program is executed by a processor, it implements the various processes of the above-described virtual resource quota management method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0202] The readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as compact disks (CD), digital video discs (DVD), Blu-ray discs (BD), high-definition universal discs (HVD), etc.), and semiconductor storage (such as read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), non-volatile memory (NAND FLASH), solid-state disks (SSD), etc.).
[0203] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0204] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0205] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A method for managing virtual resource quotas, characterized in that, include: When the data sharing party uploads the first data, a first target queue is obtained. The first target queue includes at least one element, which is used to store the pre-use quota value. The pre-use quota value is determined based on the virtual resource quota consumed by the data sharing party when downloading the data. The first target queue is updated based on the supplementary quota value to obtain the second target queue. When the supplementary quota value is less than or equal to the first total pre-used quota value, the second total pre-used quota value is the difference between the first total pre-used quota value and the supplementary quota value. When the supplementary quota value is greater than the first total pre-used quota value, the second total pre-used quota value is 0. The first total pre-used quota value is the sum of the pre-used quota values of all elements in the first target queue. The second total pre-used quota value is the sum of the pre-used quota values of all elements in the second target queue. The supplementary quota value is the virtual resource quota obtained by the data sharing party from uploading the first data.
2. The method according to claim 1, characterized in that, The step of updating the first target queue based on the supplementary quota value to obtain the second target queue includes: Perform at least one iterative update operation on the first target queue and the supplementary quota value until the updated first target queue is empty or the updated supplementary quota value is 0; The updated first target queue is designated as the second target queue.
3. The method according to claim 2, characterized in that, The iterative update operation includes: Obtain a first element from the first target queue. The first element includes a first priority quota value, which is determined based on the virtual resource quota consumed by the data sharing party when downloading the second data. If the current supplementary quota value is greater than or equal to the first pre-used quota value, the first element is removed from the first target queue, and the current supplementary quota value is subtracted from the first pre-used quota value to obtain the updated supplementary quota value. If the current supplementary credit limit is less than the first available credit limit, the current first available credit limit is subtracted from the current supplementary credit limit to obtain the updated first available credit limit, and the updated supplementary credit limit is set to 0.
4. The method according to claim 3, characterized in that, The length of the first target queue is K, and the first target queue includes M elements, where K is a positive integer, M is an integer less than or equal to K, and the first element is the element with the smallest corresponding first-use quota value among the M elements.
5. The method according to claim 3, characterized in that, Before obtaining the first target queue when the data sharing party uploads the first data, the method further includes: In the event that the data sharing party requests the second data, a third target queue is obtained, the third target queue comprising N elements, where N is an integer less than or equal to K; If the third target queue is not empty, determine whether N is less than K; When N is less than K, the first element is created based on the first priority quota value, where the first priority quota value is the virtual resource quota consumed for downloading the second data; The first element is added to the third target queue to obtain the first target queue.
6. The method according to claim 5, characterized in that, When N is less than K, before creating the first element based on the first available credit limit value, the method further includes: When N equals K, at least one second element is obtained from the N elements, the second element including a second pre-used credit value; The current third priority limit value is summed with the second priority limit value to obtain the updated third priority limit value. The third priority limit value is the priority limit value included in the third element. The third element is the element other than the second element among the N elements. Remove the second element from the third target queue.
7. The method according to claim 5, characterized in that, Before obtaining the third target queue when the data sharing party requests the second data, the method further includes: The credit value of the data sharing party is determined based on the amount of data downloaded and the amount of data uploaded within the preset period. If the credit value is greater than the credit threshold, the third target queue corresponding to the data sharing party is constructed.
8. A device for managing virtual resource quotas, characterized in that, include: The first acquisition module is used to acquire a first target queue when the data sharing party uploads the first data. The first target queue includes at least one element, which is used to store a pre-use quota value. The pre-use quota value is determined based on the virtual resource quota consumed by the data sharing party when downloading data. The update module is used to update the first target queue based on the supplementary quota value to obtain a second target queue. When the supplementary quota value is less than or equal to the first total pre-used quota value, the second total pre-used quota value is the difference between the first total pre-used quota value and the supplementary quota value. When the supplementary quota value is greater than the first total pre-used quota value, the second total pre-used quota value is 0. The first total pre-used quota value is the sum of the pre-used quota values of all elements in the first target queue. The second total pre-used quota value is the sum of the pre-used quota values of all elements in the second target queue. The supplementary quota value is the virtual resource quota obtained by the data sharing party from uploading the first data.
9. An electronic device, comprising: A memory, a processor, and a program stored in the memory and executable on the processor; characterized in that, The processor is used to read a program from the memory to implement the steps in the virtual resource quota management method as described in any one of claims 1 to 7.
10. A readable storage medium for storing a program, characterized in that, When the program is executed by the processor, it implements the steps in the virtual resource quota management method as described in any one of claims 1 to 7.