MCPcopy Create free account
hub / github.com/LUX-Core/lux / commit

Method commit

src/cpp-ethereum/libdevcore/OverlayDB.cpp:47–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45};
46
47void OverlayDB::commit()
48{
49 if (m_db)
50 {
51 ldb::WriteBatch batch;
52// cnote << "Committing nodes to disk DB:";
53#if DEV_GUARDED_DB
54 DEV_READ_GUARDED(x_this)
55#endif
56 {
57 for (auto const& i: m_main)
58 {
59 if (i.second.second)
60 batch.Put(ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.first.data(), i.second.first.size()));
61// cnote << i.first << "#" << m_main[i.first].second;
62 }
63 for (auto const& i: m_aux)
64 if (i.second.second)
65 {
66 bytes b = i.first.asBytes();
67 b.push_back(255); // for aux
68 batch.Put(bytesConstRef(&b), bytesConstRef(&i.second.first));
69 }
70 }
71
72 for (unsigned i = 0; i < 10; ++i)
73 {
74 ldb::Status o = m_db->Write(m_writeOptions, &batch);
75 if (o.ok())
76 break;
77 if (i == 9)
78 {
79 cwarn << "Fail writing to state database. Bombing out.";
80 exit(-1);
81 }
82 cwarn << "Error writing to state database: " << o.ToString();
83 WriteBatchNoter n;
84 batch.Iterate(&n);
85 cwarn << "Sleeping for" << (i + 1) << "seconds, then retrying.";
86 this_thread::sleep_for(chrono::seconds(i + 1));
87 }
88#if DEV_GUARDED_DB
89 DEV_WRITE_GUARDED(x_this)
90#endif
91 {
92 m_aux.clear();
93 m_main.clear();
94 }
95 }
96}
97
98bytes OverlayDB::lookupAux(h256 const& _h) const
99{

Callers

nothing calls this directly

Calls 13

asBytesMethod · 0.80
DEV_READ_GUARDEDFunction · 0.50
SliceClass · 0.50
DEV_WRITE_GUARDEDFunction · 0.50
PutMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
WriteMethod · 0.45
okMethod · 0.45
ToStringMethod · 0.45
IterateMethod · 0.45

Tested by

no test coverage detected