Skip to content

Commit

Permalink
Provider update 1.1.1 (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell authored Oct 26, 2022
2 parents ea7fd0b + b973d8b commit 3a0ef39
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 688 deletions.
3 changes: 2 additions & 1 deletion cmd/canined/file_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func (q *UploadQueue) makeContract(cmd *cobra.Command, args []string, wg *sync.W
Message: msg,
Callback: wg,
Err: nil,
Response: nil,
}

k := &u
Expand Down Expand Up @@ -344,7 +345,7 @@ func StartFileServer(cmd *cobra.Command) {

handler := cors.Default().Handler(router)

go postProofs(cmd, db)
go postProofs(cmd, db, &q)
go q.startListener(clientCtx, cmd)
go q.checkStrays(clientCtx, cmd, db)

Expand Down
26 changes: 19 additions & 7 deletions cmd/canined/proofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"os"
"strconv"
"sync"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -88,7 +89,7 @@ func CreateMerkleForProof(cmd *cobra.Command, filename string, index int) (strin

}

func postProof(cmd *cobra.Command, cid string, block string, db *leveldb.DB) (*sdk.TxResponse, error) {
func postProof(cmd *cobra.Command, cid string, block string, db *leveldb.DB, queue *UploadQueue) (*sdk.TxResponse, error) {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return nil, err
Expand Down Expand Up @@ -119,15 +120,23 @@ func postProof(cmd *cobra.Command, cid string, block string, db *leveldb.DB) (*s
return nil, err
}

res, err := SendTx(clientCtx, cmd.Flags(), msg)
if err != nil {
return nil, err
var wg sync.WaitGroup
wg.Add(1)

u := Upload{
Message: msg,
Err: nil,
Callback: &wg,
Response: nil,
}

return res, nil
queue.append(&u)
wg.Wait()

return u.Response, u.Err
}

func postProofs(cmd *cobra.Command, db *leveldb.DB) {
func postProofs(cmd *cobra.Command, db *leveldb.DB, queue *UploadQueue) {
debug, err := cmd.Flags().GetBool("debug")
if err != nil {
return
Expand Down Expand Up @@ -216,7 +225,7 @@ func postProofs(cmd *cobra.Command, db *leveldb.DB) {
continue
}

res, err := postProof(cmd, cid, block, db)
res, err := postProof(cmd, cid, block, db, queue)
if err != nil {
fmt.Printf("Posting Error: %s\n", err.Error())
continue
Expand All @@ -229,6 +238,9 @@ func postProofs(cmd *cobra.Command, db *leveldb.DB) {
}
iter.Release()
err = iter.Error()
if err != nil {
fmt.Printf("Iterator Error: %s\n", err.Error())
}

time.Sleep(time.Duration(interval) * time.Second)
}
Expand Down
9 changes: 8 additions & 1 deletion cmd/canined/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (
ctypes "github.com/cosmos/cosmos-sdk/types"
)

func (q *UploadQueue) append(upload *Upload) {
q.Queue = append(q.Queue, upload)
}

func (q *UploadQueue) checkStrays(clientCtx client.Context, cmd *cobra.Command, db *leveldb.DB) {
for {
time.Sleep(time.Second)
Expand Down Expand Up @@ -83,6 +87,7 @@ func (q *UploadQueue) checkStrays(clientCtx client.Context, cmd *cobra.Command,
Message: msg,
Callback: nil,
Err: nil,
Response: nil,
}

q.Queue = append(q.Queue, &u)
Expand All @@ -95,7 +100,7 @@ func (q *UploadQueue) checkStrays(clientCtx client.Context, cmd *cobra.Command,

func (q *UploadQueue) startListener(clientCtx client.Context, cmd *cobra.Command) error {
for {
time.Sleep(time.Second)
time.Sleep(time.Second * 2)

if q.Locked {
continue
Expand All @@ -122,6 +127,8 @@ func (q *UploadQueue) startListener(clientCtx client.Context, cmd *cobra.Command
} else {
if res.Code != 0 {
v.Err = fmt.Errorf(res.RawLog)
} else {
v.Response = res
}
}
v.Callback.Done()
Expand Down
2 changes: 2 additions & 0 deletions cmd/canined/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"sync"

"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

const MaxFileSize = 32 << 30
Expand Down Expand Up @@ -41,6 +42,7 @@ type Upload struct {
Message types.Msg
Callback *sync.WaitGroup
Err error
Response *sdk.TxResponse
}

type UploadQueue struct {
Expand Down
134 changes: 0 additions & 134 deletions x/storage/client/cli/tx_active_deals.go

This file was deleted.

Loading

0 comments on commit 3a0ef39

Please sign in to comment.