Browse Source

Various crash fixes.

cl-refactor
Gav Wood 10 years ago
parent
commit
d1b1caea29
  1. 2
      alethzero/DownloadView.cpp
  2. 4
      libdevcore/RangeMask.h
  3. 2
      libethereum/BlockChain.cpp
  4. 4
      libp2p/Session.cpp

2
alethzero/DownloadView.cpp

@ -45,7 +45,7 @@ void DownloadView::paintEvent(QPaintEvent*)
double ratio = (double)rect().width() / rect().height();
if (ratio < 1)
ratio = 1 / ratio;
double n = min(rect().width(), rect().height()) / ceil(sqrt(m_man->chain().size() / ratio));
double n = min(16.0, min(rect().width(), rect().height()) / ceil(sqrt(m_man->chain().size() / ratio)));
// QSizeF area(rect().width() / floor(rect().width() / n), rect().height() / floor(rect().height() / n));
QSizeF area(n, n);

4
libdevcore/RangeMask.h

@ -95,6 +95,8 @@ public:
{
for (auto i = _m.first; i < _m.second;)
{
assert(i >= m_all.first);
assert(i < m_all.second);
// for each number, we find the element equal or next lower. this, if any, must contain the value.
auto uit = m_ranges.upper_bound(i);
auto it = uit == m_ranges.begin() ? m_ranges.end() : std::prev(uit);
@ -179,7 +181,7 @@ public:
}
std::pair<T, T> const& all() const { return m_all; }
void extendAll(T _max) { m_all.second = _max; }
void extendAll(T _max) { m_all.second = _max + 1; }
class const_iterator
{

2
libethereum/BlockChain.cpp

@ -437,7 +437,7 @@ void BlockChain::checkConsistency()
if (p != h256())
{
auto dp = details(p);
assert(contains(dp.children, h));
assert(contains(dp.children, h)); // WTF?
assert(dp.number == dh.number - 1);
}
}

4
libp2p/Session.cpp

@ -179,7 +179,8 @@ bool Session::interpret(RLP const& _r)
return false;
}
m_node = m_server->noteNode(id, bi::tcp::endpoint(m_socket.remote_endpoint().address(), listenPort), Origin::Self, false, m_node->id == id ? NodeId() : m_node->id);
m_node = m_server->noteNode(id, bi::tcp::endpoint(m_socket.remote_endpoint().address(), listenPort), Origin::Self, false, !m_node || m_node->id == id ? NodeId() : m_node->id);
m_knownNodes.extendAll(m_node->index);
m_knownNodes.unionWith(m_node->index);
if (m_protocolVersion != m_server->protocolVersion())
@ -233,6 +234,7 @@ bool Session::interpret(RLP const& _r)
s.appendList(3) << bytesConstRef(i.address.address().to_v4().to_bytes().data(), 4) << i.address.port() << i.id;
else// if (i.second.address().is_v6()) - assumed
s.appendList(3) << bytesConstRef(i.address.address().to_v6().to_bytes().data(), 16) << i.address.port() << i.id;
m_knownNodes.extendAll(i.index);
m_knownNodes.unionWith(i.index);
}
sealAndSend(s);

Loading…
Cancel
Save