/
icarus.go
50 lines (37 loc) · 1.04 KB
/
icarus.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"github.com/ChorusOne/Icarus/blockshot"
. "github.com/ChorusOne/Icarus/common"
"fmt"
"log"
"os"
"time"
)
func main() {
timestamp := time.Now().Unix()
filename := fmt.Sprintf("icarus_%d.log", timestamp)
file, e := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if e != nil {
log.Fatalln("Failed to open log file for icarus")
}
log.SetOutput(file)
log.Print("Icarus - Time to Fly.")
db, err := NewPostgresDBFromConfig("./config.env")
if err != nil {
log.Fatal(err)
}
defer db.Close()
//The following statement flushes Icarus' database.
//Comment out if you wish to resume the iterator without flushing the database
//TODO : Configify this
blockshot.ResetDatabase(db)
blockshot.BlockIterator(db,
[]blockshot.Task{
//blockshot.ProcessTransactions,
//Note : GenerateTransactionTags depends on ProcessTransactions
//So the following task should only appear after ProcessTransactions task
//in this list
//blockshot.GenerateTransactionTags,
blockshot.TakeDailySnapshots,
})
}