-
Notifications
You must be signed in to change notification settings - Fork 9
sync main #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sync main #261
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -36,6 +36,11 @@ class KdfApiClient implements ApiClient { | |||||
| final method = request['method'] as String?; | ||||||
| final stopwatch = Stopwatch()..start(); | ||||||
|
|
||||||
| // Log activation parameters before the call | ||||||
| if (method != null && _isActivationMethod(method)) { | ||||||
| _logActivationParameters(method, request); | ||||||
| } | ||||||
|
|
||||||
| try { | ||||||
| final response = _rpcCallback(request); | ||||||
| stopwatch.stop(); | ||||||
|
|
@@ -68,6 +73,74 @@ class KdfApiClient implements ApiClient { | |||||
| method == 'my_balance'; | ||||||
| } | ||||||
|
|
||||||
| bool _isActivationMethod(String method) { | ||||||
| return method.contains('enable') || | ||||||
| method.contains('task::enable') || | ||||||
| method.contains('task_enable'); | ||||||
| } | ||||||
|
|
||||||
| void _logActivationParameters(String method, JsonMap request) { | ||||||
| try { | ||||||
| final params = request['params'] as Map<String, dynamic>?; | ||||||
| if (params == null) return; | ||||||
|
|
||||||
| final ticker = params['ticker'] as String?; | ||||||
| final activationParams = params['activation_params'] as Map<String, dynamic>?; | ||||||
|
|
||||||
| if (ticker != null) { | ||||||
| _logger.info('[ACTIVATION] Enabling coin: $ticker'); | ||||||
| } | ||||||
|
|
||||||
| if (activationParams != null) { | ||||||
| // Log key activation parameters | ||||||
| final mode = activationParams['mode']; | ||||||
| final nodes = activationParams['nodes']; | ||||||
| final servers = activationParams['servers']; | ||||||
| final rpcUrls = activationParams['rpc_urls']; | ||||||
| final tokensRequests = activationParams['erc20_tokens_requests']; | ||||||
| final bchUrls = activationParams['bchd_urls']; | ||||||
|
|
||||||
| final paramsSummary = <String, dynamic>{}; | ||||||
|
|
||||||
| if (mode != null) paramsSummary['mode'] = mode; | ||||||
| if (nodes != null) { | ||||||
| paramsSummary['nodes_count'] = (nodes as List).length; | ||||||
| } | ||||||
| if (servers != null) { | ||||||
| paramsSummary['electrum_servers_count'] = (servers as List).length; | ||||||
| } | ||||||
| if (rpcUrls != null) { | ||||||
| paramsSummary['rpc_urls_count'] = (rpcUrls as List).length; | ||||||
| } | ||||||
| if (tokensRequests != null) { | ||||||
| paramsSummary['tokens_count'] = (tokensRequests as List).length; | ||||||
| } | ||||||
| if (bchUrls != null) { | ||||||
| paramsSummary['bchd_urls_count'] = (bchUrls as List).length; | ||||||
| } | ||||||
|
|
||||||
| // Add other relevant fields | ||||||
| if (activationParams['swap_contract_address'] != null) { | ||||||
| paramsSummary['swap_contract'] = activationParams['swap_contract_address']; | ||||||
| } | ||||||
| if (activationParams['platform'] != null) { | ||||||
| paramsSummary['platform'] = activationParams['platform']; | ||||||
| } | ||||||
| if (activationParams['contract_address'] != null) { | ||||||
| paramsSummary['contract_address'] = activationParams['contract_address']; | ||||||
| } | ||||||
|
|
||||||
| _logger.info('[ACTIVATION] Parameters: $paramsSummary'); | ||||||
|
|
||||||
| // Log full activation params for detailed debugging | ||||||
| _logger.fine('[ACTIVATION] Full params: $activationParams'); | ||||||
| } | ||||||
| } catch (e) { | ||||||
| // Silently ignore logging errors | ||||||
| _logger.fine('[ACTIVATION] Error logging parameters: $e'); | ||||||
|
||||||
| _logger.fine('[ACTIVATION] Error logging parameters: $e'); | |
| _logger.warning('[ACTIVATION] Error logging parameters: $e'); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -360,7 +360,20 @@ enum ScanPolicy { | |||||
| /// Contains information about electrum & lightwallet_d servers for coins being used | ||||||
| /// in 'Electrum' or 'Light' mode | ||||||
| class ActivationRpcData { | ||||||
| ActivationRpcData({this.lightWalletDServers, this.electrum, this.syncParams}); | ||||||
| ActivationRpcData({ | ||||||
| this.lightWalletDServers, | ||||||
| this.electrum, | ||||||
| this.syncParams, | ||||||
| this.minConnected, | ||||||
| this.maxConnected = 1, | ||||||
| }) : assert( | ||||||
| minConnected == null || minConnected >= 1, | ||||||
| 'min_connected must be at least 1', | ||||||
| ), | ||||||
| assert( | ||||||
| minConnected == null || (maxConnected ?? 1) >= minConnected, | ||||||
| 'min_connected cannot exceed max_connected', | ||||||
| ); | ||||||
|
|
||||||
| /// Creates [ActivationRpcData] from JSON configuration | ||||||
| factory ActivationRpcData.fromJson(JsonMap json) { | ||||||
|
|
@@ -381,6 +394,8 @@ class ActivationRpcData { | |||||
| syncParams: ZhtlcSyncParams.tryParse( | ||||||
| json.valueOrNull<dynamic>('sync_params'), | ||||||
| ), | ||||||
| minConnected: json.valueOrNull<int>('min_connected'), | ||||||
| maxConnected: json.valueOrNull<int>('max_connected'), | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -390,6 +405,12 @@ class ActivationRpcData { | |||||
| /// List of electrum servers for QTUM, BCH & UTXO coins | ||||||
| final List<ActivationServers>? electrum; | ||||||
|
|
||||||
| /// Minimum number of electrum servers to keep connected. Optional. | ||||||
| final int? minConnected; | ||||||
|
|
||||||
| /// Maximum number of electrum servers to keep connected. Defaults to 1. | ||||||
| final int? maxConnected; | ||||||
|
|
||||||
| /// ZHTLC coins only. Optional, defaults to two days ago. Defines where to start | ||||||
| /// scanning blockchain data upon initial activation. | ||||||
| /// | ||||||
|
|
@@ -411,6 +432,8 @@ class ActivationRpcData { | |||||
| (forLightWallet ? 'electrum_servers' : 'servers'): electrum! | ||||||
| .map((e) => e.toJsonRequest()) | ||||||
| .toList(), | ||||||
| if (electrum != null) 'max_connected': (maxConnected ?? 1), | ||||||
|
||||||
| if (electrum != null) 'max_connected': (maxConnected ?? 1), | |
| if (maxConnected != null) 'max_connected': maxConnected, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error logging uses info level instead of warning or error level. Change to
_logger.warning('[ACTIVATION] Error logging parameters: $e');to properly indicate this is an error condition.