Electronic device included in blockchain network and method for operating the same
An electronic device is provided. The electronic device includes a communication circuit, memory storing one or more computer programs, and one or more processors communicatively coupled to the communication circuit and the memory. The one or more computer programs include computer-executable instructions that, when executed by the one or more processors, cause the electronic device to transmit a request, through the communication circuit a server configured to relay message transmission between nodes included in a blockchain network, to add a new block to the nodes included in the blockchain network, when the request is not rejected by the server, transmit, through the communication circuit to the server for transmission to the nodes via the server, transaction information to be stored in the new block, generate the new block including the transaction information, receive, through the communication circuit from the server, information about blocks generated by first nodes in an active state among the nodes, based on identifying that a number of blocks identical to the new block among the blocks generated by the first nodes is greater than a designated number, transmit, through the communication circuit to the server, information indicating agreement on adding the new block, and based on the transmitting, to the server, of the information indicating the agreement, add the new block to the memory.
1 . An electronic device for implementing a node for use as one of a plurality of nodes included in a blockchain network that includes other nodes different from the node, the electronic device for implementing the node comprising:
a communication circuit;
memory storing one or more computer programs; and
one or more processors communicatively coupled to the communication circuit and the memory,
wherein the one or more computer programs include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device for implementing the node to:
prior to transmitting a request to add a new block to the plurality of nodes included in the blockchain network,
access a server, through the communication circuit, to obtain information about a block last stored in each of the other nodes, the server being configured to store and update respective information about a block last stored in each of the plurality of nodes, and relay transmission between the plurality of nodes, and
identify, based on the obtained information about the block last stored in each of the other nodes, whether a block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes match,
based on identifying that the block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes match, transmit the request, through the communication circuit to the server, to add the new block to the plurality of nodes,
based on the request being not rejected by the server, transmit, through the communication circuit to the server for relay transmission to the other nodes via the server, transaction information to be stored in the new block,
generate the new block including the transaction information,
receive, through the communication circuit from the server, information about blocks generated by first nodes in an active state among the other nodes,
based on identifying that a number of blocks identical to the new block among the blocks generated by the first nodes is greater than a designated number, transmit, through the communication circuit to the server, information indicating agreement on adding the new block, and
based on the transmitting, to the server, of the information indicating the agreement, add the new block to the memory.
2 . The electronic device for implementing the node of claim 1 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device for implementing the node to:
access the server, through the communication circuit, to identify information about a state of each of the other nodes.
3 . The electronic device for implementing the node of claim 1 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device for implementing the node to:
based on identifying that the block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes do not match, transmit, through the communication circuit to the server, a request for synchronization of the block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes so as to have the block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes match.
4 . The electronic device for implementing the node of claim 3 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device for implementing the node to:
based on identifying that a number of a block last stored in the electronic device for implementing the node is smaller than a number of a block last stored in another node in the active state among the other nodes, receive, through the communication circuit from the server, information about the block last stored in the another node; and
update, in the memory, the block last stored in the electronic device for implementing the node based on the received information.
5 . The electronic device for implementing the node of claim 1 , wherein the transaction information is transmitted, through the communication circuit to the server, based on identifying that a number of the first nodes is greater than a designated number.
6 . The electronic device for implementing the node of claim 1 , wherein, when a task of adding a block requested by another node among the other nodes is to be completed by the server before acting on the request to add the new block, the request to add the new block is rejected by the server.
7 . The electronic device for implementing the node of claim 1 , wherein, when the request to add the new block is consecutively transmitted a designated number of times for a designated time, the request to add the new block is rejected by the server.
8 . The electronic device for implementing the node of claim 1 , wherein, when a number of the first nodes is greater than a designated number, an agreement condition for adding the new block to the plurality of nodes is met.
9 . The electronic device for implementing the node of claim 8 , wherein the designated number is determined to be smaller than a majority of the plurality of nodes.
10 . A method performed by an electronic device for implementing a node for use as one of a plurality of nodes included in a blockchain network that includes other nodes different from the node, the method comprising:
prior to transmitting a request to add a new block to the plurality of nodes included in the blockchain network,
accessing a server, through a communication circuit included in the electronic device for implementing the node, to obtain information about a block last stored in each of the other nodes, the server being configured to store and update respective information about a block last stored in each of the plurality of nodes, and relay transmission between the plurality of nodes, and
identifying, based on the obtained information about the block last stored in each of the other nodes, whether a block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes match;
based on identifying that the block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes match, transmitting the request, through the communication circuit to the server, to add the new block to the plurality of nodes;
based on the request being not rejected by the server, transmitting, through the communication circuit to the server for relay transmission to the other nodes via the server, transaction information to be stored in the new block;
generating the new block including the transaction information;
receiving, through the communication circuit from the server, information about blocks generated by first nodes in an active state among the other nodes;
based on identifying that a number of blocks identical to the new block among the blocks generated by the first nodes is greater than a designated number, transmitting, through the communication circuit to the server, information indicating agreement on adding the new block; and
based on the transmitting to the server, of the information indicating the agreement, adding the new block to memory included in the electronic device for implementing the node.
11 . The method of claim 10 , further comprising:
accessing the server, through the communication circuit, to identify information about a state of each of the other nodes.
12 . The method of claim 10 , further comprising:
based on identifying that the block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes do not match, transmitting, through the communication circuit to the server, a request for synchronization of the block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes so as to have the block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes match.
13 . The method of claim 12 , further comprising:
based on identifying that a number of a block last stored in the electronic device for implementing the node is smaller than a number of a block last stored in another node among the other nodes, receiving, through the communication circuit from the server, information about the block last stored in the another node; and
updating, in the memory, the block last stored in the electronic device for implementing the node based on the received information.
14 . The method of claim 10 , wherein, when a task of adding a block requested by another node among the other nodes is to be completed by the server before acting on the request to add the new block, the request to add the new block is rejected by the server.
15 . The method of claim 10 , wherein, when the request to add the new block is consecutively transmitted a designated number of times for a designated time, the request to add the new block is rejected by the server.
16 . The method of claim 10 , wherein, when a number of the first nodes is greater than a designated number, an agreement condition for adding the new block to the plurality of nodes is met.
17 . The method of claim 16 , wherein the designated number is determined to be smaller than a majority of the plurality of nodes.
18 . One or more non-transitory computer-readable storage media storing one or more computer programs including computer-executable instructions that, when executed individually or collectively by one or more processors individually or collectively of an electronic device for implementing a node for use as one of a plurality of nodes included in a blockchain network that includes other nodes different from the node, cause the electronic device for implementing the node to perform operations, the operations comprising:
prior to transmitting a request to add a new block to the plurality of nodes included in the blockchain network,
accessing a server, through a communication circuit included in the electronic device for implementing the node, to obtain information about a block last stored in each of the other nodes, the server being configured to store and update respective information about a block last stored in each of the plurality of nodes, and relay transmission between the plurality of nodes, and
identifying, based on the obtained information about the block last stored in each of the other nodes, whether a block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes match;
based on identifying that the block last stored in the electronic device for implementing the node and the block last stored in each of the other nodes match, transmitting the request, through the communication circuit to the server, to add the new block to the plurality of nodes;
based on the request being not rejected by the server, transmitting, through the communication circuit to the server for relay transmission to the other nodes via the server, transaction information to be stored in the new block;
generating the new block including the transaction information;
receiving, through the communication circuit from the server, information about blocks generated by first nodes in an active state among the other nodes;
based on identifying that a number of blocks identical to the new block among the blocks generated by the first nodes is greater than a designated number, transmitting, through the communication circuit to the server, information indicating agreement on adding the new block; and
based on the transmitting, to the server, of the information indicating the agreement, adding the new block to memory included in the electronic device for implementing the node.