diff --git a/chains/Schain.cpp b/chains/Schain.cpp index 5a55ba80b..9c32f113c 100644 --- a/chains/Schain.cpp +++ b/chains/Schain.cpp @@ -243,15 +243,7 @@ Schain::Schain( weak_ptr< Node > _node, schain_index _schainIndex, const schain_ schainIndex( _schainIndex ) { lastCommittedBlockTimeStamp = TimeStamp( 0, 0 ); - if (getNode()->getPatchTimestamps().count("verifyDaSigsPatchTimestamp") > 0) { - this->verifyDaSigsPatchTimestampS = - getNode()->getPatchTimestamps().at("verifyDaSigsPatchTimestamp"); - } - - if (getNode()->getPatchTimestamps().count("verifyDaSigsPatchTimestamp") > 0) { - this->fastConsensusPatchTimestampS = - getNode()->getPatchTimestamps().at("fastConsensusPatchTimestamp"); - } + setTimeStampValuesFromConfig(); @@ -315,6 +307,22 @@ Schain::Schain( weak_ptr< Node > _node, schain_index _schainIndex, const schain_ } + +#define SET_TIMESTAMP_FROM_CONFIG(TIMESTAMP_NAME) \ + { \ + auto& timestamps = getNode()->getPatchTimestamps(); \ + if (timestamps.count(#TIMESTAMP_NAME) > 0) { \ + TIMESTAMP_NAME = timestamps.at(#TIMESTAMP_NAME); \ + } \ + } + + +void Schain::setTimeStampValuesFromConfig() { + SET_TIMESTAMP_FROM_CONFIG(verifyDaSigsPatchTimestampS) + SET_TIMESTAMP_FROM_CONFIG(fastConsensusPatchTimestampS) +} + + // called from constructor so no locks needed void Schain::constructChildAgents() { MONITOR( __CLASS_NAME__, __FUNCTION__ ) diff --git a/chains/Schain.h b/chains/Schain.h index 1d8084c6f..840d68551 100644 --- a/chains/Schain.h +++ b/chains/Schain.h @@ -399,4 +399,5 @@ class Schain : public Agent { const ptr &getCatchupClientAgent() const; + void setTimeStampValuesFromConfig(); };