コード例 #1
0
ファイル: ledger.py プロジェクト: mikegogulski/caesure
 def save_state (self):
     from coro.asn1.data_file import DataFileWriter
     from __main__ import G
     save_path = os.path.join (G.args.base, self.save_path)
     f = open (save_path + '.tmp', 'wb')
     df = DataFileWriter (f)
     t0 = timer()
     df.write_object ([
         self.cache_version,
         self.height,
         str(self.block_name),
         self.total,
         self.lost,
         self.fees,
         len(self.outpoints)
     ])
     n = 0
     for item in self.outpoints:
         df.write_object (item)
         n += 1
         if n % 1000 == 999:
             coro.yield_slice()
     f.close()
     os.rename (save_path + '.tmp', save_path)
     W ('[saved outpoints %d/%d entries %.02fs]' % (len(self.outpoints), n, t0.end()))
コード例 #2
0
 def dump_metadata(self):
     from coro.asn1.data_file import DataFileWriter
     from __main__ import G
     LOG('saving metadata', 'start')
     t0 = timer()
     metadata_path = os.path.join(G.args.base, self.metadata_path)
     fileob = open(metadata_path + '.tmp', 'wb')
     df = DataFileWriter(fileob)
     version = 1
     df.write_object([version, len(self.blocks)])
     for a, pos in self.blocks.iteritems():
         df.write_object(
             [str(a), pos, self.block_num[a],
              str(self.prev[a])])
     fileob.close()
     os.rename(metadata_path + '.tmp', metadata_path)
     LOG('saving metadata', 'stop', t0.end())
コード例 #3
0
ファイル: block_db.py プロジェクト: fudong1127/caesure
 def dump_metadata (self):
     from coro.asn1.data_file import DataFileWriter
     from __main__ import G
     LOG ('saving metadata', 'start')
     t0 = timer()
     metadata_path = os.path.join (G.args.base, self.metadata_path)
     fileob = open (metadata_path + '.tmp', 'wb')
     df = DataFileWriter (fileob)
     version = 1
     df.write_object ([version, len(self.blocks)])
     for a, pos in self.blocks.iteritems():
         df.write_object (
             [str(a), pos, self.block_num[a], str(self.prev[a])]
         )
     fileob.close()
     os.rename (metadata_path + '.tmp', metadata_path)
     LOG ('saving metadata', 'stop', t0.end())
コード例 #4
0
ファイル: ledger.py プロジェクト: zhilinwww/caesure
 def save_state(self):
     from coro.asn1.data_file import DataFileWriter
     from __main__ import G
     save_path = os.path.join(G.args.base, self.save_path)
     f = open(save_path + '.tmp', 'wb')
     df = DataFileWriter(f)
     t0 = timer()
     df.write_object([
         self.cache_version, self.height,
         str(self.block_name), self.total, self.lost, self.fees,
         len(self.outpoints)
     ])
     n = 0
     for item in self.outpoints:
         df.write_object(item)
         n += 1
         if n % 1000 == 999:
             coro.yield_slice()
     f.close()
     os.rename(save_path + '.tmp', save_path)
     LOG('saved outpoints', len(self.outpoints), n, t0.end())