-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
55 lines (39 loc) · 1.18 KB
/
main.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
51
52
53
54
55
package main
import (
"context"
. "github.com/san-lab/immudb-tests/datastructs"
)
const STATE_DB = "defaultdb"
const MSGS_DB = "msgdb"
func main() {
// Parse all config parameters
initConfigParams()
f := initLogger()
defer f.Close()
initDB()
// Initialize digest history of already onboarded CA banks
initDigestHistory()
// Get initial nonce
initNonce()
// Ensure connection is closed
defer STATE_CLIENT.CloseSession(context.Background())
defer MSGS_CLIENT.CloseSession(context.Background())
// Go routines that interact with blockchain
done := make(chan bool)
go periodicallySubmitHash(done)
done2 := make(chan bool)
go periodicallyPollAndSubmitPreImage(done2)
// HTTP server
go startApiServer()
// Automatically send broadcast message to find other libp2p banks
done3 := make(chan bool)
go periodicallyFindCounterpartBanks(done3)
// PromptUI to select action
TopUI()
// time.Sleep(1600 * time.Millisecond)
// ticker.Stop()
// done <- true
}
// TODO use events and keep pendingSubmissions method as backup plan
// TODO refactor optimistic nonce update to have cleaner code
// TODO add previous submission blocknumber to keep submitting blocks (privacy purposes)