mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-26 00:25:17 +00:00
commit
4d65dff388
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.idea/
|
||||||
|
vouchers/
|
||||||
|
ceremony-client
|
16
Dockerfile
Normal file
16
Dockerfile
Normal 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
13
Makefile
Normal 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
|
@ -1,3 +1,9 @@
|
|||||||
# ceremonyclient
|
# 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/`.
|
@ -78,7 +78,8 @@ func JoinLobby() {
|
|||||||
|
|
||||||
client := http.DefaultClient
|
client := http.DefaultClient
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
fmt.Println("connected")
|
|
||||||
|
fmt.Println("Connected to sequencer!")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
36
main.go
36
main.go
@ -11,13 +11,7 @@ func main() {
|
|||||||
PrintLogo()
|
PrintLogo()
|
||||||
PrintVersion()
|
PrintVersion()
|
||||||
|
|
||||||
fmt.Println("Checking sequencer...")
|
WaitForSequencerToBeReady()
|
||||||
state := GetSequencerState()
|
|
||||||
for state != SEQUENCER_ACCEPTING {
|
|
||||||
fmt.Println("Sequencer currently not accepting new contributions, waiting...")
|
|
||||||
time.Sleep(30 * time.Second)
|
|
||||||
state = GetSequencerState()
|
|
||||||
}
|
|
||||||
|
|
||||||
JoinLobby()
|
JoinLobby()
|
||||||
Bootstrap()
|
Bootstrap()
|
||||||
@ -26,7 +20,33 @@ func main() {
|
|||||||
ContributeAndGetVoucher()
|
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() {
|
func PrintLogo() {
|
||||||
|
fmt.Println()
|
||||||
fmt.Println(" %#########")
|
fmt.Println(" %#########")
|
||||||
fmt.Println(" #############################")
|
fmt.Println(" #############################")
|
||||||
fmt.Println(" ########################################&")
|
fmt.Println(" ########################################&")
|
||||||
@ -64,4 +84,6 @@ func PrintLogo() {
|
|||||||
func PrintVersion() {
|
func PrintVersion() {
|
||||||
fmt.Println(" ")
|
fmt.Println(" ")
|
||||||
fmt.Println(" Quilibrium Ceremony Client - CLI - v1.0.1")
|
fmt.Println(" Quilibrium Ceremony Client - CLI - v1.0.1")
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user