Subject: Re: [Bitcoin-development] overall bitcoin client code quality

From: Andy Parkins <[email-masked]>
Date: Wed, 13 Jul 2011 14:04:09 +0100

On 2011 July 13 Wednesday, Mike Hearn wrote:
> For what it's worth, BitCoinJ has a NetworkParameters abstraction that
> does what you suggest (groups all the constants together):

"all" is a strong word :-)

I'm doing a similar thing, and so far I have (and it's definitely incomplete) 
the following for these magic-constants that are often literals in the offical 
client:

	TBlock *GenesisBlock;
	TBitcoinHash ProofOfWorkLimit;
	uint16_t DefaultTCPPort;
	uint32_t Magic;
	uint8_t BitcoinAddressPrefix;

	unsigned int COINBASE_MATURITY;
	unsigned int COINBASE_MINIMUM_SCRIPT_SIZE;
	unsigned int COINBASE_MAXIMUM_SCRIPT_SIZE;
	unsigned int MAX_BLOCK_SIZE;
	unsigned int MAX_BLOCK_SIZE_GEN;
	unsigned int MAX_BLOCK_SIGOPS;
	unsigned int MINIMUM_TRANSACTION_SIZE;
	TCoinsElement MIN_MONEY;
	TCoinsElement MAX_MONEY;
	TCoinsElement MIN_TX_FEE;

	TCoinsElement INITIAL_MINING_REWARD;
	unsigned int INFLATION_PERIOD;

	unsigned int BLOCK_TIMESTAMP_WINDOW;
	unsigned int DIFFICULTY_TIMESPAN;
	unsigned int NEW_BLOCK_PERIOD;

	unsigned int INV_MAX;
	unsigned int GETDATA_MAX;
	unsigned int GETBLOCKS_RESPONSES_MAX;
	unsigned int GETHEADERS_RESPONSES_MAX;
	unsigned int ADDR_MAX;
	unsigned int ADDR_MIN_TIME;
	unsigned int ADDR_MAX_TIME_OFFSET;
	unsigned int ADDR_DEFAULT_TIME_PENALTY;
	unsigned int ASSUME_OFFLINE_AFTER;
	unsigned int OFFLINE_UPDATE_INTERVAL;
	unsigned int ONLINE_UPDATE_INTERVAL;

	map<unsigned int, TBitcoinHash> Checkpoints;

	static const TBitcoinHash NULL_REFERENCE_HASH;
	static const unsigned int NULL_REFERENCE_INDEX;

Any suggestions for others gratefully received.

Andy

-- 
Dr Andy Parkins
[email-masked]