# US 2022/0067062 A1 · Method and apparatus for obtaining number for transaction-accessed variable in blockchain in parallel

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2022/0067062 A1
- Document ID: US20220067062A1
- Status: Published application
- Kind: A1
- Application number: 17/364,013
- Filed: 2021-06-30
- Published: 2022-03-03
- Earliest claimed: 2020-08-28
- Assignees: Alipay (Hangzhou) Information Technology Co., Ltd.
- Applicants: Alipay (Hangzhou) Information Technology Co., Ltd.
- Inventors: Xiaojian LIU
- Web page: https://patentgrep.com/patent/US20220067062A1

## CPC

- G06F 16/27: Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F 21/64: Protecting data integrity, e.g. using checksums, certificates or signatures
- G06F 16/219: {Managing data history or versioning (querying versioned data G06F16/2474; querying temporal data G06F16/2477)}
- G06F 16/2365: {Ensuring data consistency and integrity}
- H04L 9/3239: {involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD}
- G06F 9/466: {Transaction processing}
- G06Q 20/3825: {Use of electronic signatures}
- G06Q 20/3827: {Use of message hashing}
- G06Q 20/3829: {involving key management}
- G06Q 20/389: {Keeping log of transactions for guaranteeing non-repudiation of a transaction}
- H04L 9/3236: {using cryptographic hash functions}
- H04L 9/3247: {involving digital signatures}
- H04L 9/50: {using hash chains, e.g. blockchains or hash trees}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)
- G06Q: INFORMATION 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

## Abstract

Implementations of the present specification provide a method and an apparatus for obtaining a number for a transaction-accessed variable in parallel in a blockchain. The method includes: for a first variable in a first transaction, calculating a hash value m corresponding to a variable name of the first variable, the hash value m being a value in pre-determined M values; performing the following atomic operation on an mth bit in a bitmap in a shared memory: reading a current first value of the mth bit, setting the mth bit to 1, and returning the first value, the bitmap having M bits, and initial values of the M bits being 0; in response to the first value being 0, obtaining a first number uniquely corresponding to the first variable, the first number being a value in pre-determined N values, and N being less than M; and setting a value of an mth element in a mapping array in the shared memory based on the first number, the mapping array including a total of M elements.

## Claims

### Claim 1

A method, comprising:
calculating a hash value m corresponding to a variable name of a first variable accessed in a first transaction in a blockchain, the hash value m being a value in pre-determined M values;
performing a first atomic operation on an mth bit in a bitmap in a shared memory, the first atomic operation including:
reading a current first value of the mth bit,
setting the mth bit to 1, and
returning the first value, the bitmap having M bits, and initial values of the M bits being 0;
in response to the first value being 0, obtaining a first number uniquely corresponding to the first variable, the first number being a value in pre-determined N values, and N being less than M; and
setting a value of an mth element in a mapping array in the shared memory based on the first number, the mapping array including a total of M elements,
wherein the shared memory further stores a version number variable and a version number array, the version number array including M elements, the first transaction being a transaction in a first batch of transactions; and
wherein the method comprises:
before the first batch of transactions are processed setting, a value of the version number variable to be unequal to a value of each element in the version number array; and
after the setting the value of the mth element in the mapping array based on the first number, modifying a value of mth element in the version number array to be equal to a value of the version number variable.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the obtaining the first number uniquely corresponding to the first variable includes performing a second atomic operation on an atomic variable, the second atomic operation including:
reading a current second value of the atomic variable,
increasing a value of the atomic variable by 1, and
returning the second value.

### Claim 3

(canceled)

### Claim 4 (depends on 1)

The method according to claim 1, wherein:
the setting the value of the version number variable to be unequal to the value of each element in the version number array includes:
setting the value of the version number variable to meet a pre-determined relationship with the value of each element in the version number array; and
the modifying the value of the mth element in the version number array to be equal to the value of the version number variable includes:
modifying the value of the mth element in the version number array based on the pre-determined relationship.

### Claim 5 (depends on 1)

The method according to claim 1, further comprising:
before the first batch of transactions are processed, setting the value of the version number variable to be greater than a value of each element in the mapping array; and
wherein the setting the value of the mth element in the mapping array in the shared memory based on the first number includes:
storing a sum of the first number and the value of the version number variable into the mth element in the mapping array.

### Claim 6 (depends on 1)

The method according to claim 1, comprising:
in response to the first value being 1, determining whether the value of the mth element in the mapping array is valid; and
in response to determining that the value of the mth element in the mapping array is valid, obtaining a number for the first variable based on the value of the mth element in the mapping array.

### Claim 7 (depends on 6)

The method according to claim 6, wherein the first transaction is a transaction in a first batch of transactions, and the method comprises:
before the first batch of transactions are processed, setting a value of each element in the mapping array to be a pre-determined invalid value; and
wherein the determining whether the value of the mth element in the mapping array is valid includes:
determining whether the value of the mth element in the mapping array is a pre-determined invalid value.

### Claim 8 (depends on 6)

The method according to claim 6, wherein the shared memory further stores a version number variable and a version number array, the version number array includes M elements, the first transaction is a transaction in a first batch of transactions, and the method comprises:
before the first batch of transactions are processed, setting a value of the version number variable to be unequal to a value of each element in the version number array; and
wherein the determining whether the value of the mth element in the mapping array is valid includes:
determining whether a value of an mth element in the version number array is equal to the value of the version number variable.

### Claim 9 (depends on 6)

The method according to claim 6, wherein the shared memory further stores a version number variable, the first transaction is a transaction in a first batch of transactions, and the method comprises:
before the first batch of transactions are processed, setting a value of the version number variable to be greater than a value of each element in the mapping array; and
wherein the determining whether the value of the mth element in the mapping array is valid includes:
determining whether the value of the mth element in the mapping array is greater than or equal to the value of the version number variable.

### Claim 10

(canceled)

### Claim 11

A non-transitory computer readable storage medium, storing executable instructions, which when executed by a processor enable the processor to implement acts including:
calculating a hash value m corresponding to a variable name of a first variable accessed in a first transaction in a blockchain, the hash value m being a value in pre-determined M values;
performing a first atomic operation on an mth bit in a bitmap in a shared memory, the first atomic operation including:
reading a current first value of the mth bit,
setting the mth bit to 1, and
returning the first value, the bitmap having M bits, and initial values of the M bits being 0;
in response to the first value being 0, obtaining a first number uniquely corresponding to the first variable, the first number being a value in pre-determined N values, and N being less than M; and
setting a value of an mth element in a mapping array in the shared memory based on the first number, the mapping array including a total of M elements,
wherein the shared memory further stores a version number variable, the first transaction bein a transaction in a first batch of transactions;
wherein the method comprises, before the first batch of transactions are processed, setting a value of the version number variable to be greater than a value of each element in the mapping array; and
wherein the setting the value of the mth element in the mapping array in the shared memory based on the first number includes storing a sum of the first number and the value of the version number variable into the mth element in the mapping array.

### Claim 12

A computing device, comprising a memory and a processor, the memory storing executable instructions, the executable instructions, when executed by the processor, configure the processor to implement acts including:
calculating a hash value m corresponding to a variable name of a first variable accessed in a first transaction in a blockchain, the hash value m being a value in pre-determined M values;
performing a first atomic operation on an mth bit in a bitmap in a shared memory, the first atomic operation including:
reading a current first value of the mth bit,
setting the mth bit to 1, and
returning the first value, the bitmap having M bits, and initial values of the M bits being 0;
in response to the first value being 0, obtaining a first number uniquely corresponding to the first variable, the first number being a value in pre-determined N values, and N being less than M; and
setting a value of an mth element in a mapping array in the shared memory based on the first number, the mapping array including a total of M elements,
wherein the shared memory further stores a version number variable and a version number array, the version number array including M elements, the first transaction being a transaction in a first hatch of transactions; and
wherein the method comprises:
before the first batch of transactions are processed, setting a value of the version number variable to be unequal to a value of each element in the version number array; and
after the setting the value of the mth element in the mapping array based on the first number, modifying a value of an mth element in the version number array to be equal to a value of the version number variable.

### Claim 13 (depends on 12)

The device according to claim 12, wherein the obtaining the first number uniquely corresponding to the first variable includes performing a second atomic operation on an atomic variable, the second atomic operation including:
reading a current second value of the atomic variable,
increasing a value of the atomic variable by 1, and
returning the second value.

### Claim 14

(canceled)

### Claim 15 (depends on 12)

The device according to claim 12, wherein:
the setting the value of the version number variable to be unequal to the value of each element in the version number array includes:
setting the value of the version number variable to meet a pre-determined relationship with the value of each element in the version number array; and
the modifying the value of the mth element in the version number array to be equal to the value of the version number variable includes:
modifying the value of the mth element in the version number array based on the pre-determined relationship.

### Claim 16 (depends on 12)

The device according to claim 12, wherein the acts include:
before the first batch of transactions are processed, setting a value of the version number variable to be greater than a value of each element in the mapping array; and
wherein the setting the value of the mth element in the mapping array in the shared memory based on the first number includes:
storing a sum of the first number and the value of the version number variable into the mth element in the mapping array.

### Claim 17 (depends on 12)

The device according to claim 12, wherein the acts include:
in response to the first value being 1, determining whether the value of the mth element in the mapping array is valid; and
in response to determining that the value of the mth element in the mapping array is valid, obtaining a number for the first variable based on the value of the mth element in the mapping array.

### Claim 18 (depends on 17)

The device according to claim 17, wherein the first transaction is a transaction in a first batch of transactions, and the acts include:
before the first batch of transactions are processed, setting a value of each element in the mapping array to be a pre-determined invalid value; and
wherein the determining whether the value of the mth element in the mapping array is valid includes:
determining whether the value of the mth element in the mapping array is a pre-determined invalid value.

### Claim 19 (depends on 17)

The device according to claim 17, wherein the shared memory further stores a version number variable and a version number array, the version number array includes M elements, the first transaction is a transaction in a first batch of transactions, and the acts include:
before the first batch of transactions are processed, setting a value of the version number variable to be unequal to a value of each element in the version number array; and
wherein the determining whether the value of the mth element in the mapping array is valid includes:
determining whether a value of an mth element in the version number array is equal to the value of the version number variable.

### Claim 20 (depends on 17)

The device according to claim 17, wherein the shared memory further stores a version number variable, the first transaction is a transaction in a first batch of transactions, and the acts include:
before the first batch of transactions are processed, setting a value of the version number variable to be greater than a value of each element in the mapping array; and
wherein the determining whether the value of the mth element in the mapping array is valid includes:
determining whether the value of the mth element in the mapping array is greater than or equal to the value of the version number variable.

### Claim 21

A method, comprising:
calculating a hash value m corresponding to a variable name of a first variable accessed in a first transaction in a blockchain, the hash value m being a value in pre-determined M values;
performing a first atomic operation on an mth bit in a bitmap in a shared memory, the first atomic operation including:
reading a current first value of the mth bit,
setting the mth bit to 1, and
returning the first value, the bitmap having M bits, and initial values of the M bits being 0;
in response to the first value being 0, obtaining a first number uniquely corresponding to the first variable, the first number being a value in pre-determined N values, and N being less than M; and
setting a value of an mth element in a mapping array in the shared memory based on the first number, the mapping array including a total of M elements,
wherein the shared memory further stores a version number variable, the first transaction being a transaction in a first batch of transactions;
wherein the method comprises, before the first batch of transactions are processed, setting a value of the version number variable to be greater than a value of each element in the mapping array; and
wherein the setting the value of the mth element in the mapping array in the shared memory based on the first number includes storing a sum of the first number and the value of the version number variable into the mth element in the mapping array.

### Claim 22 (depends on 21)

The method according to claim 21, further comprising:
before the first batch of transactions are processed, setting a value of the version number variable to be unequal to a value of each element in the version number array; and
after the setting the value of the mth element in the mapping array based on the first number, modifying a value of an mth element in the version number array to be equal to a value of the version number variable.

### Claim 23 (depends on 11)

The storage medium according to claim 11, wherein the acts include:
before the first batch of transactions are processed, setting a value of the version number variable to be unequal to a value of each element in the version number array; and
after the setting the value of the mth element in the mapping array based on the first number, modifying a value of an mth element in the version number array to be equal to a value of the version number variable.
