Skip to content

Commit 3c8e190

Browse files
committed
Merge branch 'groovy_gluon_7.3RC' into mainnet
2 parents 1b03f16 + 558fd6c commit 3c8e190

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

node/node.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,48 @@ void Node::Processor::FlushDB()
927927
}
928928
}
929929

930+
void Node::Processor::OnInvalidBlock(const Block::SystemState::Full& s, const Block::Body& block)
931+
{
932+
if (!get_ParentObj().m_Miner.IsEnabled())
933+
return;
934+
935+
// format path
936+
std::string sPath = get_ParentObj().m_Cfg.m_sPathLocal;
937+
{
938+
for (uint32_t i = (uint32_t) sPath.size(); ; )
939+
{
940+
if (!i--)
941+
{
942+
sPath.clear();
943+
break;
944+
}
945+
946+
if (('/' == sPath[i]) || ('\\' == sPath[i]))
947+
{
948+
sPath.resize(i + 1);
949+
break;
950+
}
951+
}
952+
953+
Merkle::Hash hv;
954+
s.get_Hash(hv);
955+
956+
std::ostringstream os;
957+
os << s.m_Height << '-' << hv << ".inv_block";
958+
sPath += os.str();
959+
}
960+
961+
std::FStream fs;
962+
if (fs.Open(sPath.c_str(), false))
963+
{
964+
Serializer ser;
965+
ser & s;
966+
ser & block;
967+
968+
fs.write(ser.buffer().first, ser.buffer().second);
969+
}
970+
}
971+
930972
Node::Peer* Node::AllocPeer(const beam::io::Address& addr)
931973
{
932974
Peer* pPeer = new Peer(*this);

node/node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ struct Node
238238
void OnDummy(const CoinID&, Height) override;
239239
void InitializeUtxosProgress(uint64_t done, uint64_t total) override;
240240
Height get_MaxAutoRollback() override;
241+
void OnInvalidBlock(const Block::SystemState::Full&, const Block::Body&) override;
241242
void Stop();
242243

243244
struct MyExecutorMT

node/processor.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2940,7 +2940,7 @@ bool NodeProcessor::HandleBlock(const NodeDB::StateID& sid, const Block::SystemS
29402940
if (s.m_Kernels != ev.m_hvKernels)
29412941
{
29422942
LOG_WARNING() << LogSid(m_DB, sid) << " Kernel commitment mismatch";
2943-
return false;
2943+
bOk = false;
29442944
}
29452945
}
29462946

@@ -2962,6 +2962,8 @@ bool NodeProcessor::HandleBlock(const NodeDB::StateID& sid, const Block::SystemS
29622962
{
29632963
bic.m_Fwd = false;
29642964
BEAM_VERIFY(HandleValidatedBlock(block, bic));
2965+
2966+
OnInvalidBlock(s, block);
29652967
}
29662968
}
29672969

@@ -6553,6 +6555,7 @@ bool NodeProcessor::GenerateNewBlock(BlockContext& bc)
65536555
if (!bOk)
65546556
{
65556557
LOG_WARNING() << "couldn't apply block after cut-through!";
6558+
OnInvalidBlock(bc.m_Hdr, bc.m_Block);
65566559
return false; // ?!
65576560
}
65586561
GenerateNewHdr(bc, bic);

node/processor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ class NodeProcessor
554554
virtual void InitializeUtxosProgress(uint64_t done, uint64_t total) {}
555555
virtual void OnFastSyncSucceeded() {}
556556
virtual Height get_MaxAutoRollback();
557+
virtual void OnInvalidBlock(const Block::SystemState::Full&, const Block::Body&) {}
557558

558559
struct MyExecutor
559560
:public Executor

0 commit comments

Comments
 (0)