Skip to content

Commit

Permalink
Fix from string with correct endians (WalletWasabi#13409)
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolay authored Sep 17, 2024
1 parent d6b9fda commit 1b0e10c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Contrib/Migration/migrateBackendFilters.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ let batchSize = 1000

type Filter = { Height: int; BlockHash: byte[]; Filter: byte[]; BlockTime: int64; PrevBlockHash: byte[] }

let from_str (s: string) = Convert.FromHexString(s) |> Array.rev
let from_big_endian_str (s: string) = Convert.FromHexString(s) |> Array.rev
let from_little_endian_str (s: string) = Convert.FromHexString(s)

let createDatabaseIfNotExists (path: string) =
if not (File.Exists(path)) then
Expand Down Expand Up @@ -82,9 +83,9 @@ let processLine (line: string) =
let parts = line.Split(':')
{
Height = int parts.[0]
BlockHash = from_str parts.[1]
Filter = from_str parts.[2]
PrevBlockHash = from_str parts.[3]
BlockHash = from_big_endian_str parts.[1]
Filter = from_little_endian_str parts.[2]
PrevBlockHash = from_big_endian_str parts.[3]
BlockTime = int64 parts.[4]
}

Expand Down

0 comments on commit 1b0e10c

Please sign in to comment.