Skip to content

Commit

Permalink
allow retry if incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 3, 2022
1 parent 623327d commit bf7510a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion client/file/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ func Sync(versionDB *tmdb.Store, remoteGrpcUrl, remoteUrl, remoteWsUrl, rootDir
fmt.Printf("mm-pairs: %+v, %+v\n", len(pairs), err)
if err != nil {
fmt.Println("invalid decode")
panic(err)
}
if err = versionDB.PutAtVersion(int64(data.BlockNum), pairs); err != nil {
fmt.Println("mm-put-at-version-panic")
panic(err)
}
data.ChResult <- err

case err := <-chErr:
// fail read
fmt.Println("mm-fail-read-panic")
Expand Down
6 changes: 5 additions & 1 deletion client/file/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (d *httpFileDownloader) GetData(path string) ([]byte, error) {
type BlockData struct {
BlockNum int
Data []byte
ChResult chan<- error
}

type BlockFileWatcher struct {
Expand Down Expand Up @@ -131,11 +132,14 @@ func (w *BlockFileWatcher) fetch(blockNum int) error {
}
return err
}

chResult := make(chan error)
w.chData <- &BlockData{
BlockNum: blockNum,
Data: data,
ChResult: chResult,
}
return nil
return <-chResult
}

func (w *BlockFileWatcher) Start(
Expand Down

0 comments on commit bf7510a

Please sign in to comment.