Skip to content

Commit

Permalink
feat: add valid submission event
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin authored and hunjixin committed Jun 24, 2024
1 parent fbaf86f commit 1ac8dbf
Show file tree
Hide file tree
Showing 13 changed files with 626 additions and 167 deletions.
50 changes: 50 additions & 0 deletions cmd/lilypad/collection-pow-submission.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package lilypad

import (
"github.com/lilypad-tech/lilypad/pkg/collectpowsubmission"
"github.com/lilypad-tech/lilypad/pkg/options"
optionsfactory "github.com/lilypad-tech/lilypad/pkg/options"
"github.com/lilypad-tech/lilypad/pkg/system"
"github.com/lilypad-tech/lilypad/pkg/web3"
"github.com/spf13/cobra"
)

func newCollectionPowSubmissionCmd() *cobra.Command {
options := optionsfactory.NewCollectPowSubmissionOptions()

powSignalCmd := &cobra.Command{
Use: "collection-pow-submission",
Short: "Collect pow submission data to database.",
Long: "Collect pow submission data to database.",
Example: "",
RunE: func(cmd *cobra.Command, _ []string) error {
network, _ := cmd.Flags().GetString("network")

options, err := optionsfactory.ProcessCollectPowSubmissionOptions(options, network)
if err != nil {
return err
}
return runCollectionPowSubmission(cmd, options)
},
}

optionsfactory.AddCollectPowSubmissionCliFlags(powSignalCmd, &options)

return powSignalCmd
}

func runCollectionPowSubmission(cmd *cobra.Command, options options.CollectPowSubmissionOptions) error {
commandCtx := system.NewCommandContext(cmd)
defer commandCtx.Cleanup()

web3SDK, err := web3.NewContractSDK(options.Web3)
if err != nil {
return err
}

err = collectpowsubmission.StartCollectPowSubmission(commandCtx.Ctx, web3SDK, options.PGConnectionString, commandCtx.Cm)
if err != nil {
return err
}
return nil
}
1 change: 1 addition & 0 deletions cmd/lilypad/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func NewRootCmd() *cobra.Command {
RootCmd.AddCommand(newMediatorCmd())
RootCmd.AddCommand(newJobCreatorCmd())
RootCmd.AddCommand(newVersionCmd())
RootCmd.AddCommand(newCollectionPowSubmissionCmd())
return RootCmd
}

Expand Down
29 changes: 20 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
module github.com/lilypad-tech/lilypad

go 1.20
go 1.21

toolchain go1.22.4

require (
github.com/BurntSushi/toml v0.3.1
github.com/bits-and-blooms/bloom/v3 v3.7.0
github.com/davecgh/go-spew v1.1.1
github.com/ethereum/go-ethereum v1.13.4
github.com/fatih/color v1.15.0
github.com/fatih/color v1.16.0
github.com/go-git/go-git/v5 v5.10.0
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
Expand All @@ -16,10 +19,13 @@ require (
github.com/holiman/uint256 v1.2.4
github.com/ipfs/go-merkledag v0.11.0
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.31.0
github.com/rs/zerolog v1.32.0
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
github.com/theckman/yacspin v0.13.12
github.com/uptrace/bun v1.2.1
github.com/uptrace/bun/dialect/pgdialect v1.2.1
github.com/uptrace/bun/driver/pgdriver v1.2.1
gorgonia.org/cu v0.9.7-0.20240623234718-3cd40db700e9
k8s.io/apimachinery v0.28.3
)
Expand All @@ -30,7 +36,7 @@ require (
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/consensys/bavard v0.1.13 // indirect
Expand Down Expand Up @@ -72,10 +78,11 @@ require (
github.com/ipld/go-ipld-prime v0.20.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
Expand All @@ -98,22 +105,26 @@ require (
github.com/supranational/blst v0.3.11 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
go.opentelemetry.io/otel v1.7.0 // indirect
go.opentelemetry.io/otel/trace v1.7.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.22.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
mellium.im/sasl v0.3.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Loading

0 comments on commit 1ac8dbf

Please sign in to comment.