Method, device, electronic device and storage medium for storing difference currency

By storing the difference currency in the tail tree node of the root node, the problem of the high resource consumption of the difference currency in the prior art is solved, and a more efficient change operation is achieved.

CN113553475BActive Publication Date: 2025-08-19TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110778466.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-09
Publication Date
2025-08-19
Estimated Expiration
2040-03-09

AI Technical Summary

Technical Problem

In the prior art, the difference currency obtained for each change is needed to be re-added to the binary sorting tree, which consumes more resources.

Method used

Add a tail tree node to the root node, store the difference currency obtained from the change operation on the tail tree node, avoid restoring the difference currency into the ordered binary tree according to preset rules, and use the feature of the depth between the tail tree node and the root node not exceeding 1 to reduce resource consumption.

Benefits of technology

By storing the difference currency in the tail tree node of the root node, resource consumption and positioning time are reduced, and the efficiency of change operation is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113553475B_ABST
    Figure CN113553475B_ABST
Patent Text Reader

Abstract

The present application relates to the field of electronic resource technology and discloses a method, apparatus, electronic device, and storage medium for storing difference resources. The difference resource storage method includes: receiving a payment request for an electronic resource of a preset denomination; in response to the payment request, traversing an ordered binary tree comprising at least two nodes, comparing the denomination of the electronic resource at the root node of the ordered binary tree with the preset denomination, and determining, based on the comparison result, a target electronic resource and its matching node whose denomination matches the electronic resource of the preset denomination, wherein any of the nodes stores an electronic resource of the corresponding denomination; determining a difference resource based on the preset denomination and the target electronic resource, and storing the difference resource in a tail subtree node of the root node of the matching node. The solution provided by the present application can reduce resource consumption for storing difference resources.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the Chinese patent application filed with the China Patent Office on March 9, 2020, with application number 202010158748.X, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of electronic currency technology. Specifically, the present application relates to a storage method, device, electronic device and storage medium for differential currency. Background Art

[0003] In the prior art, the difference currency obtained each time the change is made needs to be re-added to the binary sort tree, which consumes a lot of resources. Summary of the Invention

[0004] The purpose of this application is to solve at least one of the above technical deficiencies, and the following technical solutions are proposed:

[0005] In a first aspect, a method for storing a difference currency is provided, comprising:

[0006] receiving a payment request for electronic money of a predetermined denomination;

[0007] In response to the payment request, traversing an ordered binary tree comprising at least two nodes, comparing the electronic currency denomination of a root node of the ordered binary tree with a preset denomination, and determining, based on the comparison result, a target electronic currency having a denomination matching the electronic currency of the preset denomination and its matching node, wherein any of the nodes stores electronic currency of the corresponding denomination;

[0008] The difference currency is determined according to the preset denomination and the target electronic currency, and the difference currency is stored in a tail subtree node of the root node of the matching node.

[0009] In an optional embodiment of the first aspect, after the step of comparing the electronic currency denomination of the root node of the ordered binary tree with the preset denomination, the step further includes:

[0010] If the preset denomination is not less than the electronic currency denomination of the root node, obtain the electronic currency denomination stored in the right subtree from the root node downwards;

[0011] If the preset denomination is smaller than the electronic currency denomination of the root node, the electronic currency denominations stored on the left subtree are obtained sequentially from the root node downwards.

[0012] In an optional embodiment of the first aspect, the step of traversing an ordered binary tree comprising at least two nodes, comparing the electronic currency denomination of the root node of the ordered binary tree with a preset denomination, and determining, based on the comparison result, a target electronic currency whose denomination matches the electronic currency of the preset denomination and its matching node includes:

[0013] Call the pre-built ordered binary tree;

[0014] Obtaining the electronic currency face value of each node on the left subtree or the right subtree of the ordered binary tree in sequence according to the preset face value;

[0015] Obtain the difference between the electronic currency face value of each node and the preset face value. If there is a difference that meets the preset conditions, determine the electronic currency corresponding to the difference that meets the preset conditions as the target electronic currency, and determine the storage node of the target electronic currency as the matching node. If there is no difference that meets the preset conditions, re-obtain the electronic currency face value of each node on the left subtree or the right subtree of the ordered binary tree according to the preset face value, and obtain the difference between the electronic currency face value of each node and the preset face value, until the target electronic currency and the matching node are determined.

[0016] In an optional embodiment of the first aspect, the preset condition includes: the difference between the face value of the electronic currency and the preset face value is minimum.

[0017] In an optional embodiment of the first aspect, when it is detected that a difference currency is stored in the tail subtree node corresponding to the matching node, the step of determining the difference currency based on the preset denomination and the target electronic currency includes:

[0018] Updating the electronic currency denomination of the matching node based on the difference currency stored in the tail subtree node;

[0019] The difference in currency between the updated electronic currency face value and the preset face value is obtained.

[0020] In an optional embodiment of the first aspect, when the target electronic currency is an electronic currency combination, the step of determining the difference currency based on the preset denomination and the target electronic currency includes:

[0021] Counting the face value of each electronic currency in the electronic currency combination to obtain the corresponding total value of the electronic currency;

[0022] The electronic currency whose total value exceeds the preset face value is determined to be the difference currency.

[0023] In an optional embodiment of the first aspect, after the step of determining, based on the comparison result, a target electronic currency with a denomination that matches the electronic currency with the preset denomination and its matching node, the step further includes:

[0024] Performing a payment operation using the electronic currency face value updated by the matching node as a response value of the payment request;

[0025] After the payment operation is completed, the difference currency corresponding to the electronic currency of the preset denomination and the target electronic currency are placed in an unusable state;

[0026] Adjust the link that has the target electronic currency as a child node of the root node.

[0027] In an optional embodiment of the first aspect, after the step of storing the difference currency in the tail subtree node of the root node of the matching node, the step further includes:

[0028] If it is detected that the difference currency has been stored in the tail subtree node, the difference currency that has been stored and the difference currency to be stored at that time are merged, and the merged difference currency is stored in the tail subtree node.

[0029] In a second aspect, a storage device for difference currency is provided, comprising:

[0030] a payment request receiving module, configured to receive a payment request for electronic currency of a preset denomination;

[0031] a matching node determination module configured to, in response to the payment request, traverse an ordered binary tree comprising at least two nodes, compare the electronic currency denomination of a root node of the ordered binary tree with a preset denomination, and determine, based on the comparison result, a target electronic currency having a denomination that matches the electronic currency of the preset denomination and its matching node, wherein any of the nodes stores electronic currency of the corresponding denomination;

[0032] A storage module is used to determine a difference currency according to the preset face value and the target electronic currency, and store the difference currency in a tail subtree node of the root node of the matching node.

[0033] In an optional embodiment of the second aspect, the storage device for the difference currency further includes:

[0034] A comparison module, configured to compare the electronic currency denomination of the root node of the ordered binary tree with a preset denomination;

[0035] A first acquisition module is configured to acquire the electronic currency denominations stored in the right subtree from the root node downwards if the preset denomination is not less than the electronic currency denomination of the root node;

[0036] The second acquisition module is used to acquire the electronic currency face values stored on the left subtree from the root node downwards if the preset face value is less than the electronic currency face value of the root node.

[0037] In an optional embodiment of the second aspect, determining the matching node module further includes:

[0038] A calling unit, used to call a pre-built ordered binary tree;

[0039] A traversal unit, configured to sequentially obtain the electronic currency denomination of each node on the left subtree or the right subtree of the ordered binary tree according to a preset denomination;

[0040] Determine a target electronic currency unit, which is used to obtain the difference between the electronic currency face value of each node and the preset face value. If there is a difference that meets the preset conditions, the electronic currency corresponding to the difference that meets the preset conditions is determined as the target electronic currency, and the storage node of the target electronic currency is determined as the matching node. If there is no difference that meets the preset conditions, the electronic currency face value of each node on the left subtree or the right subtree of the ordered binary tree is obtained in sequence according to the preset face value, and the difference between the electronic currency face value of each node and the preset face value is obtained, until the target electronic currency and the matching node are determined.

[0041] In an optional embodiment of the second aspect, determining the preset condition in the matching node module includes: the difference between the face value of the electronic currency and the preset face value is the smallest.

[0042] In an optional embodiment of the second aspect, when it is detected that the tail subtree node corresponding to the matching node stores the difference currency, the storage module further includes:

[0043] a denomination updating unit, configured to update the electronic currency denomination of the matching node based on the difference currency stored in the tail subtree node;

[0044] The difference currency obtaining unit is used to obtain the difference currency between the updated electronic currency face value and the preset face value.

[0045] In an optional embodiment of the second aspect, the storage module includes:

[0046] an electronic currency total value counting unit, configured to count the face value of each electronic currency in the electronic currency combination to obtain the corresponding electronic currency total value;

[0047] The difference currency determination unit is used to determine that the electronic currency whose total value exceeds the preset face value is the difference currency.

[0048] In an optional embodiment of the second aspect, the storage device for the difference currency further includes:

[0049] a payment operation module, configured to execute a payment operation using the electronic currency face value updated by the matching node as a response value of the payment request;

[0050] A setting module, configured to place the difference currency corresponding to the electronic currency of the preset denomination and the target electronic currency in an unusable state after the payment operation is completed;

[0051] The link adjustment module is used to adjust the link of the child node of the root node with the target electronic currency as the root node.

[0052] In an optional embodiment of the second aspect, the storage device for the difference currency further includes:

[0053] The merging module is used to detect that the difference currency has been stored in the tail subtree node, merge the stored difference currency and the difference currency to be stored at the time, and store the merged difference currency in the tail subtree node.

[0054] In a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for storing the difference currency shown in the first aspect of this application is implemented.

[0055] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for storing the difference currency shown in the first aspect of the present application is implemented.

[0056] The beneficial effects of the technical solution provided by this application are:

[0057] The storage method of difference currency provided by the present application stores the difference currency obtained from the change operation on the tail subtree node by adding a tail subtree node on the root node, thereby avoiding the resource consumption caused by re-storing the difference currency into an ordered binary tree according to preset rules; moreover, since the depth of the tail subtree node and its corresponding root node does not exceed 1, the time spent on locating the tail subtree node is relatively short, which greatly reduces the resource consumption of re-adding the difference currency to the ordered binary tree.

[0058] Additional aspects and advantages of the present application will be given in part in the following description, which will become apparent from the following description, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0060] Figure 1 This is an application scenario diagram of a method for storing difference currency provided in an embodiment of the present application;

[0061] Figure 2 A flowchart of a method for storing difference currency provided in an embodiment of the present application;

[0062] Figure 3A flowchart of determining a target electronic currency and a matching node thereof for matching a face value of an electronic currency with a preset face value provided in an example of the present application;

[0063] Figure 4 A schematic diagram of the structure of a storage device for difference currency provided in an embodiment of the present application;

[0064] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0065] The following describes embodiments of the present application in detail. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application and are not to be construed as limiting the present application.

[0066] It will be understood by those skilled in the art that, unless expressly stated otherwise, the singular forms "a", "an", "said" and "the" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of this application refers to the presence of features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, "connected" or "coupled" as used herein may include wireless connections or wireless couplings. The term "and / or" used herein includes all or any units and all combinations of one or more associated listed items.

[0067] Those skilled in the art will understand that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art in the art to which this invention belongs. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with their meanings in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless specifically defined as herein.

[0068] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0069] The storage method, device, electronic device and storage medium for difference currency provided in this application are intended to solve the above technical problems in the prior art.

[0070] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0071] The storage solution for the difference currency provided by this application can be applied to the account system of electronic currency, which can be used to pay, receive and store electronic currency. The account system can be stored on the client or server side and can be applied to Figure 1 The application scenario shown includes the requester's account system and the payer's account system. The interaction between the two systems can be carried out through the server. Preferably, the solution provided in this application is applied to the payer's account system. Specifically, the payer's account system receives a payment request for a preset amount of electronic currency sent by the requester's account system and forwarded by the server. In response to the payment request, the payer's account system performs an electronic currency matching operation within the system, obtains electronic currency whose face value matches the preset face value, determines the electronic currency whose face value matches the preset face value as the target electronic currency, and returns the target electronic currency to the requester. If the face value of the target electronic currency stored in the matching node is greater than the preset amount, the difference currency returned by the change operation is determined, the electronic currency of the preset face value is returned to the requester, and the difference currency is stored in the tail subtree node of the root node of the matching node to complete the transaction process.

[0072] A possible implementation method is provided in the embodiment of the present application, such as Figure 2 As shown, a storage method for difference currency is provided, which can be applied to Figure 1 The payer's account system shown may include the following steps:

[0073] Step S201: receiving a payment request for electronic currency of a preset denomination.

[0074] In a transaction scenario, one party sends a payment request for electronic currency with a preset denomination. The other party receives the payment request and, in response to the payment request, performs a payment operation to complete the transaction. The solution provided in this application can be implemented in an account system, which serves as the payer's account system. The payer's account system receives the payment request for electronic currency with a preset denomination sent by the requester. In the transaction scenario, the electronic currency with a preset denomination is the transaction amount.

[0075] Step S202: In response to the payment request, traverse an ordered binary tree comprising at least two nodes, compare the electronic currency face value of the root node of the ordered binary tree with a preset face value, and determine a target electronic currency and its matching node whose face value matches the electronic currency of the preset face value based on the comparison result, wherein any of the nodes stores electronic currency of the corresponding face value.

[0076] Before traversing the binary tree, a pre-built ordered binary tree in the account system is called. The binary tree includes a root node and child nodes. When there are more than two nodes in the binary tree, a root node includes a left subtree node and a right subtree node. Each node corresponds to electronic currency with a rated face value. The nodes on the binary tree used to store electronic currency are arranged according to a preset sorting rule. For example, if the left subtree node under the root node is not empty, the electronic currency with a face value less than the face value of the electronic currency of the root node is stored in the left subtree node. If the right subtree is not empty, the electronic currency with a face value not less than the face value of the electronic currency of the root node is stored in the right subtree node. Moreover, the left subtree and the right subtree can be binary trees respectively, that is, the left subtree node and the right subtree node also include their child nodes. New electronic currency is added to the binary tree according to the above preset sorting rule to form an ordered binary tree. The arrangement of the nodes on the binary tree can also be arranged according to other sorting rules to form an ordered binary tree.

[0077] Furthermore, in order to quickly obtain the electronic currency stored in each node, the storage address corresponding to each electronic currency is obtained, so as to obtain the electronic currency of the corresponding face value from the storage address, and the electronic currency face value and storage address of the left and right subtree nodes are stored in the storage record of its root node. According to the storage record of the root node, the electronic currency face value and storage address of its left and right subtree nodes can be determined.

[0078] Forming an ordered binary tree in the above manner is beneficial to improving the efficiency of determining matching nodes. In order to further improve the efficiency of determining matching nodes, the storage records of electronic currency can also be dynamically adjusted, such as adjusting the electronic currency face value of the root node, so that the ordered binary tree forms a balanced binary tree, reducing the average search length of the binary tree.

[0079] In response to a payment request sent by a requesting party, each node in an ordered binary tree is traversed, each node storing electronic currency of a corresponding denomination, and the electronic currency stored in the ordered binary tree with a denomination matching the preset denomination is determined as the target electronic currency, with the corresponding node being the matching node. For example, an ordered binary tree stores the following nodes: the root node stores electronic currency with a denomination of 10, its left subtree node stores electronic currency with a denomination of 5, and its right subtree node stores electronic currency with a denomination of 20. Assuming the preset denomination is 15, then, in a transaction scenario, the denomination of the target electronic currency must be no less than the preset denomination to achieve the transaction purpose. Therefore, in this ordered binary tree, the electronic currency that matches the preset denomination is the electronic currency with a denomination of 20, and its matching node is the right subtree node.

[0080] In an embodiment of the present application, an ordered binary tree is pre-constructed, and electronic currencies of various denominations are stored in the ordered binary tree according to the denominations of the electronic currencies, so as to facilitate the subsequent rapid and accurate positioning of the target electronic currency according to the denomination of the electronic currency, improve the efficiency of determining the matching nodes, and shorten the response time of the payment request.

[0081] Step S203: determining a difference currency according to the preset denomination and the target electronic currency, and storing the difference currency in a tail subtree node of the root node of the matching node.

[0082] After determining the target electronic currency and its matching node, the difference currency is determined based on the preset face value and the target electronic currency. If the face value of the target electronic currency is not equal to the preset face value, that is, the face value of the target electronic currency is greater than the preset face value, there is a change problem, and the target electronic currency needs to be replaced with two new electronic currencies, one with a face value equal to the preset face value, which is used to return to the requester as the response value of the payment request; the other with a face value equal to the difference between the two, that is, the difference between the target electronic currency and the preset face value, which is the remaining part after payment and still belongs to the payer. This process is called the change process.

[0083] In combination with the above example, assuming that the preset face value is 15 and the target electronic currency is 20, then the difference currency is (20-15=5), and the difference currency is stored in the tail subtree node of the root node of the matching node, where the tail subtree node is a child node without child nodes on the binary tree, that is, on the basis of the ordinary binary tree, a tail subtree node is added, and the tail subtree node and the left subtree node and the right subtree node are all children of the root node. The difference between the tail subtree node and the left subtree node / right subtree node is that the left subtree node and the right subtree node can also serve as the root nodes of other child nodes, continuing to extend the depth of the binary tree, while the tail subtree node has no child nodes, that is, the tail subtree node can no longer serve as the root node of other child nodes.

[0084] Furthermore, in order to improve the efficiency of obtaining electronic currency on child nodes, the electronic currency face value and storage address on the left and right subtree nodes and the tail subtree node are stored in the storage record of their root node.

[0085] The storage method of the difference currency provided by the present application stores the difference currency in the tail subtree node, avoiding the resource consumption caused by re-storing the difference currency in the binary tree according to the preset rules. Moreover, since the tail subtree node is a child node of the root node, the depth of the tail subtree node and its corresponding root node does not exceed 1. Therefore, the time spent on locating the tail subtree node is relatively short, which greatly reduces the resource consumption of re-adding the difference currency to the binary tree. Moreover, storing the difference currency in the tail subtree node only increases the limited storage space, but does not affect the efficiency of determining the matching node.

[0086] In order to make the difference currency storage solution and its technical effects provided by the present disclosure clearer, its specific implementation plans are described in detail with multiple examples.

[0087] An embodiment of the present application provides a possible implementation method, which includes, before the step of determining the target electronic currency and its matching node in step S202, the following steps:

[0088] A1. Comparing the electronic currency denomination of the root node of the ordered binary tree with a preset denomination;

[0089] A2. If the preset denomination is not less than the electronic currency denomination of the root node, obtain the electronic currency denominations stored in the right subtree from the root node downwards;

[0090] A3. If the preset face value is less than the electronic currency face value of the root node, obtain the electronic currency face value stored in the left subtree from the root node downwards.

[0091] Since the binary tree provided in the present application is an ordered binary tree, the electronic currency face value of the root node of the ordered binary tree is compared with the preset face value, and the node matching the preset face value is determined based on the comparison result. Specifically, if the preset face value is less than the electronic currency face value of the root node of the binary tree, a matching node is searched in the left subtree. If the preset face value is not less than the electronic currency face value of the root node of the binary tree, a matching node is searched in the right subtree. In this way, the electronic currency face values stored on the left subtree or the right subtree are obtained in sequence from the root node downward. This scheme can reduce the node search time to 1 / n, where n is the number of nodes on the binary tree, thereby improving the search efficiency of matching nodes.

[0092] The embodiment of the present application also provides a possible implementation method. The step of traversing an ordered binary tree including at least two nodes in step S202, comparing the electronic currency face value of the root node of the ordered binary tree with a preset face value, and determining the target electronic currency and its matching node that matches the electronic currency with the preset face value according to the comparison result can be implemented as follows. The flowchart is as follows: Figure 3 As shown, it includes the following sub-steps:

[0093] S510, calling a pre-built ordered binary tree;

[0094] S520, sequentially obtaining the electronic currency face value of each node on the left subtree or the right subtree of the ordered binary tree according to the preset face value;

[0095] S530, obtaining the difference between the electronic currency face value of each node and the preset face value, and determining the electronic currency corresponding to the difference that meets the preset conditions as the target electronic currency, and determining the storage node of the target electronic currency as the matching node.

[0096] When there are more than two nodes on an ordered binary tree, each node corresponds to electronic currency with a rated face value. The nodes on the binary tree used to store electronic currency are sorted according to preset sorting rules. For example, if the left subtree node under the root node is not empty, the value stored on the left subtree node is less than the value stored on its root node; if the right subtree is not empty, the value stored on the right subtree is not less than its root node. Moreover, the left subtree and the right subtree can be binary trees respectively, that is, the left subtree node and the right subtree node also include their child nodes, which serve as the root nodes of other child nodes. Of course, the arrangement of the nodes on the binary tree can also be arranged according to other sorting rules to form an ordered binary tree according to the sorting rules.

[0097] Step S530 includes the following sub-steps:

[0098] S531, determining whether the difference meets a preset condition;

[0099] S532: If yes, determine the electronic currency corresponding to the difference that meets the preset conditions as the target electronic currency, and determine the storage node of the target electronic currency as the matching node;

[0100] If not, step S520 is executed in a loop, and the electronic currency face value of each node on the ordered binary tree is traversed according to the preset face value until the target electronic currency and the matching node are determined.

[0101] Call the ordered binary tree constructed in the above manner, and sequentially obtain the electronic currency face values of the left subtree or right subtree nodes from the root node downward. Then, obtain the difference between the electronic currency face value of the node and the preset face value, and determine the electronic currency for which the difference between the electronic currency face value and the preset face value meets the preset condition. Then, stop traversing downward. If no electronic currency meeting the preset condition is found, continue to obtain the electronic currency face values on the subtree where the preset face value is located. The preset condition can be set as the difference between the electronic currency face value and the preset face value being the smallest, that is, the target electronic currency can be greater than or less than the preset face value, and the electronic currency face value is the closest to the preset face value.

[0102] After determining the subtree where the matching node is located, sequentially and alternately obtain the electronic currency face values of the nodes and judge the differences from the root node downward. Since the nodes on the ordered binary tree are arranged in an orderly manner according to the face values, it is not necessary to obtain the electronic currency face values of all the nodes on the subtree where the matching node is located, that is, the target electronic currency and the corresponding matching node can be determined, which is conducive to quickly determining the target electronic currency and the matching node.

[0103] In a feasible embodiment, the process of determining the target electronic currency and the matching node is as follows:

[0104] Suppose the preset face value is M, and the electronic currency with face value A is obtained by dividing the preset face value M by 2. Traverse the ordered binary tree to find the first node N(0) whose face value is not less than A. Compare the face value of N(0) with the preset face value M, including the following situations:

[0105] If N(0) >= M, then take N(0) as the target electronic currency, and the node where N(0) is located is the matching node.

[0106] If N(0) < M, that is, in the case of A < N(0) < M, the process of determining the target electronic currency and the matching node is as follows:

[0107] When N(0) is a child node, judge whether N(0) + N(-1) is not less than the preset face value M, where N(-1) is the root node of N(0). If it is greater, then N(0) + N(-1) is used as the target electronic currency combination, and the corresponding nodes are the matching node combination;

[0108] If it is less, detect whether N(0) is a left subtree node. If N(0) is a left subtree node and N(2) is the right subtree node of the same root node, sequentially judge whether N(2) + N(-1) and N(0) + N(-1) + N(2) are greater than M. If so, the corresponding combination is the matching node combination. If not, continue to trace back upward; if N(0) is a right subtree node and N(1) is the left subtree node of the same root node, judge whether N(0) + N(-1) + N(1) is greater than M. If so, the corresponding combination is the matching node combination. If not, continue to trace back upward.

[0109] According to the above matching rules, the target electronic currency and the corresponding matching node are obtained. The target electronic currency may be a target electronic currency combination, and the matching node may be a matching node combination.

[0110] According to the solution provided in the embodiment of the present application, matching nodes that meet the preset conditions are determined on an ordered binary tree. Since the nodes on the ordered binary tree are arranged in order according to the face value of the electronic currency, the target electronic currency that meets the conditions on the binary tree can be quickly determined based on the preset face value and the face value of the electronic currency in the binary tree, thereby improving the efficiency of determining the matching nodes.

[0111] The embodiment of the present application utilizes the minimum difference between the face value of the electronic currency and the preset face value to achieve the uniqueness of the target electronic currency, avoiding the use of ultra-large target electronic currency for small payment operations, which is conducive to reducing change operations and effectively reducing operational complexity.

[0112] On this basis, when it is detected that the difference currency is stored in the tail subtree node corresponding to the matching node, the step of determining the difference currency according to the preset denomination and the target electronic currency in step S203 can be implemented as follows, including:

[0113] B1. updating the electronic currency denomination of the matching node based on the difference currency;

[0114] B2. Obtain the difference in currency between the updated electronic currency face value and the preset face value.

[0115] Updating the electronic currency face value of the matching node based on the difference currency can be done in the following way: obtaining the electronic currency face value of the matching node and the difference currency stored in the tail subtree node; updating the electronic currency face value of the matching node based on the electronic currency face value and the difference currency.

[0116] When both the left and right subtree nodes are not empty, the child nodes include the left subtree node and the right subtree node, the tail subtree of the root node stores the difference currency, and the difference currency stored on the tail subtree node is used to update the electronic currency face value on the matching node.

[0117] For example, if the face value of the electronic currency stored on the root node A is 10, the face value of the electronic currency stored on the left subtree node B is 5, the face value of the electronic currency stored on the right subtree node is 20, and the face value of the electronic currency stored on the tail subtree node is 5.

[0118] If the root node is a matching node, (10 + 5) is used as the updated electronic currency face value of the root node. If the root node can be a child node of a binary tree, that is, there is a parent root node above the root node, and this type of root node is a matching node, the root node is treated as a child node according to the above method, and the electronic currency face value of the child node is updated.

[0119] According to the solution provided in the embodiment of the present application, in the case where the difference currency is stored in the tail subtree node, the electronic currency face value of the matching node is updated, and payment operations or adjustments to the matching node are performed based on the updated electronic currency face value of the matching node, which is conducive to improving the accuracy of obtaining the matching node.

[0120] The updated electronic currency face value of the matching node is obtained in the above manner, and the difference currency is determined based on the updated electronic currency face value and the preset face value. Assuming the preset face value is 17, the value stored on the tail subtree node is 5, and the electronic currency face value of each node on the binary tree is as follows: the electronic currency face value on the root node is 10, and the root node can be used as a child node of other root nodes. The electronic currency face value on the left subtree node is 5, and the electronic currency face value on the right subtree node is 13. After the update, the electronic currency face value of the left subtree node is 10, and the electronic currency face value on the right subtree node is 18. According to the above preset condition, that is, the updated electronic currency face value is not less than the preset face value, the right subtree node is a matching node, and the electronic currency face value of the matching node is 18. The difference currency is determined using the updated electronic currency face value of the matching node and the preset face value. Specifically, the preset face value is subtracted from the updated electronic currency face value of the matching node to obtain the difference currency. In the above example, the difference currency is (18-17=1).

[0121] When the target electronic currency is an electronic currency combination, the step of determining the difference currency based on the preset denomination and the target electronic currency includes:

[0122] C1. Counting the face value of each electronic currency in the electronic currency combination to obtain the corresponding total value of the electronic currency;

[0123] C2. Determine that the electronic currency whose total value exceeds the preset face value is the difference currency.

[0124] An example is as follows: the electronic currency combination includes denominations of 10, 15, and 20, and the total value of the electronic currency is (10+15+20). Based on the total value of the electronic currency being 45, the difference between the total value of the electronic currency and the preset denomination is calculated as the difference currency to accurately obtain the difference currency.

[0125] The present application also provides a possible implementation method in which, when a tail subtree node exists on a related node of a matching node, the target electronic currency and the matching node are adjusted based on the electronic currency stored on the matching node, the related node, and the tail subtree node. The process is as follows:

[0126] The electronic currency face value of the matching node is updated based on the difference currency stored in the tail subtree. If the matching node N(y0) has a left subtree node N(y1), and the difference currency is stored in the tail subtree corresponding to N(y1), and the sum of the face values of N(y1) and the difference currency stored in the tail subtree is closer to the preset face value, then the matching node is adjusted to N(y1), and the target electronic currency is the sum of the face values of N(y1) and the difference currency stored in the tail subtree, so as to reduce the face value of the difference currency obtained in the change operation.

[0127] This embodiment of the present application further provides a possible implementation method, which includes, after the step of determining the target electronic currency and its matching node based on the comparison result in step S202, further comprising:

[0128] D1. Performing a payment operation using the electronic currency face value of the matching node as the response value of the payment request;

[0129] D2. After the payment operation is completed, the target electronic currency corresponding to the electronic currency of the preset denomination is placed in an unusable state;

[0130] D3. Adjust the link with the target electronic currency as a child node of the root node.

[0131] After determining the matching node, the electronic currency stored on the matching node is used as the response value of the payment request to perform the payment operation. In the payer's account system, the target electronic currency is replaced into two parts. One part of the electronic currency has a face value equal to the preset face value. The electronic currency with the preset face value is added to the requester's account system. The other part of the electronic currency is the difference currency and is stored in the payer's tail subtree node.

[0132] After the payment operation is completed, since the target electronic currency has been divided into two parts in the payer's account system, the electronic currency with a preset face value has been added as a response value to the binary tree constructed by the requester. Therefore, in the payer's account system, the target electronic currency is placed in an unavailable state to ensure the accurate implementation of the payment operation.

[0133] When the tail subtree node of any of the root nodes stores the difference currency, the above D1 and D2 can be performed in the following ways, including:

[0134] D11. Obtain the updated electronic currency face value of the matching node as the response value of the payment request and perform the payment operation;

[0135] D22. After the payment operation is completed, the difference currency corresponding to the electronic currency of the preset denomination and the target electronic currency are placed in an unusable state.

[0136] The solution provided in the embodiment of the present application targets the case where difference currency is stored in the tail subtree node. The electronic currency face value of the matching node is updated according to the difference currency. During the payment process, the difference currency and the target electronic currency are treated as a whole to perform the payment operation. Therefore, after the payment is completed, both the difference currency and the target electronic currency are placed in an unavailable state to avoid repeated calls to the difference currency and the target electronic currency, thereby ensuring accurate completion of the payment operation.

[0137] The adjustment in step D3 to link the target electronic currency as a child node of the root node can be implemented as follows:

[0138] If node N(0) is a matching node, when N(0) is used as the return value to perform the payment operation, N(0) is placed in an unavailable state, which is equivalent to removing N(0) from the binary tree. At this time, it is necessary to adjust the links of the nodes on the ordered binary tree, that is, the node pointing, especially the link with the target electronic currency as the child node of the root node. If the left subtree of N(0) is not empty and its left subtree node is N(1), then adjust the root node of N(0) to point to N(1). If the right subtree node of N(0) is not empty and its right subtree node is N(2), then adjust N(1) as the root node of N(2) to ensure the ordered links of the ordered binary tree, which is conducive to the normal progress of the next matching operation.

[0139] After the step of storing the difference currency in the tail subtree node of the root node of the matching node in step S203, the method further includes:

[0140] If it is detected that the difference currency has already been stored in the tail subtree node, the difference currency that has already been stored and the difference currency to be stored at that time are merged.

[0141] The solution provided by the embodiment of the present application is that when the difference currency is already stored in the tail subtree node to be stored, and the difference currency generated by the current payment operation still uses the tail subtree node as a storage node, the difference currency that has been stored and the difference currency to be stored at that time are merged and stored together in the tail subtree node, so as to ensure that a node has at most one tail subtree node, thereby reducing the number of tail subtree nodes.

[0142] The present application also provides a possible implementation method, such as Figure 4 As shown, a storage device 60 for difference currency is provided, comprising: a payment request receiving module 601, a matching node determination module 602, and a storage module 603, specifically as follows:

[0143] a payment request receiving module 601 for receiving a payment request for electronic currency of a preset denomination;

[0144] a matching node determination module 602 configured to, in response to the payment request, traverse an ordered binary tree comprising at least two nodes, compare the electronic currency denomination of the root node of the ordered binary tree with a preset denomination, and determine, based on the comparison result, a target electronic currency having a denomination that matches the electronic currency of the preset denomination and its matching node, wherein any of the nodes stores electronic currency of the corresponding denomination;

[0145] The storage module 603 is configured to determine a difference currency according to the preset denomination and the target electronic currency, and store the difference currency in a tail subtree node of the root node of the matching node.

[0146] The storage device for difference currency provided by the present application stores the difference currency in the tail subtree node, avoiding the resource consumption caused by re-storing the difference currency in the binary tree according to preset rules. Moreover, since the tail subtree node is a child node of the root node, the depth of the tail subtree node and its corresponding root node does not exceed 1. Therefore, the time spent on locating the tail subtree node and storing the difference currency in the tail subtree node is relatively short, which greatly reduces the resource consumption of re-adding the difference currency to the binary tree. Moreover, storing the difference currency in the tail subtree node only increases the limited storage space, but does not affect the efficiency of determining the matching node.

[0147] In an optional embodiment provided by the embodiment of the present application, the storage device for the difference currency further includes:

[0148] A comparison module, configured to compare the electronic currency denomination of the root node of the ordered binary tree with a preset denomination;

[0149] A first acquisition module is configured to acquire the electronic currency denominations stored in the right subtree from the root node downwards if the preset denomination is not less than the electronic currency denomination of the root node;

[0150] The second acquisition module is used to acquire the electronic currency face values stored on the left subtree from the root node downwards if the preset face value is less than the electronic currency face value of the root node.

[0151] In an optional embodiment of the second aspect, the storage device for the difference currency further includes:

[0152] A comparison module, configured to compare the electronic currency denomination of the root node of the ordered binary tree with a preset denomination;

[0153] A first acquisition module is configured to acquire the electronic currency denominations stored in the right subtree from the root node downwards if the preset denomination is not less than the electronic currency denomination of the root node;

[0154] The second acquisition module is used to acquire the electronic currency face values stored on the left subtree from the root node downwards if the preset face value is less than the electronic currency face value of the root node.

[0155] In an optional embodiment of the second aspect, determining the matching node module further includes:

[0156] A calling unit, used to call a pre-built ordered binary tree;

[0157] A traversal unit, configured to sequentially obtain the electronic currency denomination of each node on the left subtree or the right subtree of the ordered binary tree according to a preset denomination;

[0158] Determine a target electronic currency unit, which is used to obtain the difference between the electronic currency face value of each node and the preset face value. If there is a difference that meets the preset conditions, the electronic currency corresponding to the difference that meets the preset conditions is determined as the target electronic currency, and the storage node of the target electronic currency is determined as the matching node. If there is no difference that meets the preset conditions, the electronic currency face value of each node on the left subtree or the right subtree of the ordered binary tree is obtained in sequence according to the preset face value, and the difference between the electronic currency face value of each node and the preset face value is obtained, until the target electronic currency and the matching node are determined.

[0159] In an optional embodiment of the second aspect, determining the preset condition in the matching node module includes: the difference between the face value of the electronic currency and the preset face value is the smallest.

[0160] In an optional embodiment of the second aspect, when it is detected that the tail subtree node corresponding to the matching node stores the difference currency, the storage module further includes:

[0161] a denomination updating unit, configured to update the electronic currency denomination of the matching node based on the difference currency stored in the tail subtree node;

[0162] The difference currency obtaining unit is used to obtain the difference currency between the updated electronic currency face value and the preset face value.

[0163] In an optional embodiment of the second aspect, the storage module includes:

[0164] an electronic currency total value counting unit, configured to count the face value of each electronic currency in the electronic currency combination to obtain the corresponding electronic currency total value;

[0165] The difference currency determination unit is used to determine that the electronic currency whose total value exceeds the preset face value is the difference currency.

[0166] In an optional embodiment of the second aspect, the storage device for the difference currency further includes:

[0167] a payment operation module, configured to execute a payment operation using the electronic currency face value updated by the matching node as a response value of the payment request;

[0168] A setting module, configured to place the difference currency corresponding to the electronic currency of the preset denomination and the target electronic currency in an unusable state after the payment operation is completed;

[0169] The link adjustment module is used to adjust the link of the child node of the root node with the target electronic currency as the root node.

[0170] In an optional embodiment of the second aspect, the storage device for the difference currency further includes:

[0171] The merging module is used to detect that the difference currency has been stored in the tail subtree node, merge the stored difference currency and the difference currency to be stored at the time, and store the merged difference currency in the tail subtree node.

[0172] The storage device for difference currency of the embodiment of the present disclosure can execute a storage method for difference currency provided by the embodiment of the present disclosure, and the implementation principle is similar. The actions performed by each module in the storage device for difference currency in each embodiment of the present disclosure correspond to the steps in the storage method for difference currency in each embodiment of the present disclosure. For the detailed functional description of each module in the storage device for difference currency, please refer to the description in the corresponding storage method for difference currency shown in the previous text, which will not be repeated here.

[0173] Based on the same principles as the method described in the embodiments of the present disclosure, an electronic device is also provided in the embodiments of the present disclosure. The electronic device may include, but is not limited to: a processor and a memory; the memory is configured to store computer operating instructions; and the processor is configured to execute the method for storing the difference currency described in the embodiments by invoking the computer operating instructions. Compared to the prior art, the method for storing the difference currency in the present application can add a tail subtree node to the root node, storing the difference obtained from the change operation in the tail subtree node, thereby avoiding the resource consumption caused by re-storing the difference currency in a binary tree according to preset rules.

[0174] In an alternative embodiment, an electronic device is provided, such as Figure 5 As shown, Figure 5 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004. It should be noted that in actual applications, the number of transceivers 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.

[0175] Processor 4001 can be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 4001 can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0176] Bus 4002 may include a path for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. Bus 4002 may be divided into an address bus, a data bus, a control bus, and the like.

[0177] The memory 4003 may be a ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, a RAM (Random Access Memory) or other type of dynamic storage device that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.

[0178] The memory 4003 is used to store application code for executing the solution of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the application code stored in the memory 4003 to implement the content shown in the above method embodiment.

[0179] Among them, electronic devices include but are not limited to: mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.

[0180] The present invention provides a computer-readable storage medium having a computer program stored thereon. When executed on a computer, the computer is enabled to execute the corresponding contents of the aforementioned method embodiments. Compared to the prior art, the present invention provides a method for storing difference currency by adding a tail subtree node to the root node, storing the difference resulting from the change operation in the tail subtree node, and thus avoiding the resource consumption associated with re-storing the difference currency in a binary tree according to preset rules.

[0181] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0182] It should be noted that the computer-readable medium described above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. Computer-readable storage media may include, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or components, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such a propagated data signal may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wire, optical cable, RF (radio frequency), or any suitable combination thereof.

[0183] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0184] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.

[0185] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0186] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0187] The modules described in the embodiments of the present disclosure may be implemented in software or hardware. In some cases, the name of a module does not necessarily limit the module itself. For example, a receiving module may also be described as a "module for receiving payment requests."

[0188] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the present disclosure is not limited to technical solutions formed by specific combinations of the aforementioned technical features. It also encompasses other technical solutions formed by any combination of the aforementioned technical features or their equivalents, without departing from the scope of the above disclosure. For example, a technical solution formed by replacing the aforementioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

Claims

1. A method for storing difference currency, characterized in that: include: receiving a payment request for electronic money of a predetermined denomination; In response to the payment request, traversing an ordered binary tree comprising at least two nodes, comparing the electronic currency denomination of a root node of the ordered binary tree with a preset denomination, and determining, based on the comparison result, a target electronic currency having a denomination matching the electronic currency of the preset denomination and its matching node, wherein any of the nodes stores electronic currency of the corresponding denomination; Determining a difference currency based on the preset denomination and the target electronic currency, and storing the difference currency in a tail subtree node of the root node of the matching node; The step of traversing an ordered binary tree comprising at least two nodes, comparing the electronic currency denomination of the root node of the ordered binary tree with a preset denomination, and determining a target electronic currency having a denomination matching the electronic currency of the preset denomination and its matching node based on the comparison result includes: Call the pre-built ordered binary tree; Obtaining the electronic currency face value of each node on the left subtree or the right subtree of the ordered binary tree in sequence according to the preset face value; Obtain the difference between the electronic currency face value of each node and the preset face value. If there is a difference that meets the preset conditions, determine the electronic currency corresponding to the difference that meets the preset conditions as the target electronic currency, and determine the storage node of the target electronic currency as the matching node. If there is no difference that meets the preset conditions, re-obtain the electronic currency face value of each node on the left subtree or the right subtree of the ordered binary tree according to the preset face value, and obtain the difference between the electronic currency face value of each node and the preset face value, until the target electronic currency and the matching node are determined.

2. The method for storing difference currency according to claim 1, characterized in that: After the step of comparing the electronic currency face value of the root node of the ordered binary tree with the preset face value, the method further includes: If the preset denomination is not less than the electronic currency denomination of the root node, obtain the electronic currency denomination stored in the right subtree from the root node downwards; If the preset denomination is smaller than the electronic currency denomination of the root node, the electronic currency denominations stored on the left subtree are obtained sequentially from the root node downwards.

3. The method for storing difference currency according to claim 1, characterized in that: When it is detected that a difference currency is stored in the tail subtree node corresponding to the matching node, the step of determining the difference currency according to the preset denomination and the target electronic currency includes: Updating the electronic currency denomination of the matching node based on the difference currency stored in the tail subtree node; The difference in currency between the updated electronic currency face value and the preset face value is obtained.

4. The method for storing difference currency according to claim 1, characterized in that: When the target electronic currency is an electronic currency combination, the step of determining the difference currency based on the preset denomination and the target electronic currency includes: Counting the face value of each electronic currency in the electronic currency combination to obtain the corresponding total value of the electronic currency; The electronic currency whose total value exceeds the preset face value is determined to be the difference currency.

5. The method for storing difference currency according to claim 1, characterized in that: After the step of determining the target electronic currency and its matching node based on the comparison result, the method further includes: Performing a payment operation using the electronic currency face value updated by the matching node as a response value of the payment request; After the payment operation is completed, the difference currency corresponding to the electronic currency of the preset denomination and the target electronic currency are placed in an unusable state; Adjust the link that has the target electronic currency as a child node of the root node.

6. The method for storing difference currency according to claim 1, characterized in that: After the step of storing the difference currency in the tail subtree node of the root node of the matching node, the method further includes: If it is detected that the difference currency has been stored in the tail subtree node, the difference currency that has been stored and the difference currency to be stored at that time are merged, and the merged difference currency is stored in the tail subtree node.

7. A storage device for difference currency, characterized in that: include: a payment request receiving module, configured to receive a payment request for electronic currency of a preset denomination; a matching node determination module configured to, in response to the payment request, traverse an ordered binary tree comprising at least two nodes, compare the electronic currency denomination of a root node of the ordered binary tree with a preset denomination, and determine, based on the comparison result, a target electronic currency having a denomination that matches the electronic currency of the preset denomination and its matching node, wherein any of the nodes stores electronic currency of the corresponding denomination; a storage module, configured to determine a difference currency based on the preset denomination and the target electronic currency, and store the difference currency in a tail subtree node of the root node of the matching node; The matching node determination module traverses an ordered binary tree including at least two nodes, compares the electronic currency denomination of the root node of the ordered binary tree with a preset denomination, and determines, based on the comparison result, a target electronic currency having a denomination that matches the electronic currency of the preset denomination and its matching node, further comprising: A calling unit, used to call a pre-built ordered binary tree; Traversing the unit, the user sequentially obtains the electronic currency face value of each node on the left subtree or right subtree of the ordered binary tree according to the preset face value; Determine a target electronic currency unit, which is used to obtain the difference between the electronic currency face value of each node and the preset face value. If there is a difference that meets the preset conditions, the electronic currency corresponding to the difference that meets the preset conditions is determined as the target electronic currency, and the storage node of the target electronic currency is determined as the matching node. If there is no difference that meets the preset conditions, the electronic currency face value of each node on the left subtree or the right subtree of the ordered binary tree is obtained in sequence according to the preset face value, and the difference between the electronic currency face value of each node and the preset face value is obtained, until the target electronic currency and the matching node are determined.

8. The storage device for difference currency according to claim 7, characterized in that: The storage device for the difference currency further includes: A first acquisition module is configured to acquire the electronic currency denominations stored in the right subtree from the root node downwards if the preset denomination is not less than the electronic currency denomination of the root node; The second acquisition module is used to acquire the electronic currency face values stored on the left subtree from the root node downwards if the preset face value is less than the electronic currency face value of the root node.

9. The storage device for difference currency according to claim 7, characterized in that: When it is detected that the difference currency is stored in the tail subtree node corresponding to the matching node, the storage module further includes: a denomination updating unit, configured to update the electronic currency denomination of the matching node based on the difference currency stored in the tail subtree node; The difference currency obtaining unit is used to obtain the difference currency between the updated electronic currency face value and the preset face value.

10. The storage device for difference currency according to claim 7, characterized in that: When the target electronic currency is an electronic currency combination, the storage device for the difference currency includes: an electronic currency total value counting unit, configured to count the face value of each electronic currency in the electronic currency combination to obtain the corresponding electronic currency total value; The difference currency determination unit is used to determine that the electronic currency whose total value exceeds the preset face value is the difference currency.

11. The storage device for difference currency according to claim 7, characterized in that: The storage device for the difference currency further includes: a payment operation module, configured to execute a payment operation using the electronic currency face value updated by the matching node as a response value of the payment request; A setting module, configured to place the difference currency corresponding to the electronic currency of the preset denomination and the target electronic currency in an unusable state after the payment operation is completed; The link adjustment module is used to adjust the link of the child node of the root node with the target electronic currency as the root node.

12. The storage device for difference currency according to claim 7, characterized in that: The storage device for the difference currency further includes: The merging module is used for merging the stored difference currency and the difference currency to be stored at the current time if it is detected that the difference currency has been stored in the tail subtree node, and storing the merged difference currency in the tail subtree node.

13. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for storing difference currency according to any one of claims 1 to 6 is implemented.

14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the method for storing difference currency according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and system of processing digital currencies

    CN107330783A

  • Data storage method and node

    CN110275884A