Split off RPCHandler::lookupLedger as a pure function.

* Also correct guard on RPCHandler.h