Browse Source

Date fix.

cl-refactor
Gav Wood 11 years ago
parent
commit
b52b629c01
  1. 12
      libethereum/BlockChain.cpp
  2. 1
      libethereum/BlockChain.h

12
libethereum/BlockChain.cpp

@ -158,7 +158,7 @@ void BlockChain::import(bytes const& _block, Overlay const& _db)
// Check block doesn't already exist first!
if (details(newHash))
{
clog(BlockChainChat) << newHash << ": Not new.";
clog(BlockChainNote) << newHash << ": Not new.";
throw AlreadyHaveBlock();
}
@ -166,11 +166,19 @@ void BlockChain::import(bytes const& _block, Overlay const& _db)
auto pd = details(bi.parentHash);
if (!pd)
{
clog(BlockChainChat) << newHash << ": Unknown parent " << bi.parentHash;
clog(BlockChainNote) << newHash << ": Unknown parent " << bi.parentHash;
// We don't know the parent (yet) - discard for now. It'll get resent to us if we find out about its ancestry later on.
throw UnknownParent();
}
// Check it's not crazy
if (bi.timestamp > (u256)time(0))
{
clog(BlockChainNote) << newHash << ": Future time " << bi.timestamp << " (now at " << time(0) << ")";
// We don't know the parent (yet) - discard for now. It'll get resent to us if we find out about its ancestry later on.
throw FutureTime();
}
clog(BlockChainNote) << "Attempting import of " << newHash << "...";
u256 td;

1
libethereum/BlockChain.h

@ -58,6 +58,7 @@ class Overlay;
class AlreadyHaveBlock: public std::exception {};
class UnknownParent: public std::exception {};
class FutureTime: public std::exception {};
struct BlockChainChat: public LogChannel { static const char* name() { return "-B-"; } static const int verbosity = 7; };
struct BlockChainNote: public LogChannel { static const char* name() { return "=B="; } static const int verbosity = 4; };

Loading…
Cancel
Save