feat: address

This commit is contained in:
hashbro
2026-09-12 18:14:03 +08:00
parent f15df77828
commit 0996d4e563
14 changed files with 350 additions and 30 deletions
+21 -12
View File
@@ -855,37 +855,46 @@ class IngestService
}
/**
* New addresses start with monitor=1. Turn off only when Tokenview is
* not configured or the chain is unsupported. If the API call fails
* (network error, rate limit, etc.), keep monitor=1 so it can be
* retried later via the admin UI or a background job.
* Two-field monitor model:
* monitor — user-facing switch (default ON for new addresses)
* monitor_synced — actual Tokenview registration state (default OFF;
* only set to true when syncMonitor() succeeds)
*
* On ingest we attempt the initial Tokenview registration. If it fails
* (network error, rate limit, etc.) we leave monitor=1 and
* monitor_synced=0 so the sync-monitors scheduled command will retry.
*/
private function enableMonitorOrDisable(WalletAddress $address): void
{
// Tokenview not configured or unsupported chain → don't monitor.
// Tokenview not configured or unsupported chain → switch off.
if (! $this->tokenview->shouldMonitor($address)) {
if ((int) $address->monitor !== 0) {
if ((int) $address->monitor !== 0 || (bool) $address->monitor_synced || (int) $address->monitor_failures !== 0) {
$address->monitor = 0;
$address->monitor_synced = false;
$address->monitor_failures = 0;
$address->save();
}
return;
}
// Try to register with Tokenview. On transient failure, keep
// monitor=1 so the address is still eligible for retry / webhooks.
// Try to register with Tokenview.
try {
if ($this->tokenview->syncMonitor($address)) {
return; // success
// syncMonitor() flips monitor_synced=true on success.
return;
}
} catch (\Throwable $e) {
Log::warning('tokenview enable on ingest failed: '.$e->getMessage(), [
'wallet_address_id' => $address->id,
]);
}
// syncMonitor returned false or threw — but Tokenview is configured
// and the chain is supported, so this is likely a transient API
// failure. Keep monitor=1 for retry.
// syncMonitor returned false or threw — transient API failure.
// Keep monitor=1, ensure monitor_synced=0 for retry by scheduled task.
if ((bool) $address->monitor_synced) {
$address->monitor_synced = false;
$address->save();
}
Log::info('tokenview sync failed, keeping monitor=1 for retry', [
'wallet_address_id' => $address->id,
]);