Add 'mempool' P2P command, and extend 'getdata' behavior
to permit downloading of mempool transactions from the remote peer.
Merge pull request #1641 from jgarzik/mempool

Add 'mempool' P2P command, and extend 'getdata' behavior
Set block.nVersion to fix miner unit test
Block height in coinbase as a new block rule

"Version 2" blocks are blocks that have nVersion=2 and
have the block height as the first item in their coinbase.
Block-height-in-the-coinbase is strictly enforced when
version=2 blocks are a supermajority in the block chain
(750 of the last 1,000 blocks on main net, 51 of 100 for
testnet). This does not affect old clients/miners at all,
which will continue producing nVersion=1 blocks, and
which will continue to be valid.
Reject block.nVersion<=1 blocks if network has upgraded to version=2

If 950 of the last 1,000 blocks are nVersion=2, reject nVersion=1
(or zero, but no bitcoin release has created block.nVersion=0) blocks
-- 75 of last 100 on testnet3.

This rule is being put in place now so that we don't have to go
through another "express support" process to get what we really
want, which is for every single new block to include the block height
in the coinbase.
When using SIGHASH_SINGLE, do not sign inputs that have no corresponding outputs.

This fixes issue #1688
Merge pull request #1526 from gavinandresen/heightincoinbase

Transition to requiring block height in block coinbases
Merge pull request #1689 from gavinandresen/rawtx_singlefix

When using SIGHASH_SINGLE, only sign inputs that have corresponding outputs
Compact serialization for variable-length integers

This commit introduces a new variable-length encoding for arbitrary integers.
They use a least-significant-digit-first base 128 encoding, where each byte
contains 7 bits of information, and one bit denoting whether another byte
follows. To avoid redundancy, however, all bytes except the first one
select a value in the range 1-128 instead of 0-127.

Thus, the byte sequence a[] where all but the last has bit 128 set, encodes
the number (a[0] & 0x7F) + sum(i=1..n, 128^i*((a[i] & 0x7F)+1)).
Compact serialization for variable-length integers: tests
Add CCoins: pruned list of transaction outputs

The CCoins class represents a pruned set of transaction outputs from
a given transaction. It only retains information about its height in
the block chain, whether it was a coinbase transaction, and its
unspent outputs (script + amount).

It has a custom serializer that has very low redundancy.
Compact serialization for scripts

Special serializers for script which detect common cases and encode
them much more efficiently. 3 special cases are defined:
* Pay to pubkey hash (encoded as 21 bytes)
* Pay to script hash (encoded as 21 bytes)
* Pay to pubkey starting with 0x02, 0x03 or 0x04 (encoded as 33 bytes)

Other scripts up to 121 bytes require 1 byte + script length. Above
that, scripts up to 16505 bytes require 2 bytes + script length.
Compact serialization for amounts

Special serializer/deserializer for amount values. It is optimized for
values which have few non-zero digits in decimal representation. Most
amounts currently in the txout set take only 1 or 2 bytes to
represent.
Compact serialization for amounts: tests

Test cases to verify the correctness of the custom amount serializer.
Add CTxUndo: transaction undo information

The CTxUndo class encapsulates data necessary to undo the effects of
a transaction on the txout set, namely the previous outputs consumed
by it (script + amount).
One file per block

Refactor of the block storage code, which now stores one file per block.
This will allow easier pruning, as blocks can be removed individually.
Preliminary undo file creation

Create files (one per block) with undo information for the transactions
in it.
Multiple blocks per file

Change the block storage layer again, this time with multiple files
per block, but tracked by txindex.dat database entries. The file
format is exactly the same as the earlier blk00001.dat, but with
smaller files (128 MiB for now).

The database entries track how many bytes each block file already
uses, how many blocks are in it, which range of heights is present
and which range of dates.
Pre-allocate block and undo files in chunks

Introduce a AllocateFileRange() function in util, which wipes or
at least allocates a given range of a file. It can be overriden
by more efficient OS-dependent versions if necessary.

Block and undo files are now allocated in chunks of 16 and 1 MiB,
respectively.
Do not store hashNext on disk

Instead of trusting the hashNest stored in the serialized CDiskBlockIndex
entries, use just the hashBestChain pointer to represent the active chain.

This means the block connection logic does not need to touch the block
index entries anymore, and will allow for easier separation of this database
in two independent parts (data about the block tree, and data about the
active chain).