Bitcoin Forum
May 02, 2024, 02:47:36 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Satoshi Bitcoin client variable explanation in main.h (Bitcoin Pseudocode Client  (Read 2387 times)
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
November 02, 2012, 07:34:03 AM
Merited by ABCbits (1)
 #1

This is for research for the Bitcoin Pseudocode Client project where we attempt at making the Bitcoin client in multiple lanaguages with complete documentation and proccesses on everything in everylanguage, so Bitcoin speaks to Every developer, I'm doing this for free so every little bit helps (Link to project: https://github.com/Xenland/Bitcoin-Pseudocode-Client/tree/gh-pages)

My question to you is... Does anyone know what the following variables are for in main.h?
I just know what MAX_MONEY is the 21 million hard limit but I can't find the COIN variable(but i assume it is the value of 100000000 for converting to satoshi) in any of the bitcoin source files(how do devs usual search for variables globally through a project?)

I'm guessing MAX_BLOCK_SIZE is the amount of transactions in one block but in what units i wonder? (kilobyte limit?, tx limit?, etc)
What is max orphan transactions? why even have a max orphans? why not just toss'em?

Quote
static const unsigned int MAX_BLOCK_SIZE = 1000000;
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
static const unsigned int MAX_INV_SZ = 50000;
static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
static const unsigned int MEMPOOL_HEIGHT = 0x7FFFFFFF;
static const int64 MIN_TX_FEE = 50000;
static const int64 MIN_RELAY_TX_FEE = 10000;
static const int64 MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
static const int COINBASE_MATURITY = 100;
// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov  5 00:53:20 1985 UTC

Thank you everyone!
1714661256
Hero Member
*
Offline Offline

Posts: 1714661256

View Profile Personal Message (Offline)

Ignore
1714661256
Reply with quote  #2

1714661256
Report to moderator
1714661256
Hero Member
*
Offline Offline

Posts: 1714661256

View Profile Personal Message (Offline)

Ignore
1714661256
Reply with quote  #2

1714661256
Report to moderator
Even in the event that an attacker gains more than 50% of the network's computational power, only transactions sent by the attacker could be reversed or double-spent. The network would not be destroyed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714661256
Hero Member
*
Offline Offline

Posts: 1714661256

View Profile Personal Message (Offline)

Ignore
1714661256
Reply with quote  #2

1714661256
Report to moderator
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
November 02, 2012, 08:24:49 AM
 #2

Not sure how you missed this but:

Code:
[main.h]
...
static const int64 COIN = 100000000;
...
static const int64 MAX_MONEY = 21000000 * COIN;

to find such symbols (assuming they are in .h files) simply:
Code:
grep COIN *.h

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
November 02, 2012, 10:16:49 AM
Merited by ABCbits (6)
 #3

static const unsigned int MAX_BLOCK_SIZE = 1000000;
Maximum size of a block in bytes, as specified by network rules.

Quote
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
Maximum size of a block that will be generated.

Quote
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
Maximum number of signature checking operations in a block, as specified by network rules

Quote
static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
Maximum number of orphan transactions kept in memory; old ones are deleted when this number is exceeded

Quote
static const unsigned int MAX_INV_SZ = 50000;
Maximum number of entries in an "inv" protocol message

Quote
static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
Maximum size of a block file (new in 0.8 )

Quote
static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
Size of preallocation chunks in block files (new in 0.8 )

Quote
static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
Size of preallocation chunks in undo files (new in 0.8 )

Quote
static const unsigned int MEMPOOL_HEIGHT = 0x7FFFFFFF;
Special height in CCoins to mark origin is mempool (memory only) (new in 0.8 )

Fees below this (in satoshi) are considered zero fee for purposes of block/tx creation
Quote
static const int64 MIN_TX_FEE = 50000;

Quote
static const int64 MIN_RELAY_TX_FEE = 10000;
Fees below this (in satoshi) are considered zero fee for purposes of relaying

Quote
static const int64 MAX_MONEY = 21000000 * COIN;
Maximum amount (in satoshi) allowed anywhere. COIN is equal to 10^8

Quote
static const int COINBASE_MATURITY = 100;
Coinbase transactions cannot be spent before this number of confirms


I do Bitcoin stuff.
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
November 02, 2012, 10:56:59 PM
 #4

Not sure how you missed this but:

Code:
[main.h]
...
static const int64 COIN = 100000000;
...
static const int64 MAX_MONEY = 21000000 * COIN;

to find such symbols (assuming they are in .h files) simply:
Code:
grep COIN *.h


That literately does not exist on main.h so I'm not sure which source code you are referring to.
Infact the integer 100000000 isn't even found on main.h on the github page https://github.com/bitcoin/bitcoin/blob/master/src/main.h
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
November 02, 2012, 11:04:45 PM
 #5

COIN is defined in util.h, apparently. I assume because it's necessary for formatting amounts.

I do Bitcoin stuff.
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
November 02, 2012, 11:16:30 PM
 #6

i've submitted a pull request with comments for all those constants.

I do Bitcoin stuff.
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
November 03, 2012, 01:17:34 AM
 #7

Great stuff thanks everyone for the help, That's one step closer to compiling all this information together.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
November 03, 2012, 02:43:09 AM
 #8

That literately does not exist on main.h so I'm not sure which source code you are referring to.
Infact the integer 100000000 isn't even found on main.h on the github page https://github.com/bitcoin/bitcoin/blob/master/src/main.h

Oops - I was looking at the source code on my own computer (so not up to date).

Guess there has been some reorg work done on the headers.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1024



View Profile
November 03, 2012, 05:03:33 AM
 #9

i've submitted a pull request with comments for all those constants.

Just out of curiosity, has MAX_BLOCK_SIGOPS always been defined as a fraction of the block size?  From the P2SH debates, I remember the number 20,000 which is what you get when you perform the division, but I don't remember the division.  And as I recall, it was somewhat important, as a change to it could potentially cause a hardfork.  And I can't find any documentation on it other than the source code, so I was wondering...

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
November 03, 2012, 05:04:28 PM
 #10

i've submitted a pull request with comments for all those constants.

Just out of curiosity, has MAX_BLOCK_SIGOPS always been defined as a fraction of the block size?  From the P2SH debates, I remember the number 20,000 which is what you get when you perform the division, but I don't remember the division.  And as I recall, it was somewhat important, as a change to it could potentially cause a hardfork.  And I can't find any documentation on it other than the source code, so I was wondering...

Does that matter? Any change to MAX_BLOCK_SIGOPS or MAX_BLOCK_SIZE has hardforking risks - making one dependent on the other does not change that.

I do Bitcoin stuff.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!