From ebaa6fdaab22f37621efc2bd55b23d2bfba9b7d7 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Wed, 17 Jan 2024 11:21:35 +0800 Subject: [PATCH 1/2] add mn info --- src/dfi/validation.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/dfi/validation.cpp b/src/dfi/validation.cpp index d7fb8adf97..a1137dce5b 100644 --- a/src/dfi/validation.cpp +++ b/src/dfi/validation.cpp @@ -2810,8 +2810,23 @@ Res ProcessDeFiEventFallible(const CBlock &block, info.size_stripped = GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); info.weight = GetBlockWeight(block); info.stake_modifier = pindex->stakeModifier.ToString(); - info.minter = "", // mn operator address - info.masternode = "", // mn owner address + info.minter = ""; // mn operator address + info.masternode = ""; // mn owner address + + // minter info + CKeyID minter; + block.ExtractMinterKey(minter); + + auto id = mnview.GetMasternodeIdByOperator(minter); + if (id) { + info.masternode = id->ToString(); + auto mn = mnview.GetMasternode(*id); + if (mn) { + auto dest = mn->operatorType == 1 ? CTxDestination(PKHash(minter)) : CTxDestination(WitnessV0KeyHash(minter)); + info.minter = EncodeDestination(dest); + } + } + ocean_index_block(result, serializedData, info); // if (!result.ok) { // return Res::Err(result.reason.c_str()); From 5f60974a562c82fbdf61fdff3325de55a8929727 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Tue, 23 Jan 2024 16:46:21 +0800 Subject: [PATCH 2/2] index genesis --- src/init.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 753a9baf4e..1c53be934b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2504,5 +2504,50 @@ bool AppInitMain(InitInterfaces& interfaces) }); } + // ********************************************************* Step 16: start genesis ocean indexing + if(gArgs.GetBoolArg("-oceanarchive", DEFAULT_OCEAN_ARCHIVE_ENABLED)) { + const CBlock &block = chainparams.GenesisBlock(); + + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss << block; + CBlockIndex* pindex = ::ChainActive().Tip(); + + // Convert the serialized data to a string + std::string serializedData = HexStr(ss.begin(), ss.end()); + + CrossBoundaryResult result; + BlockV2Info info; + info.height = pindex->nHeight; + info.difficulty = pindex->nBits; + info.version = pindex->nVersion; + info.median_time = (int64_t)pindex->GetMedianTimePast(); + info.minter_block_count = pindex->mintedBlocks; + info.size = GetSerializeSize(block, PROTOCOL_VERSION); + info.size_stripped = GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); + info.weight = GetBlockWeight(block); + info.stake_modifier = pindex->stakeModifier.ToString(); + info.minter = ""; // mn operator address + info.masternode = ""; // mn owner address + + // minter info + CKeyID minter; + block.ExtractMinterKey(minter); + + auto id = pcustomcsview->GetMasternodeIdByOperator(minter); + if (id) { + info.masternode = id->ToString(); + auto mn = pcustomcsview->GetMasternode(*id); + if (mn) { + auto dest = mn->operatorType == 1 ? CTxDestination(PKHash(minter)) : CTxDestination(WitnessV0KeyHash(minter)); + info.minter = EncodeDestination(dest); + } + } + + ocean_index_block(result, serializedData, info); + // if (!result.ok) { + // return Res::Err(result.reason.c_str()); + // } + } + return true; }