pc2-chain.ps1: the export goes through curl.exe to a file (Invoke-WebRequest's Content is a string; the first run failed on WriteAllBytes)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
igneum-josh 2026-10-05 20:57:05 +01:00
parent e5bb296c2e
commit 353a6e813b

View file

@ -26,10 +26,12 @@ $first = $tip - 30; $last = $first + 7
$t = Get-Date
$body = (@{jsonrpc='2.0'; id=1; method='igneum_exportSegments'; params=@('0x0', ('0x{0:x}' -f $last))} | ConvertTo-Json -Compress)
$seqFile = Join-Path $job 'seq.json'
try {
$resp = Invoke-WebRequest -Method Post -Uri "http://127.0.0.1:$evmPort" -ContentType 'application/json' -Body $body -TimeoutSec 600 -UseBasicParsing
[IO.File]::WriteAllBytes($seqFile, $resp.Content)
} catch { "RESULT export FAILED: $_"; exit 1 }
$bodyFile = Join-Path $job 'export-request.json'
[IO.File]::WriteAllText($bodyFile, $body, (New-Object System.Text.UTF8Encoding $false))
# curl.exe (Windows 10+ ships it) streams the 70 MB reply to a file; Invoke-WebRequest's Content is a string there
# and WriteAllBytes refused it (the first run, 19:52Z)
& curl.exe -s -S -m 600 -X POST "http://127.0.0.1:$evmPort" -H 'Content-Type: application/json' --data-binary "@$bodyFile" -o $seqFile 2>&1 | ForEach-Object { "curl: $_" }
if (-not (Test-Path $seqFile) -or (Get-Item $seqFile).Length -lt 1000) { "RESULT export FAILED: no reply file"; exit 1 }
$len = (Get-Item $seqFile).Length
"RESULT export $(Stamp) $len bytes in $([math]::Round(((Get-Date) - $t).TotalSeconds,1)) s to $seqFile"
# the JSON-RPC envelope: the exporter wants the result object; unwrap with python inside WSL (below)