Skip to content

Commit

Permalink
SKALE-5059 update uninstall watch
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Apr 5, 2022
1 parent fd32775 commit 1710a0a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions libethereum/ClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ unsigned ClientBase::installWatch( h256 _h, const std::string& _strOrigin, Reapi
return ret;
}

bool ClientBase::uninstallWatch( unsigned _i ) {
bool ClientBase::uninstallWatch( unsigned _i, const std::string& _strOrigin ) {
LOG( m_loggerWatch ) << "XXX" << _i;

Guard l( x_filtersWatches );
Expand All @@ -307,7 +307,7 @@ bool ClientBase::uninstallWatch( unsigned _i ) {
LOG( m_loggerWatch ) << "*X*" << fit->first << ":" << fit->second.filter;
m_filters.erase( fit );
}
m_filtersByIp[""] -= 1;
m_filtersByIp[_strOrigin] -= 1;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libethereum/ClientBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ClientBase : public Interface {
Reaping _r = Reaping::Automatic,
fnClientWatchHandlerMulti_t fnOnNewChanges = fnClientWatchHandlerMulti_t(),
bool isWS = false ) override;
bool uninstallWatch( unsigned _watchId ) override;
bool uninstallWatch( unsigned _watchId, const std::string& strOrigin = "" ) override;
LocalisedLogEntries peekWatch( unsigned _watchId ) const override;
LocalisedLogEntries checkWatch( unsigned _watchId ) override;

Expand Down
2 changes: 1 addition & 1 deletion libethereum/Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Interface {
Reaping _r = Reaping::Automatic,
fnClientWatchHandlerMulti_t fnOnNewChanges = fnClientWatchHandlerMulti_t(),
bool isWS = false ) = 0;
virtual bool uninstallWatch( unsigned _watchId ) = 0;
virtual bool uninstallWatch( unsigned _watchId, const std::string& strOrigin = "" ) = 0;
LocalisedLogEntries peekWatchSafe( unsigned _watchId ) const {
try {
return peekWatch( _watchId );
Expand Down
7 changes: 4 additions & 3 deletions libskale/httpserveroverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ void SkaleWsPeer::uninstallAllWatches() {
auto pEthereum = ethereum();
for ( auto iw : sw ) {
try {
pEthereum->uninstallWatch( iw );
pEthereum->uninstallWatch( iw, m_strUnDdosOrigin );
} catch ( ... ) {
}
}
Expand Down Expand Up @@ -1352,7 +1352,8 @@ void SkaleWsPeer::eth_subscribe_logs(
"eth_subscription/logs" );
stats::register_stats_error(
"RPC", "eth_subscription/logs" );
pThis->ethereum()->uninstallWatch( iw );
pThis->ethereum()->uninstallWatch(
iw, pThis->m_strUnDdosOrigin );
}
// } );
} // for ( const auto& joWalk : joResultLogs )
Expand Down Expand Up @@ -1815,7 +1816,7 @@ void SkaleWsPeer::eth_unsubscribe(
joResponse["error"] = joError;
return;
}
ethereum()->uninstallWatch( iw );
ethereum()->uninstallWatch( iw, m_strUnDdosOrigin );
setInstalledWatchesLogs_.erase( iw );
}
} // for ( idxParam = 0; idxParam < cntParams; ++idxParam )
Expand Down
8 changes: 4 additions & 4 deletions libweb3jsonrpc/Eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ bool Eth::isEnabledTransactionSending() const {
throw std::runtime_error(
"error config.json file, cannot find "
"\"skaleConfig\"/\"nodeInfo\"/\"syncNode\"" );
const nlohmann::json& joSkaleConfig_nodeInfo_syncNode =
joSkaleConfig_nodeInfo["syncNode"];
const nlohmann::json& joSkaleConfig_nodeInfo_syncNode = joSkaleConfig_nodeInfo["syncNode"];
isEnabled = joSkaleConfig_nodeInfo_syncNode.get< bool >() ? false : true;
} catch ( ... ) {
}
Expand Down Expand Up @@ -490,9 +489,10 @@ string Eth::eth_newPendingTransactionFilter( const std::string& strOrigin ) {
return toJS( client()->installWatch( filter, strOrigin ) );
}

bool Eth::eth_uninstallFilter( string const& _filterId ) {
bool Eth::eth_uninstallFilter( string const& _filterId, const std::string& _strOrigin ) {
try {
return client()->uninstallWatch( static_cast< unsigned int >( jsToInt( _filterId ) ) );
return client()->uninstallWatch(
static_cast< unsigned int >( jsToInt( _filterId ) ), _strOrigin );
} catch ( ... ) {
BOOST_THROW_EXCEPTION( JsonRpcException( Errors::ERROR_RPC_INVALID_PARAMS ) );
}
Expand Down
3 changes: 2 additions & 1 deletion libweb3jsonrpc/Eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class Eth : public dev::rpc::EthFace, public skutils::json_config_file_accessor
virtual std::string eth_newBlockFilter( const std::string& strOrigin = "" ) override;
virtual std::string eth_newPendingTransactionFilter(
const std::string& strOrigin = "" ) override;
virtual bool eth_uninstallFilter( std::string const& _filterId ) override;
virtual bool eth_uninstallFilter(
std::string const& _filterId, const std::string& strOrigin = "" ) override;
virtual Json::Value eth_getFilterChanges( std::string const& _filterId ) override;
virtual Json::Value eth_getFilterChangesEx( std::string const& _filterId ) override;
virtual Json::Value eth_getFilterLogs( std::string const& _filterId ) override;
Expand Down
3 changes: 2 additions & 1 deletion libweb3jsonrpc/EthFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ class EthFace : public ServerInterface< EthFace > {
// virtual std::string eth_newFilterEx( const Json::Value& param1 ) = 0;
virtual std::string eth_newBlockFilter( const std::string& strOrigin = "" ) = 0;
virtual std::string eth_newPendingTransactionFilter( const std::string& strOrigin = "" ) = 0;
virtual bool eth_uninstallFilter( const std::string& param1 ) = 0;
virtual bool eth_uninstallFilter(
const std::string& param1, const std::string& strOrigin = "" ) = 0;
virtual Json::Value eth_getFilterChanges( const std::string& param1 ) = 0;
virtual Json::Value eth_getFilterChangesEx( const std::string& param1 ) = 0;
virtual Json::Value eth_getFilterLogs( const std::string& param1 ) = 0;
Expand Down

0 comments on commit 1710a0a

Please sign in to comment.