Browse Source

Ensure full currency definition on newly syncing PBaaS chains

pull/434/head
miketout 2 years ago
parent
commit
27e2b699aa
  1. 1
      src/main.cpp
  2. 2
      src/miner.cpp
  3. 4
      src/rpc/pbaasrpc.cpp

1
src/main.cpp

@ -4372,6 +4372,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
else if (p.evalCode == EVAL_CURRENCY_DEFINITION)
{
cbCurDef = CCurrencyDefinition(p.vData[0]);
ConnectedChains.UpdateCachedCurrency(cbCurDef, nHeight);
if (cbCurDef.GetID() == ASSETCHAINS_CHAINID)
{
ConnectedChains.ThisChain() = cbCurDef;

2
src/miner.cpp

@ -772,6 +772,8 @@ bool AddOneCurrencyImport(const CCurrencyDefinition &newCurrency,
std::vector<CTxDestination> dests({CPubKey(ParseHex(CC.CChexstr))});
outputs.push_back(CTxOut(0, MakeMofNCCScript(CConditionObj<CCurrencyDefinition>(EVAL_CURRENCY_DEFINITION, dests, 1, &newCurrency))));
ConnectedChains.UpdateCachedCurrency(newCurrency, 1);
// import / export capable currencies include the main currency, fractional currencies on any system,
// gateway currencies. the launch system, and non-token currencies. they also get an import / export thread
if (ConnectedChains.ThisChain().launchSystemID == newCurID ||

4
src/rpc/pbaasrpc.cpp

@ -180,7 +180,7 @@ bool GetCurrencyDefinition(const uint160 &chainID, CCurrencyDefinition &chainDef
chainDef = foundDef;
if (pDefHeight)
{
*pDefHeight = 0;
*pDefHeight = chainActive.Height() + 1;
}
if (pUTXO)
{
@ -222,10 +222,12 @@ bool GetCurrencyDefinition(const uint160 &chainID, CCurrencyDefinition &chainDef
{
thisChainLoaded = true;
ConnectedChains.ThisChain() = foundDef;
ConnectedChains.UpdateCachedCurrency(foundDef, *pDefHeight);
}
}
else if (foundDef.IsValid())
{
ConnectedChains.UpdateCachedCurrency(foundDef, *pDefHeight);
// add to nodes with last confirmed notarization nodes
CChainNotarizationData cnd;
if (notarizationCheck && GetNotarizationData(chainID, cnd) && cnd.IsConfirmed())

Loading…
Cancel
Save