Electronic device for recovering block data in blockchain network and operation method thereof
An electronic device constituting a block node included in a blockchain network is provided. The method for operating an electronic device includes, in response to a request for recovery of loss of data stored in a memory, requesting user node information relating to a user of the electronic device from an external device through a communication circuit, receiving the user node information acquired based on node identification information stored in the external device, requesting block data associated with the user from the external device, based on the user node information, acquiring at least one block detected based on the node information, among the entire ledger, from the external device through the communication circuit, and storing the at least one acquired block in the memory.
1 . An electronic device constituting a first block node included in a blockchain network, the electronic device comprising:
a communication circuitry configured to transmit or receive a signal to or from an external device having an entire ledger for the blockchain network, and node identification information about mapping between a plurality of users registered in the blockchain network and a plurality of block nodes registered with the plurality of users, wherein the entire ledger comprises at least one block comprising node information relating to at least one block node included in the blockchain network, the at least one block node having consented to block generation;
memory, comprising one or more storage media, storing instructions; and
at least one processor communicatively coupled to the communication circuitry and the memory,
wherein the instructions, when executed by the at least one processor, cause the electronic device to:
execute a smart contract for registering a user of the electronic device and the electronic device together in the blockchain network,
receive a request for generating a first transaction,
execute a first smart contract for the first transaction in response to the request,
store, in the memory, a partial ledger comprising at least a part of the entire ledger, wherein the at least a part of the entire ledger comprises a first block including the first transaction,
identify that at least a part of data included in the partial ledger is lost, and
in response to a request for recovery of the at least a part of data:
request user node information about at least one block node registered with the user of the electronic device from the external device through the communication circuitry, wherein the at least one block node comprises the first block node, and the user node information comprises first node information about the first block node,
receive the user node information acquired based on the node identification information stored in the external device,
request block data associated with the first block node from the external device, based on the user node information comprising the first node information about the first block node,
acquire at least one block which is detected in the entire ledger based on the first node information, by receiving the block data from the external device through the communication circuitry, and
store, for the partial ledger, the acquired at least one block in the memory.
2 . The electronic device of claim 1 , wherein the entire ledger comprises a blockchain comprising a block corresponding to at least one transaction generated in the blockchain network and a state database of the blockchain network.
3 . The electronic device of claim 1 ,
wherein the at least one block comprises related block information, and
wherein the related block information comprises the node information and previous block information in the partial ledger.
4 . The electronic device of claim 3 , wherein the instructions, when executed by the at least one processor, further cause the electronic device to connect the at least one block to a blockchain included in the partial ledger, based on the previous block information in the partial ledger.
5 . The electronic device of claim 1 , wherein the node identification information comprises user information relating to each of the at least one block node, the user information being associated with a unique value of each of the at least one block node.
6 . The electronic device of claim 1 ,
wherein the smart contract is executed in response to initial execution of a blockchain-related operation by the electronic device, the smart contract being related to an initial operation.
7 . The electronic device of claim 1 ,
wherein the instructions, when executed by the at least one processor, further cause the electronic device to:
generate a security connection with the external device through a relay server, and
transmit or receive data through the security connection, and
wherein the relay server is configured to generate a connection between devices for which verification of non-falsification is made.
8 . The electronic device of claim 1 , further comprising:
a display,
wherein the instructions, when executed by the at least one processor, further cause the electronic device to display, in response to the loss of the at least a part of data included in the partial ledger, a notification of recovery of the block data.
9 . The electronic device of claim 1 , wherein the user node information is first user node information, and the instructions, when executed by the at least one processor, further cause the electronic device to, when executing a second smart contract for a second transaction in response to a request for generating the second transaction:
request second user node information associated with the second transaction from the external device,
receive the second user node information associated with the second transaction from the external device, and
generate a write-set to be stored in the memory through the second smart contract, based on the second user node information associated with the second transaction.
10 . The electronic device of claim 9 , wherein the write-set comprises data related to the second transaction and the second user node information associated with the second transaction.
11 . The electronic device of claim 9 , wherein the instructions, when executed by the at least one processor, further cause the electronic device to transfer, to the external device, second transaction data comprising the write-set and a read-set related to the execution of the second smart contract.
12 . The electronic device of claim 11 , wherein the instructions, when executed by the at least one processor, further cause the electronic device to:
receive an updating request for a block generated based on the second transaction data, and
store the generated block in the memory in response to the updating request.
13 . The electronic device of claim 1 ,
wherein a second block node is one of the at least one block node relating to the user,
wherein the user node information further comprises second node information about the second block node, and
wherein the instructions, when executed by the at least one processor, cause the electronic device to:
request the block data by requesting the block data associated with the first block node and the second block node from the external device, based on the user node information comprising the first node information and the second node information,
acquire the at least one block which is detected in the entire ledger based on the first node information and the second node information, by receiving the block data.
14 . A method for operating an electronic device constituting a first block node included in a blockchain network, the method comprising:
receiving, by the electronic device, a request for generating a first transaction;
executing, by the electronic device, a first smart contract for the first transaction in response to the request;
storing, in memory of the electronic device, a partial ledger comprising at least a part of an entire ledger for the blockchain network stored at an external device, wherein the external device stores node identification information about mapping between a plurality of users registered in the blockchain network and a plurality of block nodes registered with the plurality of users, and the entire ledger comprises at least one block comprising node information relating to at least one block node included in the blockchain network, the at least one block node having consented to block generation;
executing a smart contract for registering a user of the electronic device and the electronic device together in the blockchain network;
identifying, by the electronic device, that at least a part of data included in the partial ledger is lost; and
in response to a request for recovery of the at least a part of data:
requesting, by the electronic device, user node information about at least one block node registered with the user of the electronic device from the external device, wherein the at least one block node comprises the first block node, and the user node information comprises first node information about the first block node;
receiving, by the electronic device, the user node information acquired based on the node identification information stored in the external device;
requesting, by the electronic device, block data associated with the first block node from the external device, based on the user node information comprising the first node information about the first block node;
acquiring, by the electronic device, at least one block which is detected in the entire ledger based on the first node information, by receiving the block data from the external device; and
storing, by the electronic device, the acquired at least one block in the memory for the partial ledger.
15 . The method of claim 14 ,
wherein each of the at least one block comprises related block information, and
wherein the related block information comprises the node information and previous block information in the partial ledger.
16 . The method of claim 3 ,
wherein a smart contract is executed in response to initial execution of a blockchain-related operation by the electronic device, the smart contract being related to an initial operation, and
wherein the smart contract comprises a contract for registration of the user and the electronic device in the blockchain network through the smart contract related to the initial operation.
17 . The method of claim 14 , further comprising:
generating a security connection with the external device through a relay server; and
transmitting or receiving data through the security connection,
wherein the relay server generates a connection between devices for which verification of non-falsification is made.
18 . The method of claim 14 , further comprising:
providing a notification of recovery of the block data through an output device included in the electronic device in response to the loss of the at least a part of data included in the partial ledger.
19 . The method of claim 14 ,
wherein a second block node is one of the at least one block node relating to the user,
wherein the user node information further comprises second node information about the second block node,
wherein the requesting of the block data comprises:
requesting, by the electronic device, the block data associated with the first block node and the second block node from the external device, based on the user node information comprising the first node information and the second node information, and
wherein the acquiring the at least one block comprises:
acquiring, by the electronic device, the at least one block which is detected in the entire ledger based on the first node information and the second node information, by receiving the block data.