Skip to content

Commit

Permalink
Merge branch 'groovy_gluon_7.3RC' into mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
valdok committed May 8, 2023
2 parents 1b03f16 + 558fd6c commit 3c8e190
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
42 changes: 42 additions & 0 deletions node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,48 @@ void Node::Processor::FlushDB()
}
}

void Node::Processor::OnInvalidBlock(const Block::SystemState::Full& s, const Block::Body& block)
{
if (!get_ParentObj().m_Miner.IsEnabled())
return;

// format path
std::string sPath = get_ParentObj().m_Cfg.m_sPathLocal;
{
for (uint32_t i = (uint32_t) sPath.size(); ; )
{
if (!i--)
{
sPath.clear();
break;
}

if (('/' == sPath[i]) || ('\\' == sPath[i]))
{
sPath.resize(i + 1);
break;
}
}

Merkle::Hash hv;
s.get_Hash(hv);

std::ostringstream os;
os << s.m_Height << '-' << hv << ".inv_block";
sPath += os.str();
}

std::FStream fs;
if (fs.Open(sPath.c_str(), false))
{
Serializer ser;
ser & s;
ser & block;

fs.write(ser.buffer().first, ser.buffer().second);
}
}

Node::Peer* Node::AllocPeer(const beam::io::Address& addr)
{
Peer* pPeer = new Peer(*this);
Expand Down
1 change: 1 addition & 0 deletions node/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ struct Node
void OnDummy(const CoinID&, Height) override;
void InitializeUtxosProgress(uint64_t done, uint64_t total) override;
Height get_MaxAutoRollback() override;
void OnInvalidBlock(const Block::SystemState::Full&, const Block::Body&) override;
void Stop();

struct MyExecutorMT
Expand Down
5 changes: 4 additions & 1 deletion node/processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2940,7 +2940,7 @@ bool NodeProcessor::HandleBlock(const NodeDB::StateID& sid, const Block::SystemS
if (s.m_Kernels != ev.m_hvKernels)
{
LOG_WARNING() << LogSid(m_DB, sid) << " Kernel commitment mismatch";
return false;
bOk = false;
}
}

Expand All @@ -2962,6 +2962,8 @@ bool NodeProcessor::HandleBlock(const NodeDB::StateID& sid, const Block::SystemS
{
bic.m_Fwd = false;
BEAM_VERIFY(HandleValidatedBlock(block, bic));

OnInvalidBlock(s, block);
}
}

Expand Down Expand Up @@ -6553,6 +6555,7 @@ bool NodeProcessor::GenerateNewBlock(BlockContext& bc)
if (!bOk)
{
LOG_WARNING() << "couldn't apply block after cut-through!";
OnInvalidBlock(bc.m_Hdr, bc.m_Block);
return false; // ?!
}
GenerateNewHdr(bc, bic);
Expand Down
1 change: 1 addition & 0 deletions node/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ class NodeProcessor
virtual void InitializeUtxosProgress(uint64_t done, uint64_t total) {}
virtual void OnFastSyncSucceeded() {}
virtual Height get_MaxAutoRollback();
virtual void OnInvalidBlock(const Block::SystemState::Full&, const Block::Body&) {}

struct MyExecutor
:public Executor
Expand Down

0 comments on commit 3c8e190

Please sign in to comment.