auto backing up of wallet.dat
I started posting in the other topic but I’ll repeat here, this thread seems more specific to the topic.
The main backup improvement will be a pre-generated pool of keys and a rescan at load to scrape missed transactions from the block history. Then a backup will last forward for a long time.
I was starting to post the same idea you said nelisky.
How about a json-rpc command that locks the wallet, flushes it, copies wallet.dat to a location you specified, then unlocks it? That would be a smaller project than the pooled keys, so maybe it could be done first.
What’s the simplest portable way to copy a file? Is there something in Boost?
What should it be named? maybe:
backupwallet
If you read it into memory and write it out, it could fail in tight memory situations.
I’m looking for something like copyfile(const char* from, const char* to) or copyfile(path from, path to), preferably something in Boost if it has it. If you find it for me, it’s more likely I’ll get to implementing it.
Quote from: nelisky on August 26, 2010, 01:21:57 AMAs for the file copy, why add to the boost dependency? I for one would love to get a core lib with very little deps. We require Boost for JSON and a dozen things replacing dependencies on wxWidgets. Boost is good, portable stuff, we should not shy away from it.
I doubt there’s an mmap(2) on Windows. I’d rather call an existing file copy function than make and test my own.
Quote from: nelisky on August 27, 2010, 01:21:09 AMBut if you are already using features from boost::filesystem you can use copy_file from that. I just think that, if not already required for something else, it’s a tad overkill. Thanks. I thought it would be in there somewhere.
We already use boost::filesystem in a dozen places. It’s not a new added dependency. It gives us a lot of portable stuff that we would otherwise have to have a #ifdef for each OS and test everywhere.
Sorry, I’ve been so busy lately I’ve been skimming messages and I still can’t keep up.
We want to avoid Windows API calls whenever possible. They usually take about 6-8 parameters and a lot of testing to get right, it takes a page of code to do something simple.
I usually shy away from iostreams. Seems like I too often hit limitations. They kind of botched the C++ streams standard in the 90’s, which is too bad, streams can be very powerful and useful when done right. Using it in rpc.cpp may still turn out to be a mistake.
Bottom line is I’d rather call an existing file copy function than make and test my own.
rpc backupwallet