Merge pull request #1 from Fitblip/main

QOL Updates
This commit is contained in:
Cassandra Heart 2023-04-17 22:14:05 -05:00 committed by GitHub
commit 4d65dff388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 9 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.idea/
vouchers/
ceremony-client

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM golang:1.18
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
# Add an entry to .bash_history so we can just run `make dev` and hit up to test the cli
RUN echo 'go run ./... test-voucher.hex' >> ~/.bash_history
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o ceremony-client
CMD ./ceremony-client

13
Makefile Normal file
View File

@ -0,0 +1,13 @@
IMAGE_TAG := quilibrium-ceremony-client
build-docker:
docker build -t $(IMAGE_TAG) .
bash:
docker run --rm -it $(IMAGE_TAG) bash
participate: build-docker
docker run --rm -it -v $(PWD)/vouchers:/vouchers $(IMAGE_TAG) ./ceremony-client "/vouchers/quil-voucher-$(shell date +'%m.%d.%y-%H:%M:%S').hex"
dev:
docker run --rm -it -v $(PWD):$(PWD) --workdir $(PWD) $(IMAGE_TAG) bash

View File

@ -1,3 +1,9 @@
# ceremonyclient
KZG Ceremony client for Quilibrium. Run with `go run ./... <voucher_filename>` or omit the filename to write to quil_voucher.hex.
KZG Ceremony client for Quilibrium.
# Running
Run with `go run ./... <voucher_filename>` or omit the filename to write to quil_voucher.hex.
If you have docker installed you can participate in the ceremony by simply running `make participate`. Your voucher will be written to `vouchers/`.

View File

@ -78,7 +78,8 @@ func JoinLobby() {
client := http.DefaultClient
resp, err := client.Do(req)
fmt.Println("connected")
fmt.Println("Connected to sequencer!")
if err != nil {
panic(err)

36
main.go
View File

@ -11,13 +11,7 @@ func main() {
PrintLogo()
PrintVersion()
fmt.Println("Checking sequencer...")
state := GetSequencerState()
for state != SEQUENCER_ACCEPTING {
fmt.Println("Sequencer currently not accepting new contributions, waiting...")
time.Sleep(30 * time.Second)
state = GetSequencerState()
}
WaitForSequencerToBeReady()
JoinLobby()
Bootstrap()
@ -26,7 +20,33 @@ func main() {
ContributeAndGetVoucher()
}
func WaitForSequencerToBeReady() {
spinnerChars := []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}
spinnerIndex := 0
attempts := 0
removeLine := "\u001B[A\u001B[2K"
state := GetSequencerState()
for state != SEQUENCER_ACCEPTING {
message := "Sequencer currently not accepting new contributions, waiting..."
status := fmt.Sprintf("[Attempt %d - Last Checked: %s]", attempts, time.Now().String())
fmt.Printf("\r%s", removeLine)
fmt.Printf("%s\n", message+spinnerChars[spinnerIndex])
fmt.Printf(" |- %s", status)
spinnerIndex = (spinnerIndex + 1) % len(spinnerChars)
attempts += 1
time.Sleep(5 * time.Second)
state = GetSequencerState()
}
fmt.Println()
fmt.Println("Sequencer is ready for contributions!")
}
func PrintLogo() {
fmt.Println()
fmt.Println(" %#########")
fmt.Println(" #############################")
fmt.Println(" ########################################&")
@ -64,4 +84,6 @@ func PrintLogo() {
func PrintVersion() {
fmt.Println(" ")
fmt.Println(" Quilibrium Ceremony Client - CLI - v1.0.1")
fmt.Println()
fmt.Println()
}