1

Imagine smart contract getting triggered by transaction and as result it sends another transaction. How is the code shall be executed? If each node will execute code there gonna be lots of same transactions with only possible difference in timestamp. So, how does this issue can be avoided?

Yuri Stiopin
  • 105
  • 10

1 Answers1

1

This is not quite the correct way to view transactions on the blockchain.

All of the nodes are competing to be the first to commit the block of transactions to the existing chain. Then ALL the other nodes receive that block and store it with the rest of their chain data.

Therefore, even if there are temporal differences between independent nodes, they are all still only storing the same transaction. And the record of transactions is made up of the sum total of all the chain data.

Also, transactions are not committed immediately when you submit them. They are placed into a list of pending transactions, along with their accompanying gas (transaction fee). Those transactions that sent along a higher accompanying fee will be selected for inclusion into the block being currently mined.

See this article for some explanations

trejas
  • 991
  • 7
  • 17
  • Yep. Now I get it. I just tried to think out of blockchain context and got stuck. Thanks) But, does each node execute contract or just miner ones? – Yuri Stiopin Jan 22 '18 at 05:08
  • My understand is that a node is that you can have a connected node for local submission of contracts and that node will forward received transactions to the miner nodes. Then the miner nodes will actually execute the contract code. Please, someone else correct me is that is wrong. – trejas Jan 22 '18 at 05:11