Merge #10279: Add a CChainState class to validation.cpp to take another step towards...
commit214046f69b1978129030ba1f65007d57b29f0761
authorWladimir J. van der Laan <laanwj@gmail.com>
Tue, 12 Dec 2017 13:06:45 +0000 (12 14:06 +0100)
committerWladimir J. van der Laan <laanwj@gmail.com>
Tue, 12 Dec 2017 13:36:57 +0000 (12 14:36 +0100)
tree273c8f076b9e9d5678e74bb4af88139f5953adc5
parentad1820cbad15c4eb4e2c86ac8032d0fb1b7b7c35
parent22fdddeabb17881af2004c45538f91514837d363
Merge #10279: Add a CChainState class to validation.cpp to take another step towards clarifying internal interfaces

22fddde Avoid calling GetSerializeSize on each tx in a block if !fTxIndex (Matt Corallo)
2862aca Move some additional variables into CChainState private (Matt Corallo)
fd4d80a Create initial CChainState to hold chain state information (Matt Corallo)
e104f0f Move block writing out of AcceptBlock (Matt Corallo)
50701ba Move txindex/undo data disk location stuff out of ConnectBlock (Matt Corallo)
93a34cf Make DisconnectBlock unaware of where undo data resides on disk (Matt Corallo)

Pull request description:

  CChainState should eventually, essentially, be our exposed "libconsensus", but we're probably a few releases away, so the real goal is to clarify our internal interfaces. The main split was a big step, but validation.cpp is still a somewhat ranomly-mixed bag of functions that are pure functions which validate inputs (which should probably either merge with their callers or move into another file in consensus/), read/write data from disk, manipulate our current chain state (which moves into CChainState), and do mempool transaction validation.

  Obviously this is only a small step, but some effort is made to clean up what functions the functions in CChainState call, and obviously as things are added its easy to keep clear "CChainState::* cannot call anything except via callbacks through CValidationInterface, pure functions, or disk read/write things". Right now there are some glaring violations in mempool callbacks, and general flushing logic needs cleaning up (FlushStateToDisk maybe shouldnt be called, and there should be an API towards setDirtyBlockIndex, but I'll leave that for after @sipa's current changesets land).

Tree-SHA512: 69b8ec191b36b19c9492b4dee74c8057621fb6ec98ad219e8da0b2ed5c3ad711b10b5af9ff1117e8807ccf88918eeeab573be8448baecc9a59f099c53095985b
src/validation.cpp
src/validation.h