Commit 37fcfd3a authored by Joshua Gutow's avatar Joshua Gutow

Refactor

parent f68c098a
...@@ -168,7 +168,17 @@ func loadTransactions(dir string, inbox common.Address) []fetch.TransactionWithM ...@@ -168,7 +168,17 @@ func loadTransactions(dir string, inbox common.Address) []fetch.TransactionWithM
} }
var out []fetch.TransactionWithMeta var out []fetch.TransactionWithMeta
for _, file := range files { for _, file := range files {
f, err := os.Open(path.Join(dir, file.Name())) f := path.Join(dir, file.Name())
txm := loadTransactionsFile(f)
if txm.InboxAddr == inbox && txm.ValidSender {
out = append(out, txm)
}
}
return out
}
func loadTransactionsFile(file string) fetch.TransactionWithMeta {
f, err := os.Open(file)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
...@@ -176,11 +186,7 @@ func loadTransactions(dir string, inbox common.Address) []fetch.TransactionWithM ...@@ -176,11 +186,7 @@ func loadTransactions(dir string, inbox common.Address) []fetch.TransactionWithM
dec := json.NewDecoder(f) dec := json.NewDecoder(f)
var txm fetch.TransactionWithMeta var txm fetch.TransactionWithMeta
if err := dec.Decode(&txm); err != nil { if err := dec.Decode(&txm); err != nil {
log.Fatalf("Failed to decode %v. Err: %v\n", path.Join(dir, file.Name()), err) log.Fatalf("Failed to decode %v. Err: %v\n", file, err)
}
if txm.InboxAddr == inbox && txm.ValidSender {
out = append(out, txm)
}
} }
return out return txm
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment