CN111861613B - Electronic lock operation recording method and device - Google Patents

Electronic lock operation recording method and device Download PDF

Info

Publication number
CN111861613B
CN111861613B CN201910418212.4A CN201910418212A CN111861613B CN 111861613 B CN111861613 B CN 111861613B CN 201910418212 A CN201910418212 A CN 201910418212A CN 111861613 B CN111861613 B CN 111861613B
Authority
CN
China
Prior art keywords
account number
active
active account
state
identification information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910418212.4A
Other languages
Chinese (zh)
Other versions
CN111861613A (en
Inventor
吴琼
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qisheng Technology Co Ltd
Original Assignee
Beijing Qisheng Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qisheng Technology Co Ltd filed Critical Beijing Qisheng Technology Co Ltd
Priority to CN201910418212.4A priority Critical patent/CN111861613B/en
Publication of CN111861613A publication Critical patent/CN111861613A/en
Application granted granted Critical
Publication of CN111861613B publication Critical patent/CN111861613B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0645Rental transactions; Leasing transactions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0631Resource planning, allocation, distributing or scheduling for enterprises or organisations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Human Resources & Organizations (AREA)
  • Theoretical Computer Science (AREA)
  • Strategic Management (AREA)
  • Economics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Entrepreneurship & Innovation (AREA)
  • General Business, Economics & Management (AREA)
  • Development Economics (AREA)
  • Finance (AREA)
  • Marketing (AREA)
  • Game Theory and Decision Science (AREA)
  • Educational Administration (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides an electronic lock operation recording method and device, which are used for solving the problem that the number of electronic locks in an active state after two different platforms are counted and delivered is inconsistent. The method comprises the following steps: receiving first operation information sent by an electronic lock, wherein the first operation information comprises: the first identification information and the first operation state of the electronic lock at this time are unique identification of the electronic lock; searching a recently generated first active account number from the active account number in a data block of a blockchain deployed in a blockchain network and the locally cached active account number which is not written into the blockchain; obtaining a second active account number according to the first active account number, the first identification information and the first operation state; generating an operation record comprising the second active account number, the first identification information and the first operation state; the operation record is written to a data buffer for holding data to be written to the blockchain.

Description

Electronic lock operation recording method and device
Technical Field
The application relates to the technical field of information processing, in particular to an electronic lock operation recording method and device.
Background
Currently within the industry there are two different platforms to manage electronic locks on the same shared bicycle, for example: the manufacturer's platform manages using the license plate number as identification information, and the operator's platform manages using the battery number as identification information. Therefore, the two different platforms manage the electronic locks, and the situation that the number of the electronic locks in an active state after leaving the factory is inconsistent is caused by the two different platforms.
Disclosure of Invention
An object of the embodiment of the present application is to provide an electronic lock operation recording method, which is used for improving the problem that the number of electronic locks in an active state after two different platforms are counted and delivered is inconsistent.
The embodiment of the application provides an electronic lock operation recording method, which is applied to a node server in a blockchain network and comprises the following steps: receiving first operation information sent by an electronic lock, wherein the first operation information comprises: the electronic lock comprises first identification information and a first operation state of the electronic lock, wherein the first identification information is a unique identification of the electronic lock; searching a first recently generated active account number from the active account number in a data block of a blockchain deployed in the blockchain network and the locally cached active account number which is not written into the blockchain, wherein the active account number represents the number of electronic locks in an active state when the active account number is generated; obtaining a second active account number according to the first active account number, the first identification information and the first operation state; generating an operation record comprising the second active account number, the first identification information and the first operation state; and writing the operation record into a data buffer area for storing data to be written into the blockchain. In the implementation process, the unique identification information of the electronic locks managed by the multiple platforms and the latest obtained active account numbers are stored through the data blocks in the blockchain network, so that the multiple platforms can query the latest active account numbers corresponding to the identification information of the electronic locks from the stored data blocks by acquiring and storing the data blocks in the blockchain network, and the problem that the number of the electronic locks in an active state after two different platforms are counted by factory is inconsistent is effectively solved.
Optionally, in this embodiment of the present application, after the generating an operation record number including the second active account number, the first identification information, and the first operation state, the method further includes: and sending the operation record to the blockchain network so as to enable other node servers of the blockchain network to cache the operation record. In the implementation process, the problem of blockchain bifurcation is effectively improved by sending the operation record of each data blockchain operation to the blockchain network in the mode of synchronous operation record.
Optionally, in an embodiment of the present application, the operation state of the operation information of the electronic lock includes an activation state, and the obtaining the second active account number according to the first active account number, the first identification information, and the first operation state includes: judging whether the first operation state is an activated state or not; if not, the numerical value of the first active account number is assigned to the second active account number. In the implementation process, after the first operation state is not the activation state, the original active account number is used as the new active account number, so that the speed and efficiency of acquiring the active account number are effectively improved.
Optionally, in an embodiment of the present application, after the determining whether the first operation state is an active state, the method further includes: and if the first operation state is an activation state, adding one to the first active account number to obtain the second active account number. In the implementation process, after the first operation state is determined to be the activation state, the original active account number is added with one to be used as the new active account number, so that the accuracy of acquiring the active account number is effectively improved.
Optionally, in an embodiment of the present application, the operation state of the operation information of the electronic lock further includes a pre-activation state, and the adding one to the first active account number to obtain the second active account number includes: reading a second operation state which is stored recently in the operation states corresponding to the first identification information from the data block of the block chain and the data buffer area of the local cache; and if the second operation state is a pre-activation state, adding one to the first active account number to obtain the second active account number. In the implementation process, after the current first operation state is determined to be the active state and the original second operation state is determined to be the pre-active state, the original active account number is added with one to be used as the new active account number, so that the situation that the electronic lock is broken when leaving a factory is avoided, and the accuracy of acquiring the active account number is effectively improved.
Optionally, in this embodiment of the present application, the obtaining the second active account number according to the first active account number, the first identification information, and the first operation state further includes: and if the second operation state is an activation state, assigning the value of the first active account number to the second active account number. In the implementation process, after the original operation state of the electronic lock is determined to be the activation state and the current operation state is determined to be the activation state, the original active account number is used as the new active account number, so that the situation that the active account number is repeatedly accumulated when the electronic lock is reactivated during fault maintenance is avoided, and the accuracy of acquiring the active account number is effectively improved.
Optionally, in an embodiment of the present application, the generating an operation record including the second active account number, the first identification information, and the first operation state includes: obtaining identification information of all active accounts in the data block; splicing the identification information of all active accounts in the data block to obtain an identification character string; generating a first hash value of the identification string; generating the operation record including the first hash value, the second active account number, the first identification information, and the first operation state. In the implementation process, the identification information of all the active accounts is spliced, and the hash value is generated according to the spliced character strings and stored in the data block, so that the credibility of writing the operation record into the data block is effectively increased.
Optionally, in an embodiment of the present application, the method further includes: obtaining a second hash value that was most recently generated prior to generating the first hash value; and if the first active account number is the same as the second active account number and the first hash value is different from the second hash value, obtaining the identification information of all abnormal accounts in the data block, wherein the abnormal accounts represent the electronic locks in abnormal states when the second active account number is stored. In the implementation process, by comparing the number of the active accounts before and after the operation of the electronic lock and comparing the hash values of the identification information of the active accounts before and after the operation of the electronic lock, misjudgment is avoided when the number of the active accounts is the same but the number of the active accounts is the same as the number of the abnormal accounts, and the accuracy of acquiring the abnormal accounts is effectively improved.
Optionally, in an embodiment of the present application, the method further includes: if the first active account number is different from the second active account number, obtaining identification information of all abnormal accounts in the data block, wherein the abnormal accounts represent electronic locks in abnormal states when the second active account number is stored. In the implementation process, the identification information of all the abnormal accounts in the data block is obtained by comparing the number of active accounts before and after the electronic lock is operated, so that the monitoring rate of all the abnormal accounts in the data block is improved.
The embodiment of the application also provides an electronic lock operation recording device, which is applied to a node server in a blockchain network and comprises: the first receiving module is used for receiving first operation information sent by the electronic lock, and the first operation information comprises: the electronic lock comprises first identification information and a first operation state of the electronic lock, wherein the first identification information is a unique identification of the electronic lock; a first searching module, configured to search a first recently generated active account number from an active account number in a data block of a blockchain deployed in the blockchain network and a locally cached active account number that has not been written into the blockchain, where the active account number represents a number of electronic locks that are in an active state when the active account number is generated; the first obtaining module is used for obtaining a second active account number according to the first active account number, the first identification information and the first operation state; a first generation module configured to generate an operation record including the second active account number, the first identification information, and the first operation state; and the first writing module is used for writing the operation record into the data block. In the implementation process, the identification information of the electronic locks and the latest obtained active account numbers are stored through the data blocks in the blockchain network, so that the problem that the number of the electronic locks in an active state after two different platforms are counted and leaving the factory is inconsistent is effectively solved.
Optionally, in an embodiment of the present application, the method further includes: and the first sending module is used for sending the operation record to the blockchain network so as to enable other node servers of the blockchain network to cache the operation record.
Optionally, in an embodiment of the present application, the operation state of the operation information of the electronic lock includes an activation state, and the first obtaining module includes: the first judging module is used for judging whether the first operation state is an activation state or not; and the first assignment module is used for assigning the numerical value of the first active account number to the second active account number if the first operation state is not an activation state.
Optionally, in an embodiment of the present application, the method further includes: and the second obtaining module is used for adding one to the first active account number if the first operation state is an activation state, so as to obtain the second active account number.
Optionally, in an embodiment of the present application, the operation state of the operation information of the electronic lock further includes a pre-activation state, and the second obtaining module includes: the first reading module is used for reading a second operation state which is stored recently in the operation states corresponding to the first identification information from the data block of the blockchain and the data buffer area of the local cache; and the first execution module is used for adding one to the first active account number if the second operation state is a pre-activation state, so as to obtain the second active account number.
Optionally, in an embodiment of the present application, the first obtaining module includes: and the second assignment module is used for assigning the numerical value of the first active account number to the second active account number if the second operation state is an activation state.
Optionally, in an embodiment of the present application, the method further includes: a fourth obtaining module, configured to obtain identification information of all active accounts in the data block; a fifth obtaining module, configured to splice identification information of all active accounts in the data block to obtain an identification string; a second generation module, configured to generate a first hash value of the identification string; and a third generation module, configured to generate the operation record including the first hash value, the second active account number, the first identification information, and the first operation state.
Optionally, in an embodiment of the present application, the method further includes: a sixth obtaining module, configured to obtain a second hash value that is generated recently before the first hash value is generated; and a seventh obtaining module, configured to obtain identification information of all abnormal accounts in the data block if the first active account number is the same as the second active account number and the first hash value is different from the second hash value, where the abnormal accounts represent electronic locks in an abnormal state when the second active account number is stored.
Optionally, in an embodiment of the present application, the method further includes: and the third obtaining module is used for obtaining the identification information of all abnormal accounts in the data block if the first active account number is different from the second active account number, and the abnormal accounts represent the electronic locks in abnormal states when the second active account number is stored.
The embodiment of the application also provides electronic equipment, which comprises: a processor and a memory storing machine-readable instructions executable by the processor, which when executed by the processor, perform the method as described above.
The present embodiments also provide a storage medium having stored thereon a computer program which, when executed by a processor, performs a method as described above.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 shows a schematic diagram of a communication system in an embodiment of the present application;
fig. 2 is a schematic flow chart of an electronic lock operation recording method according to an embodiment of the present application;
FIG. 3 is a flow chart of one embodiment of the electronic lock operation recording method step S130;
fig. 4 is a schematic structural diagram of an electronic lock operation recording device according to an embodiment of the present application;
fig. 5 shows a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
For ease of understanding, some concepts related to the embodiments of the present application are described below:
the block chain is a data block which is generated by using a cryptography method in a correlated mode, is used as a bottom technology of a bit coin, and contains information of network operation records for verifying the validity of the information and generating a next block.
A blockchain network refers to a network formed by all node servers in the network which jointly store and maintain data blocks with the node servers, and all the node servers in the blockchain network can jointly store and maintain the data blocks with the same content through a consensus mechanism and a synchronization mechanism.
Node servers refer to servers in a blockchain network that participate in the co-storage and maintenance of data blocks.
The data block refers to a data block stored and maintained in the blockchain by all node servers in the blockchain network where the node server is located, and one block may include a plurality of network operation records, where the network operation records may refer to operation records of the electronic lock.
An electronic lock refers to an electronic component with a battery or control lock and each lock or control lock has unique identification information. The battery, which is broadly referred to herein as the entire battery portion of the electric vehicle that provides power support, is a critical component that provides power support for the electric vehicle. Of course, the lock and battery may be operated in an integrated state or may be operated in a separate state together, such as an electronic lock with a battery in a shared bicycle, although the battery may be automatically charged during riding.
The identification information, also called SN level, or SN number, SN is called specific number or specific number, and is a label or unique identifier of the electronic lock. This identification number is unique and can be used to mark and distinguish each electronic lock.
The node server is used for receiving the first operation information sent by the electronic lock, calculating the latest active account number according to the first operation information, and storing the latest active account number into a data block in the blockchain network where the server is located. Of course, the server may also receive the query request and return the query result, for example, may receive a request for querying the identification information of all active accounts, and return the queried identification information of all active accounts to the request initiator, or may receive a request for querying the identification information of all abnormal accounts, and return the queried identification information of all abnormal accounts to the request initiator.
Referring to fig. 1, fig. 1 is a schematic diagram of a communication system in an embodiment of the present application, and the communication system in the embodiment of the present application is described below:
the plurality of node servers are in the same blockchain network, all node servers in the blockchain network store a blockchain, the blockchain comprises a plurality of data blocks, and any node server in the blockchain network can execute the method as follows. When the operation state of the electronic lock in the communication system is changed, the operation information is sent to a node server in the blockchain network, in some embodiments, the node server receiving the operation information is the node server to which the electronic lock belongs, and in other embodiments, the node server receiving the operation information is the node server closest to the electronic lock. The node server may maintain state information of the electronic lock on the blockchain based on the received operational information.
Referring to fig. 2, fig. 2 shows a flowchart of an electronic lock operation recording method provided in an embodiment of the present application, where the electronic lock operation recording method is applied to the node server in fig. 1, and the method includes:
step S110: and the node server receives the first operation information sent by the electronic lock.
The operation information refers to information sent by the electronic lock that the electronic lock is operated, and for example, the operation information may include: identification information, operation state, operator, operation time, operation place or operation position, etc. of the electronic lock. Therefore, the inclusion of the operation information herein in detail should not be construed as limiting the embodiments of the present application.
The first operation information refers to information that the node server receives that the electronic lock is operated, where the information is sent by the electronic lock, and for example, the first operation information may include: the electronic lock comprises first identification information and a first operation state of the electronic lock, wherein the first identification information is a unique identification of the electronic lock.
Step S120: the node server searches the recently generated first active account number from the active account number in the data block of the blockchain deployed in the blockchain network and the locally cached active account number which is not written into the blockchain.
The number of active accounts refers to the number of electronic locks in an active state in a data block in a blockchain network where a node server is located, namely the number of electronic locks in an active state when the active accounts represent the generation of the active accounts. The number of active accounts generated at different times characterizes the number of electronic locks that are active at different times, and the number of active accounts generated at different times may be different because the number of electronic locks that are active at different times may be different. For convenience of description, the first active account number generated most recently (latest) among the first active account numbers generated before step S120 is referred to as a first active account number in the embodiment of the present application.
The node server may search the first most recent active account number from two locations, the first location being in a blockchain deployed by the blockchain network, the data block of the blockchain storing a historically generated active account number that has been agreed upon in the blockchain network, the second location being the active account number locally cached by the node server that has not been written to the blockchain.
The node server may search the two locations for the latest first active account number by: the node server searches the recently generated active account number in the blockchain and searches a recently generated active account number from a local cache, wherein the first active account number is generated later in the two active account numbers; or the node server searches the recently generated active account number in the blockchain, then traverses the active account number in the local cache, judges whether the active account number with the generation time later than that of the active account number searched in the blockchain exists, if not, the active account number searched in the blockchain is the first active account number, and if so, the active account number with the latest generation time in the local cache is determined to be the first account number; in another possible manner, similar to the previous manner, the latest generated active account number is searched from the local cache, and then compared with the active account number in the blockchain, and finally the first active account number with the latest generation time is determined.
The node server searches the active account number with the latest generation time from the blockchain in the following manner: first, the node server locally stores a complete blockchain, and the node server searches the latest generated active account number in the locally stored blockchain. The node server maintains the data blocks of the complete blockchain, either periodically or non-periodically, to synchronize the blockchain from the blockchain network, or to synchronize the blockchain from the blockchain network when there are new data blocks to add to the blockchain. And secondly, after receiving the first operation information, the node server synchronizes the complete blockchain from the blockchain network, and searches the active account number with the latest generation time from the synchronized blockchain.
Step S130: and the node server obtains a second active account number according to the first active account number, the first identification information and the first operation state.
The first identification information refers to identification information included in first operation information sent by the electronic lock and received by the node server.
The operation state refers to a state in operation information sent by the electronic lock and operated by the electronic lock, and also refers to a state in which the electronic lock is operated. The operating state is for example: the electronic lock comprises a preactivation state, an unlocking state, a locking state and the like, wherein the preactivation state indicates that the battery lock can work normally, and the electronic lock can be set to the preactivation state by an operator when the electronic lock leaves a factory, namely the electronic lock can send a data request, so that the situation that the electronic lock cannot be used due to damage when the electronic lock leaves the factory is avoided.
The first operation state refers to an operation state included in first operation information sent by the electronic lock and received by the node server.
Referring to fig. 3, fig. 3 is a flow chart schematically illustrating an embodiment of the electronic lock operation recording method step S130. In this embodiment, one implementation of step S130 may include the following steps:
step S131: the node server determines whether the first operational state is an active state.
The activated state means that the electronic lock can be normally used after being set to be in the activated state, namely, can be normally unlocked and locked. If not set to an activated state, the electronic lock cannot be unlocked and locked.
Step S132: and if the first operation state is not the activation state, assigning the value of the first active account number to the second active account number.
The second active account number refers to the original value of the first active account number as the current second active account number after the electronic lock is changed to the first operation state after being operated, that is, the current value of the active account number is not changed.
Step S133: and if the first operation state is the activation state, adding one to the first active account number to obtain a second active account number.
Wherein, the operation state of the operation information of the electronic lock further includes a pre-activation state, and one embodiment of step S133 may include the steps of:
and reading the second operation state which is stored recently in the operation states corresponding to the first identification information from the data blocks of the block chain and the data buffer area of the local cache. Wherein the first operating state is the present state and the second operating state is the original state.
And if the second operation state is the pre-activation state, adding one to the first active account number to obtain a second active account number. That is, if the original state is the pre-activated state and the present state is the activated state, the first active account number is added by one to obtain the second active account number. For example: the electronic lock is set to be in a pre-activated state before leaving the factory, and is set to be in an activated state when leaving the factory, and the number of active accounts is determined to be a new number of active accounts after being added by one.
If the second operation state is the active state, the step of assigning the value of the first active account number to the second active account number is executed. That is, if the original state is the active state and the current state is the active state, the value of the first active account number is assigned to the second active account number. For example: the electronic lock is already in an activated state, and a sharing bicycle with the electronic lock is damaged, and the electronic lock needs to be returned to a factory for repair and can be reactivated after repair, and the number of active accounts is unchanged.
Of course, in a specific implementation, multiple states may be jointly determined, rather than one state as described above, for example: and if the second operation state is a pre-activation state or an unlocking state or a locking state, executing to add one to the first active account number to obtain a second active account number.
In the implementation process, after the current first operation state is determined to be the active state and the original second operation state is determined to be the pre-active state, the original active account number is added with one to be used as the new active account number, so that the situation that the electronic lock is broken when leaving a factory is avoided, and the accuracy of acquiring the active account number is effectively improved.
Step S140: the node server generates an operation record including the second active account number, the first identification information, and the first operation state.
In the implementation process, the identification information of the electronic locks and the latest obtained active account numbers are stored through the data blocks in the blockchain network, so that the problem that the number of the electronic locks in an active state after two different platforms are counted and leaving the factory is inconsistent is effectively solved. In this embodiment, one implementation manner of step S140 may include:
Step S141: the node server obtains the identification information of all active accounts in the data block.
The node server can directly acquire the identification information of all active accounts from the data block in the blockchain network where the node server is located, can acquire the identification information of all active accounts from the cached data block, and can also combine the identification information of all active accounts cached last time with the identification information of the active accounts at this time to acquire the identification information of all active accounts.
Step S142: the node server splices the identification information of all active accounts in the data block to obtain an identification character string.
The splicing of the identification information of all active accounts in the data block may be performed by splicing the identification information of all active accounts through a character string, or by splicing the character string after transcoding, for example, in a transcoding manner: base64 and URL encoding, etc.
Step S143: the node server generates a first hash value identifying the string.
The specific manner in which the node server generates the first hash value of the identification string may be adopted in the specific implementation process: the method comprises the steps of obtaining hash values in the modes of MD5, RSA2 and the like.
Step S144: the node server writes the first hash value, the second active account number, the first identification information and the first operation state as one operation record into a data buffer for storing data to be written into the blockchain.
In the implementation process, the identification information of all the active accounts is spliced, and the hash value is generated according to the spliced character strings and stored in the data block, so that the credibility of writing the operation record into the data buffer area for storing the data of the block chain to be written is effectively increased.
Step S150: the node server writes the operation record to a data buffer for holding data to be written to the blockchain.
The node server may write the operation record to the data buffer for storing the data to be written to the blockchain in a plurality of ways, the first way the node server may write the operation record to the locally stored data buffer for storing the data to be written to the blockchain, and the second way the node server may broadcast the operation record to other node servers in the blockchain network synchronously, so that the other node servers in the blockchain network write the operation record to the data buffers of the other node servers.
After writing an operation record to a data buffer for holding data to be written to the blockchain, the operation record may be written to the blockchain-agreed upon data block in a number of ways, as follows:
in the first way, the node server may write the operation record into a data buffer area for storing the data to be written into the blockchain, and when the data buffer area in the node server meets a preset condition and is mature into a data block, the data block is broadcast to other node servers in the blockchain network, and the node server and the other node servers in the blockchain network compete for accounting rights. When the node server obtains the accounting right, the node server writes the accounting result into the data block agreed with the blockchain and broadcasts the accounting result to other node servers in the blockchain network, or when the other node servers in the blockchain network obtain the accounting right, the other node servers in the blockchain network write the accounting result into the data block agreed with the blockchain and broadcast the accounting result to other node servers in the blockchain network.
In a second manner, the node servers may broadcast the operation records synchronously to other node servers in the blockchain network to cause the other node servers in the blockchain network to write the operation records into the data buffers of the other node servers. When the data buffer area to be stored in other node servers in the block chain network meets the preset condition and is mature into the data block, the other node servers in the block chain network broadcast the data block to the node servers in the block chain network. The node server receives the data block, and the node server competes with other node servers in the blockchain network for accounting rights, and after obtaining the accounting rights, the steps performed are the same as the first mode described above, and will not be described again.
The third way is similar to the first way, except that when the data buffer in the node server satisfies the preset condition, it is mature into a data block, and the data block does not need to be broadcast to other node servers in the blockchain network. When the node server obtains the accounting right or other node servers in the blockchain network obtain the accounting right, the subsequent execution method is the same as the method of the first mode, and therefore, the details are not repeated here. In the third mode, the reason that the data block does not need to be broadcast to the blockchain network is that the node server broadcasts the operation record to the blockchain network after generating each operation record, which can ensure that different node servers in the blockchain network locally cache the same operation record, and when the operation record cached in the data buffer area on one node server can be packaged into the data block, the operation records cached in the data buffer areas on other node servers can also be packaged into the data block, and the data blocks formed by packaging different node servers are the same. This approach may save bandwidth resources and may reduce the time consumed for out-of-block.
Optionally, in an embodiment of the present application, after step S140, the method may further include:
step S160: the node server sends the operation record to the blockchain network.
The node server sends the operation record to the blockchain network so that other node servers of the blockchain network cache the operation record to solve the problem of blockchain bifurcation possibly caused by time difference of block storage and verification. The common mechanism here refers to when the current block includes a certain number of records, that is, when the block is mature, the block needs to be sent to other node servers in the blockchain network to enable the other node servers to verify the block, where record synchronization refers to that each time an operation record is stored in the block, synchronization is requested from the other node servers.
In the implementation process, the problem of blockchain bifurcation is effectively improved by sending the operation record of each data blockchain operation to the blockchain network in the mode of synchronous operation record.
Optionally, in the embodiment of the present application, after writing the operation record into the data buffer area for storing the data to be written into the blockchain, the identification information of all the abnormal accounts may be queried, and the query of the identification information of all the abnormal accounts may be performed, where the method is implemented in the following two embodiments:
In a first embodiment, if the number of active accounts is not changed and hash values of identification information of all active accounts are changed, identification information of all abnormal accounts is obtained, and one embodiment includes the following steps:
step S170: the node server obtains a second hash value that was most recently generated prior to generating the first hash value.
Wherein the specific way to obtain the second hash value that was most recently generated before the first hash value was generated is for example: the node server obtains a second hash value in the operation record stored recently from the data block, wherein the operation record stored recently by the data block is the operation record stored last time by the data block, and the operation record stores the second hash value generated according to the identification information of all active accounts stored last time.
Step S180: and if the first active account number is the same as the second active account number and the first hash value is different from the second hash value, acquiring the identification information of all abnormal accounts in the data block.
The abnormal account represents the electronic lock in an abnormal state when the second active account number is stored, and the number of the changed active accounts is consistent with the number of the changed abnormal accounts, so that the active account number is unchanged.
In a second embodiment, if the number of active accounts changes, the identification information of all abnormal accounts is obtained, and one embodiment includes the following steps:
step S190: if the number of the first active accounts is different from the number of the second active accounts, the identification information of all abnormal accounts in the data block is obtained.
An abnormal account refers to an electronic lock that is in an abnormal state when the second active account number is stored, where the abnormal state is, for example: the disconnection state refers to heartbeat information sent by the node server when the node server does not receive the electronic lock, for example, the battery of the electronic lock is dead or the battery is destroyed, so that the heartbeat information cannot be sent, the silencing state refers to heartbeat information sent by the node server when the node server can receive the electronic lock, but the node server does not receive the unlocking state operation information or the locking state operation information sent by the electronic lock, for example, the electronic lock on the sharing bicycle is abandoned in a place where people are not smoking.
In the implementation process, by comparing the number of the active accounts before and after the operation of the electronic lock and comparing the hash values of the identification information of the active accounts before and after the operation of the electronic lock, misjudgment is avoided when the number of the active accounts is the same but the number of the active accounts is the same as the number of the abnormal accounts, and the accuracy of acquiring the abnormal accounts is effectively improved.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic lock operation recording device according to an embodiment of the present application. The embodiment of the application provides an electronic lock operation recording device 100, which is applied to a node server, and includes:
the operation information receiving module 110 is configured to receive first operation information sent by the electronic lock, where the first operation information includes: the electronic lock comprises first identification information and a first operation state of the electronic lock, wherein the first identification information is a unique identification of the electronic lock.
The first account obtaining module 120 is configured to obtain a first active account number that is recently stored in a data block in a blockchain network where the node server is located, where the first active account number represents a number of electronic locks that are in an active state when the first active account number is stored.
The second account obtaining module 130 is configured to obtain a second active account number according to the first active account number, the first identification information, and the first operation state.
The first record writing module 140 is configured to write, as one operation record, the second active account number, the first identification information, and the first operation state into a data buffer for storing data to be written into the blockchain.
In the implementation process, the identification information of the electronic locks and the latest obtained active account numbers are stored through the data blocks in the blockchain network, so that the problem that the number of the electronic locks in an active state after two different platforms are counted and delivered is inconsistent is effectively solved.
Optionally, in an embodiment of the present application, the apparatus further includes:
and the operation record sending module is used for sending the operation record to the blockchain network.
Optionally, in an embodiment of the present application, the first account obtaining module includes:
and the data block storage module is used for obtaining and storing the data blocks in the blockchain network where the node server is located.
The first obtaining submodule is used for obtaining the first active account number from the stored data block.
Optionally, in an embodiment of the present application, the second account obtaining module includes:
and the activation state judging module is used for judging whether the first operation state is an activation state or not.
And the first value assignment module is used for assigning the value of the first active account number to the second active account number when the first operation state is not the active state.
Optionally, in an embodiment of the present application, the apparatus further includes:
and the second obtaining submodule is used for adding one to the first active account number when the first operation state is the activation state to obtain a second active account number.
Optionally, in an embodiment of the present application, the second obtaining submodule includes:
and the operation state reading module is used for reading the second operation state which is stored recently in the operation states corresponding to the first identification information from the data blocks of the block chain and the data buffer area of the local cache.
And the third obtaining sub-module is used for executing the addition of one to the first active account number to obtain a second active account number when the second operation state is the pre-activation state.
Optionally, in an embodiment of the present application, the apparatus may further include:
and the second value assignment module is used for assigning the value of the first active account number to the second active account number when the second operation state is the active state.
Optionally, in an embodiment of the present application, the electronic lock operation recording device further includes:
the first anomaly obtaining module is used for obtaining the identification information of all anomaly accounts in the data block when the first active account number is different from the second active account number, and the anomaly accounts represent the electronic locks in an anomaly state when the second active account number is stored.
Optionally, in an embodiment of the present application, the apparatus may further include:
the identification information obtaining module is used for obtaining the identification information of all the active accounts in the data block.
The identification information splicing module is used for splicing the identification information of all the active accounts in the data block to obtain an identification character string.
And the first hash obtaining module is used for generating a first hash value of the identification character string.
The second record writing module is used for writing the first hash value, the second active account number, the first identification information and the first operation state into a data buffer area used for storing the data of the blockchain to be written as one operation record.
Optionally, in an embodiment of the present application, the electronic lock operation recording device may further include:
and the second hash obtaining module is used for obtaining a second hash value in the operation record stored recently by the data block.
And the second abnormity obtaining module is used for obtaining the identification information of all the abnormal accounts in the data block when the first active account number is the same as the second active account number and the first hash value is different from the second hash value, and the abnormal accounts represent the electronic locks in abnormal states when the second active account number is stored.
In the implementation process, by comparing the number of the active accounts before and after the operation of the electronic lock and comparing the hash values of the identification information of the active accounts before and after the operation of the electronic lock, misjudgment is avoided when the number of the active accounts is the same but the number of the active accounts is the same as the number of the abnormal accounts, and the accuracy of acquiring the abnormal accounts is effectively improved.
Referring to fig. 5, fig. 5 shows a schematic structural diagram of an electronic device according to an embodiment of the present application. An electronic device 101 provided in an embodiment of the present application includes: a processor 102 and a memory 103, the memory 103 storing machine-readable instructions executable by the processor 102, which when executed by the processor 102 perform the following method.
Referring to fig. 5, an embodiment of the present application further provides a storage medium 104, where the storage medium 104 stores a computer program that, when executed by the processor 102, performs the following method.
The storage medium 104 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as a static random access Memory (Static Random Access Memory, SRAM), an electrically erasable Programmable Read-Only Memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), an erasable Programmable Read-Only Memory (Erasable Programmable Read Only Memory, EPROM), a Programmable Read-Only Memory (PROM), a Read-Only Memory (ROM), a magnetic Memory, a flash Memory, a magnetic disk, or an optical disk.
The foregoing is merely a specific implementation of the embodiments of the present application, but the scope of the embodiments of the present application is not limited thereto, and any person skilled in the art may easily think about changes or substitutions within the technical scope of the embodiments of the present application, and they are intended to be covered by the scope of the embodiments of the present application.

Claims (16)

1. The electronic lock operation recording method is characterized by being applied to a node server in a blockchain network and comprising the following steps of:
receiving first operation information sent by an electronic lock, wherein the first operation information comprises: the electronic lock comprises first identification information and a first operation state of the electronic lock, wherein the first identification information is a unique identification of the electronic lock;
searching a first recently generated active account number from the active account number in a data block of a blockchain deployed in the blockchain network and the locally cached active account number which is not written into the blockchain, wherein the active account number represents the number of electronic locks in an active state when the active account number is generated;
obtaining a second active account number according to the first active account number, the first identification information and the first operation state;
generating an operation record comprising the second active account number, the first identification information and the first operation state;
Writing the operation record into a data buffer area for storing data to be written into the blockchain;
if the operation state of the operation information of the electronic lock includes an activation state, the obtaining a second active account number according to the first active account number, the first identification information and the first operation state includes:
judging whether the first operation state is an activated state or not;
if not, assigning the value of the first active account number to the second active account number;
and if the first operation state is an activation state, adding one to the first active account number to obtain the second active account number.
2. The method of claim 1, further comprising, after the generating the operation record including the second number of active accounts, the first identification information, and the first operational state:
and sending the operation record to the blockchain network so as to enable other node servers of the blockchain network to cache the operation record.
3. The method of claim 1, wherein the operational state of the operational information of the electronic lock further comprises a pre-activation state, the adding one to the first number of active accounts to obtain the second number of active accounts, comprising:
Reading a second operation state which is stored recently in the operation states corresponding to the first identification information from the data block of the block chain and the data buffer area of the local cache;
and if the second operation state is a pre-activation state, adding one to the first active account number to obtain the second active account number.
4. The method of claim 3, wherein the obtaining a second number of active accounts based on the first number of active accounts, the first identification information, and the first operational state, further comprises:
and if the second operation state is an activation state, assigning the value of the first active account number to the second active account number.
5. The method of any of claims 1-4, wherein the generating an operation record including the second number of active accounts, the first identification information, and the first operational state comprises:
obtaining identification information of all active accounts in the data block;
splicing the identification information of all active accounts in the data block to obtain an identification character string;
generating a first hash value of the identification string;
generating the operation record including the first hash value, the second active account number, the first identification information, and the first operation state.
6. The method as recited in claim 5, further comprising:
obtaining a second hash value that was most recently generated prior to generating the first hash value;
and if the first active account number is the same as the second active account number and the first hash value is different from the second hash value, obtaining the identification information of all abnormal accounts in the data block, wherein the abnormal accounts represent the electronic locks in abnormal states when the second active account number is stored.
7. The method of any one of claims 1-4, further comprising:
if the first active account number is different from the second active account number, obtaining identification information of all abnormal accounts in the data block, wherein the abnormal accounts represent electronic locks in abnormal states when the second active account number is stored.
8. An electronic lock operation recording device, which is applied to a node server in a blockchain network, comprising:
the first receiving module is used for receiving first operation information sent by the electronic lock, and the first operation information comprises: the electronic lock comprises first identification information and a first operation state of the electronic lock, wherein the first identification information is a unique identification of the electronic lock;
A first searching module, configured to search a first recently generated active account number from an active account number in a data block of a blockchain deployed in the blockchain network and a locally cached active account number that has not been written into the blockchain, where the active account number represents a number of electronic locks that are in an active state when the active account number is generated;
the first obtaining module is used for obtaining a second active account number according to the first active account number, the first identification information and the first operation state;
a first generation module configured to generate an operation record including the second active account number, the first identification information, and the first operation state;
a first writing module for writing the operation record into a data buffer for storing data to be written into the blockchain;
if the operation state of the operation information of the electronic lock includes an activation state, the first obtaining module includes:
the first judging module is used for judging whether the first operation state is an activation state or not;
the first assignment module is used for assigning the numerical value of the first active account number to the second active account number if the first operation state is not an activation state;
And the second obtaining module is used for adding one to the first active account number if the first operation state is an activation state, so as to obtain the second active account number.
9. The apparatus as recited in claim 8, further comprising:
and the first sending module is used for sending the operation record to the blockchain network so as to enable other node servers of the blockchain network to cache the operation record.
10. The apparatus of claim 8, wherein the operational state of the operational information of the electronic lock further comprises a pre-activation state, and the second obtaining module comprises:
the first reading module is used for reading a second operation state which is stored recently in the operation states corresponding to the first identification information from the data block of the blockchain and the data buffer area of the local cache;
and the first execution module is used for adding one to the first active account number if the second operation state is a pre-activation state, so as to obtain the second active account number.
11. The apparatus of claim 10, wherein the first obtaining module comprises:
and the second assignment module is used for assigning the numerical value of the first active account number to the second active account number if the second operation state is an activation state.
12. The apparatus of any one of claims 8-11, further comprising:
a fourth obtaining module, configured to obtain identification information of all active accounts in the data block;
a fifth obtaining module, configured to splice identification information of all active accounts in the data block to obtain an identification string;
a second generation module, configured to generate a first hash value of the identification string;
and a third generation module, configured to generate the operation record including the first hash value, the second active account number, the first identification information, and the first operation state.
13. The apparatus as recited in claim 12, further comprising:
a sixth obtaining module, configured to obtain a second hash value that is generated recently before the first hash value is generated;
and a seventh obtaining module, configured to obtain identification information of all abnormal accounts in the data block if the first active account number is the same as the second active account number and the first hash value is different from the second hash value, where the abnormal accounts represent electronic locks in an abnormal state when the second active account number is stored.
14. The apparatus of any one of claims 8-11, further comprising:
And the third obtaining module is used for obtaining the identification information of all abnormal accounts in the data block if the first active account number is different from the second active account number, and the abnormal accounts represent the electronic locks in abnormal states when the second active account number is stored.
15. An electronic device, comprising: a processor and a memory storing machine-readable instructions executable by the processor, which when executed by the processor, perform the method of any of claims 1-7.
16. A storage medium having stored thereon a computer program which, when executed by a processor, performs the method of any of claims 1-7.
CN201910418212.4A 2019-05-19 2019-05-19 Electronic lock operation recording method and device Active CN111861613B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910418212.4A CN111861613B (en) 2019-05-19 2019-05-19 Electronic lock operation recording method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910418212.4A CN111861613B (en) 2019-05-19 2019-05-19 Electronic lock operation recording method and device

Publications (2)

Publication Number Publication Date
CN111861613A CN111861613A (en) 2020-10-30
CN111861613B true CN111861613B (en) 2024-04-16

Family

ID=72965909

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910418212.4A Active CN111861613B (en) 2019-05-19 2019-05-19 Electronic lock operation recording method and device

Country Status (1)

Country Link
CN (1) CN111861613B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116506496B (en) * 2023-06-25 2023-09-22 深圳市华曦达科技股份有限公司 Locking method, device, equipment and computer readable storage medium for equipment

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015200098A (en) * 2014-04-08 2015-11-12 川越 文雄 Bicycle lock system and method, and bicycle lock device used therefor
CN105096739A (en) * 2015-07-14 2015-11-25 同方威视技术股份有限公司 Electronic seal and electronic lock
CN107067253A (en) * 2017-04-11 2017-08-18 崔俊新 Account binding method and system and storage medium
CN107742336A (en) * 2017-09-19 2018-02-27 深圳市几米软件有限公司 A kind of data transmission method and terminal device for being used to share bicycle smart lock
CN108118981A (en) * 2017-12-15 2018-06-05 湖南斯迈尔特智能科技发展有限公司 Vehicle intelligent is locked
CN108282474A (en) * 2018-01-18 2018-07-13 山东大学 The maintaining method of digital asset trade identity based on block chain
CN108965991A (en) * 2018-07-27 2018-12-07 深圳Tcl新技术有限公司 Verification method and system, terminal device, the storage medium of program ordering state
CN109272606A (en) * 2018-07-19 2019-01-25 天网互联科技(深圳)有限公司 A kind of smart lock monitoring equipment, method and storage medium based on block chain
CN109377626A (en) * 2018-12-13 2019-02-22 深圳市云歌人工智能技术有限公司 The method of electronic lock information processing and the acquisition electronic lock right to use based on block chain
CN109685946A (en) * 2018-11-29 2019-04-26 深圳供电局有限公司 Open method, device, equipment and the storage medium of lockset
CN109710823A (en) * 2018-11-02 2019-05-03 远光软件股份有限公司 Archive management method, file administration network and electronic equipment based on block chain

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015200098A (en) * 2014-04-08 2015-11-12 川越 文雄 Bicycle lock system and method, and bicycle lock device used therefor
CN105096739A (en) * 2015-07-14 2015-11-25 同方威视技术股份有限公司 Electronic seal and electronic lock
CN107067253A (en) * 2017-04-11 2017-08-18 崔俊新 Account binding method and system and storage medium
CN107742336A (en) * 2017-09-19 2018-02-27 深圳市几米软件有限公司 A kind of data transmission method and terminal device for being used to share bicycle smart lock
CN108118981A (en) * 2017-12-15 2018-06-05 湖南斯迈尔特智能科技发展有限公司 Vehicle intelligent is locked
CN108282474A (en) * 2018-01-18 2018-07-13 山东大学 The maintaining method of digital asset trade identity based on block chain
CN109272606A (en) * 2018-07-19 2019-01-25 天网互联科技(深圳)有限公司 A kind of smart lock monitoring equipment, method and storage medium based on block chain
CN108965991A (en) * 2018-07-27 2018-12-07 深圳Tcl新技术有限公司 Verification method and system, terminal device, the storage medium of program ordering state
CN109710823A (en) * 2018-11-02 2019-05-03 远光软件股份有限公司 Archive management method, file administration network and electronic equipment based on block chain
CN109685946A (en) * 2018-11-29 2019-04-26 深圳供电局有限公司 Open method, device, equipment and the storage medium of lockset
CN109377626A (en) * 2018-12-13 2019-02-22 深圳市云歌人工智能技术有限公司 The method of electronic lock information processing and the acquisition electronic lock right to use based on block chain

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
电子门锁远程监控系统;李鸿;;山西电子技术;20171015(05);第58-61、83页 *

Also Published As

Publication number Publication date
CN111861613A (en) 2020-10-30

Similar Documents

Publication Publication Date Title
CN110543788B (en) Data storage method, apparatus, computer readable storage medium and computer device
CN108710681B (en) File acquisition method, device, equipment and storage medium
US7526530B2 (en) System and method for cacheing web files
CN112131099B (en) Version upgrading test method and device
CN110602239A (en) Block chain information storage method and related equipment
JP2020182214A (en) Verification system and method for cooperation of blockchain and off-chain device
CN110096522B (en) Block chain data processing method, device and equipment supporting relational retrieval
US20080082831A1 (en) Information processing system, information processing apparatus, information processing method, and storage medium
CN113204530B (en) Data writing method, device, equipment and medium of distributed file system
CN111400267B (en) Method and device for recording logs
CN104765652A (en) Data backup and data recovery method and device
CN111861613B (en) Electronic lock operation recording method and device
CN112860452A (en) Method, device and computer readable medium for improving response speed of high concurrency condition
CN108509296B (en) Method and system for processing equipment fault
CN105550230A (en) Method and device for detecting failure of node of distributed storage system
CN112000623A (en) Metadata access method and device and computer readable storage medium
CN109067849A (en) Method of data synchronization based on block
CN108876378A (en) Publicly-owned chain data enciphering back-up method
CN112783688B (en) Erasure code data recovery method and device based on available partition level
US8533135B2 (en) Model generating device and model generating method
CN116107801A (en) Transaction processing method and related product
CN111385511B (en) Video data processing method and device and video recording equipment
CN111966635A (en) Method and device for improving file detection speed of distributed storage file system
CN114077610A (en) Data publishing method and related device
CN113377762A (en) Publishing system and method for block chain subchain

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant