-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
68 lines (55 loc) · 3.09 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
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"flag"
"fmt"
"github.com/btcsuite/btcd/btcec"
"github.com/decent-labs/airfoil-sarcophagus-archaeologist-service/shared/archaeologist"
"github.com/decent-labs/airfoil-sarcophagus-archaeologist-service/shared/arweave"
"github.com/decent-labs/airfoil-sarcophagus-archaeologist-service/shared/models"
"github.com/decent-labs/airfoil-sarcophagus-archaeologist-service/shared/utility"
"github.com/ethereum/go-ethereum/crypto/ecies"
"log"
"strings"
)
func main(){
log.Printf("%v", loadArt())
// Add curve used by pub/priv keys in hdwallet to the accepted curves for ecies
// This is the curve used by the Web App to encrypt the file bytes
ecies.AddParamsForCurve(btcec.S256(), ecies.ECIES_AES128_SHA256)
// Load the config file values. Flag with config location is optional
var configFile = flag.String("config", "config", "Location of the config file.")
configDir := "./"
flag.Parse()
config := new(models.Config)
config.LoadConfig(*configFile, configDir, true)
// Initialize the Archaeologist with values from the config
arch := new(models.Archaeologist)
errStrings := archaeologist.InitializeArchaeologist(arch, config)
// List any errors. If any errors, exit
if len(errStrings) > 0 {
fmt.Println(fmt.Errorf(strings.Join(errStrings, "\n")))
log.Fatal("**Please fix these errors in your config file and restart the service.**")
}
// Start the server to listen for files
go arch.ListenForFile()
// Register/Update the Archaeologist on the contract
archaeologist.RegisterOrUpdateArchaeologist(arch)
log.Printf("Eth Balance: %v", utility.ToDecimal(arch.EthBalance(), 18))
log.Printf("Sarco Token Balance: %v", utility.ToDecimal(arch.SarcoBalance(), 18))
log.Println("Arweave Balance:", ar.ArweaveBalance(arch.ArweaveClient, arch.ArweaveWallet))
log.Printf("Arweave Address: %v", arch.ArweaveWallet.Address)
go archaeologist.RebuildArchStateListener(arch)
go archaeologist.ReInitializeArchaeologistScheduler(arch, config)
// Listen for contract events
for {
select {
case <-arch.ReconnectChan:
archaeologist.EventsSubscribe(arch)
default:
archaeologist.EventsSubscribe(arch)
}
}
}
func loadArt() string{
return "\n\n ██ █▄▄▄▄ ▄█▄ ▄ █ ██ ▄███▄ ████▄ █ ████▄ ▄▀ ▄█ ▄▄▄▄▄ ▄▄▄▄▀ \n█ █ █ ▄▀ █▀ ▀▄ █ █ █ █ █▀ ▀ █ █ █ █ █ ▄▀ ██ █ ▀▄ ▀▀▀ █ \n█▄▄█ █▀▀▌ █ ▀ ██▀▀█ █▄▄█ ██▄▄ █ █ █ █ █ █ ▀▄ ██ ▄ ▀▀▀▀▄ █ \n█ █ █ █ █▄ ▄▀ █ █ █ █ █▄ ▄▀ ▀████ ███▄ ▀████ █ █ ▐█ ▀▄▄▄▄▀ █ \n █ █ ▀███▀ █ █ ▀███▀ ▀ ███ ▐ ▀ \n █ ▀ ▀ █ \n ▀ ▀ \n\n"
}