Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #153 from JackalLabs/marston/prune-combo
Browse files Browse the repository at this point in the history
Feat: prune combo flag
  • Loading branch information
dahn510 authored Apr 22, 2024
2 parents e2f48d7 + a8ccfa5 commit 5993ece
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.DS_Store

build
.idea
.idea
config
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM golang:1.22 as build

RUN apt update -y
RUN apt upgrade -y
RUN apt install build-essential -y
#RUN apk add --no-cache git make gcc musl-dev linux-headers ca-certificates build-base

ADD . canine-provider
WORKDIR canine-provider

RUN LEDGER_ENABLED=false make install

ENV PROVIDER_CHAIN_ID="jackal-1"
ENV PROVIDER_RPC="https://rpc.jackalprotocol.com:443"
ENV PROVIDER_DOMAIN="http://127.0.0.1:3333"
ENV PROVIDER_SPACE="1000000000000"
ENV PROVIDER_NAME="storage-provider"

RUN jprovd client gen-key
RUN jprovd client config chain-id $PROVIDER_CHAIN_ID
RUN jprovd client config node $PROVIDER_RPC

CMD ["sh", "scripts/docker.sh"]


13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.8'
services:
canine-provider:
build: .
ports:
- "3333:3333"
network_mode: "host"
volumes:
- storage:/root/.jackal-storage/storage
- "./config:/copyconfig"

volumes:
storage:
20 changes: 19 additions & 1 deletion jprov/jprovd/provider_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func StartServerCommand() *cobra.Command {
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

dbPath := utils.GetArchiveDBPath(clientCtx)
archivedb, err := archive.NewDoubleRefArchiveDB(dbPath)
if err != nil {
Expand Down Expand Up @@ -69,6 +70,10 @@ func StartServerCommand() *cobra.Command {
if err != nil {
return err
}
err = fs.Init()
if err != nil {
return err
}
fs.StartFileServer(cmd)
return nil
},
Expand Down Expand Up @@ -311,6 +316,11 @@ func MigrateCommand() *cobra.Command {
Long: `Migrate old file system. This will glue all blocks together into one file per fids stored in your machine`,
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
prune, err := cmd.Flags().GetBool(types.FlagPruneFirst)
if err != nil {
return err
}

buf := bufio.NewReader(cmd.InOrStdin())
yes, err := input.GetConfirmation("Are you sure you want to migrate from old file system?", buf, cmd.ErrOrStderr())
if err != nil {
Expand Down Expand Up @@ -374,8 +384,15 @@ func MigrateCommand() *cobra.Command {
return err
}

if prune {
err := fs.PruneExpiredFiles()
if err != nil {
return err
}
}
utils.Migrate(clientCtx, chunkSize)
return err

return nil
},
}
AddTxFlagsToCmd(cmd)
Expand All @@ -393,6 +410,7 @@ func MigrateCommand() *cobra.Command {
cmd.Flags().String(types.FlagProviderName, "A Storage Provider", "The name to identify this provider in block explorers.")
cmd.Flags().Int64(types.FlagSleep, types.DefaultSleep, "The time, in milliseconds, before adding another proof msg to the queue.")
cmd.Flags().Bool(types.FlagDoReport, types.DefaultDoReport, "Should this provider report deals (uses gas).")
cmd.Flags().Bool(types.FlagPruneFirst, false, "Should the provider prune its state before migration?")

return cmd
}
Expand Down
1 change: 1 addition & 0 deletions jprov/types/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
FlagProviderName = "moniker"
FlagSleep = "sleep"
FlagDoReport = "do-report"
FlagPruneFirst = "prune"
)

const (
Expand Down
10 changes: 10 additions & 0 deletions scripts/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cp -r /root/.jackal-storage/config /copyconfig


jprovd init $PROVIDER_DOMAIN $PROVIDER_SPACE "" -y || true

sleep 10

jprovd start -y --moniker=$PROVIDER_NAME || true

/bin/bash

0 comments on commit 5993ece

Please sign in to comment.