Longer term workaround for chainstate corruption from negative versions.

This also makes negative transaction versions non-standard.

This avoids an issue triggered in Bitcoin block 256818 where transactions with
negative version numbers were incorrectly serialized into the UTXO set.

On restart nodes detect the inconsistency and refuse to start so long as
a block with these transactions is inside the self-consistency check
window, logging "coin database inconsistencies found". The software
recommends reindexing, but reindexing does not correct the problem.

This should be fixed by changing the chainstate serialization, but
working around it seems harmless for now because the version is not
used by any network rule currently.

A patch free workaround is to start with -checklevel=2 which skips
the consistency checks, but the IsStandard change is important for
miners in order to protect unpatched nodes.
Fix out-of-bounds check
Litecoin version 0.8.5.1
Merge pull request #69 from pooler/master-0.8

Use nChainWork in GetNetworkHashPS()
For getnetworkhashps, use min/max to calculate the block times.
Silence useless warning in src/json/json_spirit_writer_template.h to make important warnings easier to see.

warning: typedef ‘Char_type’ locally defined but not used [-Wunused-local-typedefs]
More fixes for blockchain corruption on OSX.

As we'd previously learned, OSX's fsync is a data eating lie.

Since 0.8.4 we're still getting some reports of disk corruption on
 OSX but now all of it looks like the block files have gotten out of
 sync with the database. It turns out that we were still using fsync()
 on the block files, so this isn't surprising.
Fix compiler warning for getnetworkhashps.
log start and end of Shutdown()

- could be helpful when debugging shutdown related problems

Rebased-by:   Warren Togami <wtogami@gmail.com>
Rebased-from: ced3c248168941fbbd42d5a3807657a88be6a54e
exclude CreatePidFile() function on WIN32 as it is unused
Hurricane Electric uses block 2001:470::, not 2011:470::
Porting MinGW multithreading bugfix to makefile.mingw

Original fix:
https://github.com/bitcoin/bitcoin/commit
/8864019f6d88b13d3442843d9e6ebeb8dd938831
special case DoS value == 0 in ProcessMessage()

- prevents unneeded log messages, which could make users think something
  bad was happening

Squashed: style-police code cleanup
Don't store or send blocks forked before last checkpoint.
Enable NODE_BLOOM by default

Also change behavior to simply disconnect peers, rather than DoS-ban
them.
Litecoin: Add a simplified SSE2 version of scrypt

pooler: Ported from tarsnap upstream, fixed aliasing issue
cfields: break apart sse2/non-sse2 into separate objects
Litecoin: Runtime detection of SSE2 32bit x86 for Scrypt

* x86_64 and Intel MacOS X always uses scrypt-sse2, non-x86 uses scrypt-generic.
* x86 (not Mac) detects cpuid features and chooses sse2 or generic during runtime.

How to Build with SSE2 Support
==============================
* make litecoind with USE_SSE2=1
* qmake with USE_SSE2=1
Litecoin: Upgrade gitian win32 to Precise 12.04 and boost-1.54

mingw upgrade allows more hardening, compiler bug fixes and possibily win64 later.
Rename deps .zip files to be more consistent in revision format.

Litecoin: Reuse bitcoin-0.9 win32 deps.
Litecoin: SSE2 scrypt unit test coverage
Litecoin: Restore USE_BUILD_INFO=1 in gitian-win32.yml