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! // Check block doesn't already exist first!
if (details(newHash)) if (details(newHash))
{ {
clog(BlockChainChat) << newHash << ": Not new."; clog(BlockChainNote) << newHash << ": Not new.";
throw AlreadyHaveBlock(); throw AlreadyHaveBlock();
} }
@ -166,11 +166,19 @@ void BlockChain::import(bytes const& _block, Overlay const& _db)
auto pd = details(bi.parentHash); auto pd = details(bi.parentHash);
if (!pd) 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. // 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(); 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 << "..."; clog(BlockChainNote) << "Attempting import of " << newHash << "...";
u256 td; u256 td;

1
libethereum/BlockChain.h

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

Loading…
Cancel
Save