@@ -66,23 +66,10 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) {
6666CBlockTreeDB::CBlockTreeDB (size_t nCacheSize, bool fMemory , bool fWipe ) : CLevelDBWrapper(GetDataDir() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
6767}
6868
69- bool CBlockTreeDB::WriteBlockIndex (const CDiskBlockIndex& blockindex)
70- {
71- return Write (make_pair (' b' , blockindex.GetBlockHash ()), blockindex);
72- }
73-
74- bool CBlockTreeDB::WriteBlockFileInfo (int nFile, const CBlockFileInfo &info) {
75- return Write (make_pair (' f' , nFile), info);
76- }
77-
7869bool CBlockTreeDB::ReadBlockFileInfo (int nFile, CBlockFileInfo &info) {
7970 return Read (make_pair (' f' , nFile), info);
8071}
8172
82- bool CBlockTreeDB::WriteLastBlockFile (int nFile) {
83- return Write (' l' , nFile);
84- }
85-
8673bool CBlockTreeDB::WriteReindexing (bool fReindexing ) {
8774 if (fReindexing )
8875 return Write (' R' , ' 1' );
@@ -152,6 +139,18 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
152139 return true ;
153140}
154141
142+ bool CBlockTreeDB::WriteBatchSync (const std::vector<std::pair<int , const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo) {
143+ CLevelDBBatch batch;
144+ for (std::vector<std::pair<int , const CBlockFileInfo*> >::const_iterator it=fileInfo.begin (); it != fileInfo.end (); it++) {
145+ batch.Write (make_pair (' f' , it->first ), *it->second );
146+ }
147+ batch.Write (' l' , nLastFile);
148+ for (std::vector<const CBlockIndex*>::const_iterator it=blockinfo.begin (); it != blockinfo.end (); it++) {
149+ batch.Write (make_pair (' b' , (*it)->GetBlockHash ()), CDiskBlockIndex (*it));
150+ }
151+ return WriteBatch (batch, true );
152+ }
153+
155154bool CBlockTreeDB::ReadTxIndex (const uint256 &txid, CDiskTxPos &pos) {
156155 return Read (make_pair (' t' , txid), pos);
157156}
0 commit comments