Skip to content

Commit

Permalink
getting chunk size from chain on boot
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Nov 3, 2023
1 parent 9616a03 commit d570d8f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
1 change: 0 additions & 1 deletion api/file_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func PostFileHandler(db *badger.DB, q *queue.Queue, wl *wallet.Wallet, chunkSize

err = json.NewEncoder(w).Encode(resp)
if err != nil {

log.Error().Err(fmt.Errorf("can't encode json : %w", err))
}
}
Expand Down
2 changes: 0 additions & 2 deletions config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type Seed struct {
type Config struct {
QueueInterval int64 `yaml:"queue_interval"`
ProofInterval int64 `yaml:"proof_interval"`
ChunkSize int64 `yaml:"chunk_size"`
StrayManagerCfg StrayManagerConfig `yaml:"stray_manager"`
ChainCfg types.ChainConfig `yaml:"chain_config"`
Ip string `yaml:"domain"`
Expand All @@ -32,7 +31,6 @@ func DefaultConfig() *Config {
return &Config{
QueueInterval: 10,
ProofInterval: 120,
ChunkSize: 10240,
StrayManagerCfg: StrayManagerConfig{
CheckInterval: 30,
RefreshInterval: 120,
Expand Down
24 changes: 22 additions & 2 deletions core/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"syscall"
"time"

"github.com/cosmos/gogoproto/grpc"

"github.com/JackalLabs/sequoia/api"
"github.com/JackalLabs/sequoia/config"
"github.com/JackalLabs/sequoia/logger"
Expand Down Expand Up @@ -129,6 +131,19 @@ func updateIp(wallet *wallet.Wallet, ip string) error {
return nil
}

func (a *App) GetStorageParams(client grpc.ClientConn) (storageTypes.Params, error) {
queryParams := &storageTypes.QueryParamsRequest{}

cl := storageTypes.NewQueryClient(client)

res, err := cl.Params(context.Background(), queryParams)
if err != nil {
return storageTypes.Params{}, err
}

return res.Params, nil
}

func (a *App) Start() {
cfg, err := config.Init(a.home)
if err != nil {
Expand Down Expand Up @@ -180,20 +195,25 @@ func (a *App) Start() {
}
}

params, err := a.GetStorageParams(w.Client.GRPCConn)
if err != nil {
panic(err)
}

myUrl := cfg.Ip

log.Info().Msg(fmt.Sprintf("Provider started as: %s", myAddress))

a.q = queue.NewQueue(w, cfg.QueueInterval)
a.prover = proofs.NewProver(w, a.db, a.q, cfg.ProofInterval)

go a.api.Serve(a.db, a.q, w, cfg.ChunkSize)
go a.api.Serve(a.db, a.q, w, params.ChunkSize)
go a.prover.Start()
go a.q.Listen()

a.strayManager = strays.NewStrayManager(w, a.q, cfg.StrayManagerCfg.CheckInterval, cfg.StrayManagerCfg.RefreshInterval, cfg.StrayManagerCfg.HandCount, claimers)

go a.strayManager.Start(a.db, myUrl, cfg.ChunkSize)
go a.strayManager.Start(a.db, myUrl, params.ChunkSize)

done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)
Expand Down

0 comments on commit d570d8f

Please sign in to comment.