Bitcoin Forum
December 03, 2016, 05:54:21 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Newbie questions from a programmer  (Read 1113 times)
oskar
Newbie
*
Offline Offline

Activity: 9


View Profile
February 15, 2011, 01:58:47 AM
 #1

I'm a hobbyist C++ programmer and spent some time going through Bitcoin's source code and absorbing whatever information I could find online about the protocol. I would really appreciate someone answering the few remaining questions I have.

1. How does the network decide when enough transactions have occurred for new block to be generated? Is it a hard-set number? On a related note, how do I know if I actually have all transactions in a given moment?

2. Once I successfully generate a block, how do I go about announcing this fact to the network? Is it a simple floodfill -- i.e., I send it to all my directly-connected neighbors, and they do the same, on and on until everyone gets it?

3. What happens if two people, Alice and Bob, generate a valid block at approximately the same time, and begin telling the network of their block simultaneously? Won't some nodes receive Alice's first, and some receive Bob's first? Who will ultimately be decided as the "winner"?
1480787661
Hero Member
*
Offline Offline

Posts: 1480787661

View Profile Personal Message (Offline)

Ignore
1480787661
Reply with quote  #2

1480787661
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480787661
Hero Member
*
Offline Offline

Posts: 1480787661

View Profile Personal Message (Offline)

Ignore
1480787661
Reply with quote  #2

1480787661
Report to moderator
genjix
Legendary
*
Offline Offline

Activity: 1232


View Profile
February 15, 2011, 02:50:39 AM
 #2

I'm a hobbyist C++ programmer and spent some time going through Bitcoin's source code and absorbing whatever information I could find online about the protocol. I would really appreciate someone answering the few remaining questions I have.

1. How does the network decide when enough transactions have occurred for new block to be generated? Is it a hard-set number? On a related note, how do I know if I actually have all transactions in a given moment?

2. Once I successfully generate a block, how do I go about announcing this fact to the network? Is it a simple floodfill -- i.e., I send it to all my directly-connected neighbors, and they do the same, on and on until everyone gets it?

3. What happens if two people, Alice and Bob, generate a valid block at approximately the same time, and begin telling the network of their block simultaneously? Won't some nodes receive Alice's first, and some receive Bob's first? Who will ultimately be decided as the "winner"?

1. block is generated when somebody finds the solution to a hard mathematical problem (finding a hash of the last block's header below the current difficulty). transactions are confirmed as they get put into the blocks.
2. yep.
3. they compete to have their block accepted by the network. the blockchain gets forked until one gets ahead of the other. it's a race to have your generated block incorporated into somebody elses next block.
theymos
Administrator
Legendary
*
Offline Offline

Activity: 2492


View Profile
February 15, 2011, 03:29:51 AM
 #3

Blocks are generated at a certain rate regardless of the number of transactions. Blocks can contain no real transactions.

Broadcasts are basically as you describe, though you actually only announce the hash of the item at first. Then the peer will request it if they don't already have it.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
oskar
Newbie
*
Offline Offline

Activity: 9


View Profile
February 15, 2011, 04:06:26 AM
 #4

transactions are confirmed as they get put into the blocks.
Blocks can contain no real transactions.
Thanks for your responses. These two quotes seem to suggest different things. My understanding was that blocks contained a hash of every transaction since the last block, and that these transactions weren't "official" until they become part of the block-chain in this way. Is this incorrect? If it's right, then what happens when I create a block that doesn't contain a certain transaction (because I didn't receive it)? Does it get lost in time and never is deemed official?
genjix
Legendary
*
Offline Offline

Activity: 1232


View Profile
February 15, 2011, 04:32:04 AM
 #5

the hash of the block doesn't include transactions. but the miner adds the transactions optionally. there's little overhead and it benefits the miners by adding value to bitcoin by establishing confidence in the currency.
theymos
Administrator
Legendary
*
Offline Offline

Activity: 2492


View Profile
February 15, 2011, 05:24:58 AM
 #6

If it's right, then what happens when I create a block that doesn't contain a certain transaction (because I didn't receive it)? Does it get lost in time and never is deemed official?

It gets in some later block.

The transactions in the block are hashed, though indirectly through the Merkle tree.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!