Skip to content

Commit

Permalink
Applied parameters in protocol with stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
mike31 committed Dec 19, 2017
1 parent 014d354 commit 862926e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/chainparams/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ typedef struct mc_MultichainParams
int Write(int overwrite);
int Print(FILE *);
int SetGlobals();
int SetProtocolGlobals();
int SetUpgradedParamValue(const mc_OneMultichainParam *param,int64_t value);
int Import(const char *name,const char *source_address);
int Set(const char *name,const char *source,int source_size);

Expand Down
51 changes: 51 additions & 0 deletions src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ bool MultichainNode_AcceptData(CNode *pnode);
bool MultichainNode_IgnoreIncoming(CNode *pnode);
bool MultichainNode_IsLocal(CNode *pnode);
bool IsTxBanned(uint256 txid);
int CreateUpgradeLists(int current_height,vector<mc_UpgradedParameter> *vParams,vector<mc_UpgradeStatus> *vUpgrades);



Expand Down Expand Up @@ -348,6 +349,56 @@ map<NodeId, CNodeState> mapNodeState;
/* MCHN START */

int MultichainNode_ApplyUpgrades(int current_height)
{
vector<mc_UpgradedParameter> vParams;
int err=MC_ERR_NOERROR;

CreateUpgradeLists(chainActive.Height(),&vParams,NULL);

int OriginalProtocolVersion=(int)mc_gState->m_NetworkParams->GetInt64Param("protocolversion");
int CurrentProtocolVersion=mc_gState->m_NetworkParams->ProtocolVersion();//mc_gState->m_ProtocolVersionToUpgrade;
int NewProtocolVersion=OriginalProtocolVersion;

mc_gState->m_NetworkParams->SetGlobals();
for(int p=0;p<(int)vParams.size();p++)
{
if(strcmp(vParams[p].m_Param->m_Name,"protocolversion") == 0)
{
err=mc_gState->m_NetworkParams->m_ProtocolVersion=mc_gState->m_ProtocolVersionToUpgrade;// UPGRADE CODE HERE
mc_gState->m_NetworkParams->SetProtocolGlobals();
}
else
{
mc_gState->m_NetworkParams->SetUpgradedParamValue(vParams[p].m_Param,vParams[p].m_Value);
}
}
SetMultiChainParams();

if(mc_gState->m_ProtocolVersionToUpgrade != CurrentProtocolVersion)
{
LogPrintf("New protocol upgrade version: %d (was %d)\n",mc_gState->m_ProtocolVersionToUpgrade,CurrentProtocolVersion);
if( (err == MC_ERR_NOT_SUPPORTED) || ((mc_gState->m_ProtocolVersionToUpgrade > 0) && (mc_gState->IsSupported(mc_gState->m_ProtocolVersionToUpgrade) == 0)) )
{
LogPrintf("NODE SHOULD BE UPGRADED FROM %d TO %d\n",mc_gState->GetProtocolVersion(),mc_gState->m_ProtocolVersionToUpgrade);
}
else
{
if(mc_gState->m_ProtocolVersionToUpgrade != mc_gState->m_NetworkParams->ProtocolVersion())
{
LogPrintf("NODE IS UPGRADED FROM %d TO %d\n",mc_gState->m_NetworkParams->ProtocolVersion(),mc_gState->m_ProtocolVersionToUpgrade);
}
}
}
else
{
mc_gState->m_ProtocolVersionToUpgrade=0;
}

return MC_ERR_NOERROR;
}


int MultichainNode_ApplyUpgrades_Old(int current_height)
{
mc_EntityDetails entity;
mc_Buffer *permissions;
Expand Down
31 changes: 28 additions & 3 deletions src/utils/utilwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,29 @@ int mc_BuildDescription(int build, char *desc)
return MC_ERR_NOERROR;
}

int mc_MultichainParams::SetUpgradedParamValue(const mc_OneMultichainParam *param,int64_t value)
{
return MC_ERR_NOERROR;
}

int mc_MultichainParams::SetProtocolGlobals()
{
if(mc_gState->m_Features->ShortTxIDInTx() == 0)
{
m_AssetRefSize=MC_AST_ASSET_REF_SIZE;
}
MCP_ALLOW_ARBITRARY_OUTPUTS=1;
if(mc_gState->m_Features->FixedDestinationExtraction() != 0)
{
int aao=mc_gState->m_NetworkParams->GetInt64Param("allowarbitraryoutputs");
if(aao>=0)
{
MCP_ALLOW_ARBITRARY_OUTPUTS=aao;
}
}
return MC_ERR_NOERROR;
}

int mc_MultichainParams::SetGlobals()
{
m_IsProtocolMultiChain=1;
Expand Down Expand Up @@ -773,12 +796,12 @@ int mc_MultichainParams::SetGlobals()
CENT=0;
MAX_MONEY=0;
}

/*
if(mc_gState->m_Features->ShortTxIDInTx() == 0)
{
m_AssetRefSize=MC_AST_ASSET_REF_SIZE;
}

*/
MCP_MAX_STD_OP_RETURN_COUNT=mc_gState->m_NetworkParams->GetInt64Param("maxstdopreturnscount");
MCP_INITIAL_BLOCK_REWARD=mc_gState->m_NetworkParams->GetInt64Param("initialblockreward");
MCP_FIRST_BLOCK_REWARD=mc_gState->m_NetworkParams->GetInt64Param("firstblockreward");
Expand All @@ -790,6 +813,7 @@ int mc_MultichainParams::SetGlobals()
MCP_ANYONE_CAN_RECEIVE=mc_gState->m_NetworkParams->GetInt64Param("anyonecanreceive");
MCP_ANYONE_CAN_ACTIVATE=mc_gState->m_NetworkParams->GetInt64Param("anyonecanactivate");
MCP_MINIMUM_PER_OUTPUT=mc_gState->m_NetworkParams->GetInt64Param("minimumperoutput");
/*
MCP_ALLOW_ARBITRARY_OUTPUTS=1;
if(mc_gState->m_Features->FixedDestinationExtraction() != 0)
{
Expand All @@ -799,6 +823,7 @@ int mc_MultichainParams::SetGlobals()
MCP_ALLOW_ARBITRARY_OUTPUTS=aao;
}
}
*/
MCP_ALLOW_MULTISIG_OUTPUTS=mc_gState->m_NetworkParams->GetInt64Param("allowmultisigoutputs");
MCP_ALLOW_P2SH_OUTPUTS=mc_gState->m_NetworkParams->GetInt64Param("allowp2shoutputs");
MCP_WITH_NATIVE_CURRENCY=0;
Expand All @@ -809,7 +834,7 @@ int mc_MultichainParams::SetGlobals()
MCP_STD_OP_DROP_COUNT=mc_gState->m_NetworkParams->GetInt64Param("maxstdopdropscount");
MCP_STD_OP_DROP_SIZE=mc_gState->m_NetworkParams->GetInt64Param("maxstdopdropsize");
MCP_ANYONE_CAN_RECEIVE_EMPTY=mc_gState->m_NetworkParams->GetInt64Param("anyonecanreceiveempty");
return MC_ERR_NOERROR;
return SetProtocolGlobals();
}


Expand Down

0 comments on commit 862926e

Please sign in to comment.