Short-circuit bloom checking if we will always return true.

This allows full nodes to use bloom filters as an optimization.
Merge pull request #2338 from TheBlueMatt/bloom

Short-circuit bloom checking if we will always return true.
P2P: parse network datastream into header/data components in socket thread

Replaces CNode::vRecv buffer with a vector of CNetMessage's.  This simplifies
ProcessMessages() and eliminates several redundant data copies.

Overview:

* socket thread now parses incoming message datastream into
  header/data components, as encapsulated by CNetMessage
* socket thread adds each CNetMessage to a vector inside CNode
* message thread (ProcessMessages) iterates through CNode's CNetMessage vector

Message parsing is made more strict:

* Socket is disconnected, if message larger than MAX_SIZE
  or if CMessageHeader deserialization fails (latter is impossible?).
  Previously, code would simply eat garbage data all day long.
* Socket is disconnected, if we fail to find pchMessageStart.
  We do not search through garbage, to find pchMessageStart.  Each
  message must begin precisely after the last message ends.

ProcessMessages() always processes a complete message, and is more efficient:

* buffer is always precisely sized, using CDataStream::resize(),
  rather than progressively sized in 64k chunks.  More efficient
  for large messages like "block".
* whole-buffer memory copy eliminated (vRecv -> vMsg)
* other buffer-shifting memory copies eliminated (vRecv.insert, vRecv.erase)
P2P, cosmetic: break out buffer send(2) code into separate function
P2P: improve RX/TX flow control

1) "optimistic write": Push each message to kernel socket buffer immediately.

2) If there is write data at select time, that implies send() blocked
   during optimistic write.  Drain write queue, before receiving
   any more messages.

This avoids needlessly queueing received data, if the remote peer
is not themselves receiving data.

Result: write buffer (and thus memory usage) is kept small, DoS
potential is slightly lower, and TCP flow control signalling is
properly utilized.

The kernel will queue data into the socket buffer, then signal the
remote peer to stop sending data, until we resume reading again.
fix netmsg
Add speedup for sig verification based on secp256k1.
Some optimizations for Hal's secp256k1 verifier
Precalculate P, N and G*lambda in CSecp256k1Consts
Refactor secp256k1 ECDSA verify code to mimic generic version
Allow verification of optimized secp256k1 code
Implement Hal's suggestion for a faster G split
Build test objects separately
Rework the clients thread priority handling

- removes SetThreadPriority() and integrates that into NewThread() with a
  default of THREAD_PRIORITY_NORMAL
- removes special-casing (priority switching) for internal Bitcoin miner
- uses a new default for the following threads: ThreadScriptCheck (below
  normal - because normal prio threads on every CPU core could slowdown UX),
  ThreadImport (above normal - to speed it up a little) and
  ThreadBitcoinMiner (below normal - to compensate the removed special
  casing)
- removes thread priority code for non-Windows OSes, so these will just
  get a no-op
Fix getbalance discrepency

Two changes:

Use IsConfirmed() instead of IsFinal(), so 'getbalance "*" 0' uses the same
'is this output spendable' criteria as 'getbalance'. Fixes issue #172.

And a tiny refactor to CWallet::GetBalance() (redundant call to IsFinal -- IsConfirmed
calls IsFinal).
getbalance with no arguments and 'getbalance "*" 0' could return different different results,
Refactor CheckSig (prep for OP_CHECKMULTISIG optimization)
Unit test: OP_CHECKMULTISIG multiple signatures with different hash types
OP_CHECKMULTISIG signature hash optimization

Rework OP_CHECKMULTISIG so each OP_CHECKMULTISIG only
hashes the transaction once for each different SIGHASH_ type.
add address and account information to listunspent
remove duplicate bitdb.Open() code from init

- remove code from step 7, which we already have in step 5 of init