Putting a transaction in every block

GenoilGenoil 0xeb9310b185455f863f526dab3d245809f6854b4dMember Posts: 769 ✭✭✭
edited May 2015 in Smart Contracts and Dapps
I'm writing a compeltely pointless contract that has the sole purpose of at least putting a transaction into every block on the chain, while it is running. This is a part of the the javascript:

var checkNewBlock = function() { if(currentBlock != web3.eth.blockNumber) { currentBlock = web3.eth.blockNumber; console.log("adding some crap to block " + currentBlock); try { crapInstance.addCrap({from:from}); } catch(e) { currentBlock--; } } } setInterval(checkNewBlock, 1000);

This works great. Here's some of the output:

adding some crap to block 322707 adding some crap to block 322708 Error response: Known transaction (9f14133a) adding some crap to block 322708 adding some crap to block 322709 Error response: Known transaction (9f14133a) adding some crap to block 322709 adding some crap to block 322710 Error response: Known transaction (9f14133a) adding some crap to block 322710 adding some crap to block 322711 adding some crap to block 322712 adding some crap to block 322713 adding some crap to block 322714 adding some crap to block 322715 adding some crap to block 322716

Now I have two questions:

1. Why are there sometimes known transaction? what are they?
2. When I monitor the number of transactions on stats.ethdev.com, I still quite regularly see blocks with 0 transactions, while my script even re-attempts on failures (see the try/catch)

Comments

  • TalkingAntColonyTalkingAntColony Member Posts: 9
    It's hard to say without seeing all the code, but I don't think even sending a tx at every block guarantees it will be included in the next block.
  • GenoilGenoil 0xeb9310b185455f863f526dab3d245809f6854b4dMember Posts: 769 ✭✭✭
    well @TalkingAntColony that actually makes a lot of sense, thank you. as it currently is very quiet on the chain, I studied it again and found that on average, I still push one tx of crap to the chain:

    ok now for some more serious application ;)...
Sign In or Register to comment.