Skip to content

Commit

Permalink
chore: move apibsstore.go to pkg/util/blockstoreutil (#5391)
Browse files Browse the repository at this point in the history
* chore: move apibsstore.go to pkg/util/blockstoreutil

* chore: tidy mod
  • Loading branch information
simlecode committed Oct 21, 2022
1 parent b75163f commit 590b3bb
Show file tree
Hide file tree
Showing 41 changed files with 102 additions and 193 deletions.
4 changes: 2 additions & 2 deletions app/node/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestJsonrpc(t *testing.T) {
httpRes, err := http.Post("http://"+testServ.Listener.Addr().String()+"/rpc/v1", "", bytes.NewReader(reqBytes))
require.NoError(t, err)
assert.Equal(t, httpRes.Status, "200 OK")
result, err := ioutil.ReadAll(httpRes.Body)
result, err := io.ReadAll(httpRes.Body)
require.NoError(t, err)
res := struct {
Result string `json:"result"`
Expand Down
73 changes: 0 additions & 73 deletions app/submodule/chain/apibstore.go

This file was deleted.

3 changes: 1 addition & 2 deletions cmd/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
logging "github.com/ipfs/go-log/v2"

"github.com/filecoin-project/venus/app/node"
"github.com/filecoin-project/venus/app/submodule/chain"
"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/pkg/wallet"
"github.com/filecoin-project/venus/venus-shared/actors"
Expand Down Expand Up @@ -260,7 +259,7 @@ var minerInfoCmd = &cmds.Command{
return err
}

tbs := blockstoreutil.NewTieredBstore(chain.NewAPIBlockstore(blockstoreAPI), blockstoreutil.NewTemporary())
tbs := blockstoreutil.NewTieredBstore(blockstoreutil.NewAPIBlockstore(blockstoreAPI), blockstoreutil.NewTemporary())
mas, err := miner.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cmd/miner_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/venus-shared/blockstore"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
Expand All @@ -20,7 +21,6 @@ import (

builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/venus/app/node"
"github.com/filecoin-project/venus/app/submodule/chain"
"github.com/filecoin-project/venus/cmd/tablewriter"
"github.com/filecoin-project/venus/venus-shared/actors"
"github.com/filecoin-project/venus/venus-shared/actors/adt"
Expand Down Expand Up @@ -299,7 +299,7 @@ var actorRepayDebtCmd = &cmds.Command{
return err
}

store := adt.WrapStore(ctx, cbor.NewCborStore(chain.NewAPIBlockstore(env.(*node.Env).BlockStoreAPI)))
store := adt.WrapStore(ctx, cbor.NewCborStore(blockstore.NewAPIBlockstore(env.(*node.Env).BlockStoreAPI)))

mst, err := miner.Load(store, mact)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/miner_proving.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
cbor "github.com/ipfs/go-ipld-cbor"

"github.com/filecoin-project/venus/app/node"
"github.com/filecoin-project/venus/app/submodule/chain"
"github.com/filecoin-project/venus/venus-shared/actors/adt"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/miner"
"github.com/filecoin-project/venus/venus-shared/blockstore"
"github.com/filecoin-project/venus/venus-shared/types"
)

Expand Down Expand Up @@ -59,7 +59,7 @@ var provingInfoCmd = &cmds.Command{
return err
}

stor := adt.WrapStore(ctx, cbor.NewCborStore(chain.NewAPIBlockstore(env.(*node.Env).BlockStoreAPI)))
stor := adt.WrapStore(ctx, cbor.NewCborStore(blockstore.NewAPIBlockstore(env.(*node.Env).BlockStoreAPI)))

mas, err := miner.Load(stor, mact)
if err != nil {
Expand Down Expand Up @@ -315,7 +315,7 @@ var provingFaultsCmd = &cmds.Command{
ctx := req.Context
api := env.(*node.Env).ChainAPI
bstoreAPI := env.(*node.Env).BlockStoreAPI
stor := adt.WrapStore(ctx, cbor.NewCborStore(chain.NewAPIBlockstore(bstoreAPI)))
stor := adt.WrapStore(ctx, cbor.NewCborStore(blockstore.NewAPIBlockstore(bstoreAPI)))

mact, err := api.StateGetActor(ctx, maddr, types.EmptyTSK)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/venus/app/node"
sbchain "github.com/filecoin-project/venus/app/submodule/chain"
"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/venus-shared/actors"
"github.com/filecoin-project/venus/venus-shared/actors/adt"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/multisig"
"github.com/filecoin-project/venus/venus-shared/blockstore"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/filecoin-project/venus/venus-shared/utils"
"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -158,7 +158,7 @@ var msigInspectCmd = &cmds.Command{
return fmt.Errorf("must specify address of multisig to inspect")
}
ctx := req.Context
store := adt.WrapStore(ctx, cbor.NewCborStore(sbchain.NewAPIBlockstore(env.(*node.Env).BlockStoreAPI)))
store := adt.WrapStore(ctx, cbor.NewCborStore(blockstore.NewAPIBlockstore(env.(*node.Env).BlockStoreAPI)))
//store := env.(*node.Env).ChainAPI.ChainReader.Store(req.Context)
maddr, err := address.NewFromString(req.Arguments[0])
if err != nil {
Expand Down Expand Up @@ -604,7 +604,7 @@ var msigAddProposeCmd = &cmds.Command{
return err
}

store := adt.WrapStore(ctx, cbor.NewCborStore(sbchain.NewAPIBlockstore(env.(*node.Env).BlockStoreAPI)))
store := adt.WrapStore(ctx, cbor.NewCborStore(blockstore.NewAPIBlockstore(env.(*node.Env).BlockStoreAPI)))

head, err := env.(*node.Env).ChainAPI.ChainHead(ctx)
if err != nil {
Expand Down
27 changes: 13 additions & 14 deletions cmd/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -95,7 +94,7 @@ var genesisNewCmd = &cmds.Command{
return err
}

return ioutil.WriteFile(genf, genb, 0644)
return os.WriteFile(genf, genb, 0644)
},
}

Expand All @@ -118,7 +117,7 @@ var genesisAddMinerCmd = &cmds.Command{
}

var template genesis.Template
genb, err := ioutil.ReadFile(genf)
genb, err := os.ReadFile(genf)
if err != nil {
return fmt.Errorf("read genesis template: %w", err)
}
Expand All @@ -132,7 +131,7 @@ var genesisAddMinerCmd = &cmds.Command{
return fmt.Errorf("expand preseal file path: %w", err)
}
miners := map[string]genesis.Miner{}
minb, err := ioutil.ReadFile(minf)
minb, err := os.ReadFile(minf)
if err != nil {
return fmt.Errorf("read preseal file: %w", err)
}
Expand Down Expand Up @@ -171,7 +170,7 @@ var genesisAddMinerCmd = &cmds.Command{
return err
}

return ioutil.WriteFile(genf, genb, 0644)
return os.WriteFile(genf, genb, 0644)
},
}

Expand Down Expand Up @@ -199,7 +198,7 @@ var genesisAddMsigsCmd = &cmds.Command{
}

var template genesis.Template
b, err := ioutil.ReadFile(genf)
b, err := os.ReadFile(genf)
if err != nil {
return fmt.Errorf("read genesis template: %w", err)
}
Expand Down Expand Up @@ -237,7 +236,7 @@ var genesisAddMsigsCmd = &cmds.Command{
return err
}

return ioutil.WriteFile(genf, b, 0644)
return os.WriteFile(genf, b, 0644)
},
}

Expand Down Expand Up @@ -334,7 +333,7 @@ var genesisSetVRKCmd = &cmds.Command{
}

var template genesis.Template
b, err := ioutil.ReadFile(genf)
b, err := os.ReadFile(genf)
if err != nil {
return fmt.Errorf("read genesis template: %w", err)
}
Expand Down Expand Up @@ -401,7 +400,7 @@ var genesisSetVRKCmd = &cmds.Command{
return err
}

return ioutil.WriteFile(genf, b, 0644)
return os.WriteFile(genf, b, 0644)
},
}

Expand All @@ -427,7 +426,7 @@ var genesisSetRemainderCmd = &cmds.Command{
}

var template genesis.Template
b, err := ioutil.ReadFile(genf)
b, err := os.ReadFile(genf)
if err != nil {
return fmt.Errorf("read genesis template: %w", err)
}
Expand Down Expand Up @@ -494,7 +493,7 @@ var genesisSetRemainderCmd = &cmds.Command{
return err
}

return ioutil.WriteFile(genf, b, 0644)
return os.WriteFile(genf, b, 0644)
},
}

Expand All @@ -517,7 +516,7 @@ var genesisSetActorVersionCmd = &cmds.Command{
}

var template genesis.Template
b, err := ioutil.ReadFile(genf)
b, err := os.ReadFile(genf)
if err != nil {
return fmt.Errorf("read genesis template: %w", err)
}
Expand All @@ -542,7 +541,7 @@ var genesisSetActorVersionCmd = &cmds.Command{
return err
}

return ioutil.WriteFile(genf, b, 0644)
return os.WriteFile(genf, b, 0644)
},
}

Expand Down Expand Up @@ -574,7 +573,7 @@ var preSealCmd = &cmds.Command{
var ki *crypto.KeyInfo
if key, _ := req.Options["key"].(string); key != "" {
ki = new(crypto.KeyInfo)
kh, err := ioutil.ReadFile(key)
kh, err := os.ReadFile(key)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/version_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd_test

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"os/exec"
"strings"
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestVersionOverHttp(t *testing.T) {
commit := getCodeCommit(t)[0:7]

defer res.Body.Close() // nolint: errcheck
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
require.NoError(t, err)
require.Contains(t, string(body), constants.BuildVersion+"+git."+commit)
}
Expand Down
6 changes: 3 additions & 3 deletions fixtures/fortest/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package fortest
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -63,7 +63,7 @@ func init() {
panic(err)
}
}()
genConfigBytes, err := ioutil.ReadAll(genConfigFile)
genConfigBytes, err := io.ReadAll(genConfigFile)
if err != nil {
panic(err)
}
Expand All @@ -86,7 +86,7 @@ func init() {
panic(err)
}
}()
detailsFileBytes, err := ioutil.ReadAll(detailsFile)
detailsFileBytes, err := io.ReadAll(detailsFile)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ require (
)

require (
github.com/BurntSushi/toml v1.2.0 // indirect
github.com/BurntSushi/toml v1.1.0 // indirect
github.com/Kubuxu/go-os-helper v0.0.1 // indirect
github.com/Stebalien/go-bitfield v0.0.1 // indirect
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOv
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
Expand Down
Loading

0 comments on commit 590b3bb

Please sign in to comment.