diff --git a/.github/workflows/beekeeper.yml b/.github/workflows/beekeeper.yml index 95a09cfc1dc..da44ec4d14a 100644 --- a/.github/workflows/beekeeper.yml +++ b/.github/workflows/beekeeper.yml @@ -162,6 +162,12 @@ jobs: - name: Test staking id: stake run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks ci-stake + - name: Test withdraw + id: withdraw + run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks ci-withdraw; do echo "waiting for withdraw..."; sleep .3; done' + - name: Test redundancy + id: redundancy + run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks ci-redundancy - name: Collect debug artifacts if: failure() run: | diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000000..51c624e6cbd --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" +permissions: read-all +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '23 1 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.goreleaser.yml b/.goreleaser.yml index 9e26e592582..88bf9d55c85 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -15,11 +15,11 @@ builds: - -trimpath ldflags: - -s -w - - -X github.com/ethersphere/bee.version={{ .Version }} - - -X github.com/ethersphere/bee.commitHash={{ .ShortCommit }} - - -X github.com/ethersphere/bee.commitTime={{ .CommitTimestamp }} - - -X github.com/ethersphere/bee/pkg/api.Version={{ .Env.BEE_API_VERSION }} - - -X github.com/ethersphere/bee/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} + - -X github.com/ethersphere/bee/v2.version={{ .Version }} + - -X github.com/ethersphere/bee/v2.commitHash={{ .ShortCommit }} + - -X github.com/ethersphere/bee/v2.commitTime={{ .CommitTimestamp }} + - -X github.com/ethersphere/bee/v2/pkg/api.Version={{ .Env.BEE_API_VERSION }} + - -X github.com/ethersphere/bee/v2/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} env: - CGO_ENABLED=0 goos: @@ -39,11 +39,11 @@ builds: - -trimpath ldflags: - -s -w - - -X github.com/ethersphere/bee.version={{ .Version }} - - -X github.com/ethersphere/bee.commitHash={{ .ShortCommit }} - - -X github.com/ethersphere/bee.commitTime={{ .CommitTimestamp }} - - -X github.com/ethersphere/bee/pkg/api.Version={{ .Env.BEE_API_VERSION }} - - -X github.com/ethersphere/bee/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} + - -X github.com/ethersphere/bee/v2.version={{ .Version }} + - -X github.com/ethersphere/bee/v2.commitHash={{ .ShortCommit }} + - -X github.com/ethersphere/bee/v2.commitTime={{ .CommitTimestamp }} + - -X github.com/ethersphere/bee/v2/pkg/api.Version={{ .Env.BEE_API_VERSION }} + - -X github.com/ethersphere/bee/v2/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} env: - CGO_ENABLED=0 goos: @@ -65,11 +65,11 @@ builds: - -trimpath ldflags: - -s -w - - -X github.com/ethersphere/bee.version={{ .Version }} - - -X github.com/ethersphere/bee.commitHash={{ .ShortCommit }} - - -X github.com/ethersphere/bee.commitTime={{ .CommitTimestamp }} - - -X github.com/ethersphere/bee/pkg/api.Version={{ .Env.BEE_API_VERSION }} - - -X github.com/ethersphere/bee/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} + - -X github.com/ethersphere/bee/v2.version={{ .Version }} + - -X github.com/ethersphere/bee/v2.commitHash={{ .ShortCommit }} + - -X github.com/ethersphere/bee/v2.commitTime={{ .CommitTimestamp }} + - -X github.com/ethersphere/bee/v2/pkg/api.Version={{ .Env.BEE_API_VERSION }} + - -X github.com/ethersphere/bee/v2/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} env: - CGO_ENABLED=0 goos: @@ -85,11 +85,11 @@ builds: - -trimpath ldflags: - -s -w - - -X github.com/ethersphere/bee.version={{ .Version }} - - -X github.com/ethersphere/bee.commitHash={{ .ShortCommit }} - - -X github.com/ethersphere/bee.commitTime={{ .CommitTimestamp }} - - -X github.com/ethersphere/bee/pkg/api.Version={{ .Env.BEE_API_VERSION }} - - -X github.com/ethersphere/bee/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} + - -X github.com/ethersphere/bee/v2.version={{ .Version }} + - -X github.com/ethersphere/bee/v2.commitHash={{ .ShortCommit }} + - -X github.com/ethersphere/bee/v2.commitTime={{ .CommitTimestamp }} + - -X github.com/ethersphere/bee/v2/pkg/api.Version={{ .Env.BEE_API_VERSION }} + - -X github.com/ethersphere/bee/v2/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} env: - CGO_ENABLED=0 goos: @@ -104,11 +104,11 @@ builds: - -trimpath ldflags: - -s -w - - -X github.com/ethersphere/bee.version={{ .Version }} - - -X github.com/ethersphere/bee.commitHash={{ .ShortCommit }} - - -X github.com/ethersphere/bee.commitTime={{ .CommitTimestamp }} - - -X github.com/ethersphere/bee/pkg/api.Version={{ .Env.BEE_API_VERSION }} - - -X github.com/ethersphere/bee/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} + - -X github.com/ethersphere/bee/v2.version={{ .Version }} + - -X github.com/ethersphere/bee/v2.commitHash={{ .ShortCommit }} + - -X github.com/ethersphere/bee/v2.commitTime={{ .CommitTimestamp }} + - -X github.com/ethersphere/bee/v2/pkg/api.Version={{ .Env.BEE_API_VERSION }} + - -X github.com/ethersphere/bee/v2/pkg/debugapi.Version={{ .Env.BEE_DEBUG_API_VERSION }} env: - CGO_ENABLED=0 goos: diff --git a/Makefile b/Makefile index f245354331c..46da4995b14 100644 --- a/Makefile +++ b/Makefile @@ -20,13 +20,13 @@ COMMIT_HASH ?= "$(shell git describe --long --dirty --always --match "" || true) CLEAN_COMMIT ?= "$(shell git describe --long --always --match "" || true)" COMMIT_TIME ?= "$(shell git show -s --format=%ct $(CLEAN_COMMIT) || true)" LDFLAGS ?= -s -w \ --X github.com/ethersphere/bee.version="$(VERSION)" \ --X github.com/ethersphere/bee.commitHash="$(COMMIT_HASH)" \ --X github.com/ethersphere/bee.commitTime="$(COMMIT_TIME)" \ --X github.com/ethersphere/bee/pkg/api.Version="$(BEE_API_VERSION)" \ --X github.com/ethersphere/bee/pkg/api.DebugVersion="$(BEE_DEBUG_API_VERSION)" \ --X github.com/ethersphere/bee/pkg/p2p/libp2p.reachabilityOverridePublic="$(REACHABILITY_OVERRIDE_PUBLIC)" \ --X github.com/ethersphere/bee/pkg/postage/listener.batchFactorOverridePublic="$(BATCHFACTOR_OVERRIDE_PUBLIC)" +-X github.com/ethersphere/bee/v2.version="$(VERSION)" \ +-X github.com/ethersphere/bee/v2.commitHash="$(COMMIT_HASH)" \ +-X github.com/ethersphere/bee/v2.commitTime="$(COMMIT_TIME)" \ +-X github.com/ethersphere/bee/v2/pkg/api.Version="$(BEE_API_VERSION)" \ +-X github.com/ethersphere/bee/v2/pkg/api.DebugVersion="$(BEE_DEBUG_API_VERSION)" \ +-X github.com/ethersphere/bee/v2/pkg/p2p/libp2p.reachabilityOverridePublic="$(REACHABILITY_OVERRIDE_PUBLIC)" \ +-X github.com/ethersphere/bee/v2/pkg/postage/listener.batchFactorOverridePublic="$(BATCHFACTOR_OVERRIDE_PUBLIC)" .PHONY: all all: build lint test-race binary diff --git a/cmd/bee/cmd/cmd.go b/cmd/bee/cmd/cmd.go index ffe6bc06d01..7082adf4d19 100644 --- a/cmd/bee/cmd/cmd.go +++ b/cmd/bee/cmd/cmd.go @@ -13,78 +13,80 @@ import ( "strings" "time" - chaincfg "github.com/ethersphere/bee/pkg/config" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/node" - "github.com/ethersphere/bee/pkg/swarm" + chaincfg "github.com/ethersphere/bee/v2/pkg/config" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/node" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/spf13/cobra" "github.com/spf13/viper" ) const ( - optionNameDataDir = "data-dir" - optionNameCacheCapacity = "cache-capacity" - optionNameDBOpenFilesLimit = "db-open-files-limit" - optionNameDBBlockCacheCapacity = "db-block-cache-capacity" - optionNameDBWriteBufferSize = "db-write-buffer-size" - optionNameDBDisableSeeksCompaction = "db-disable-seeks-compaction" - optionNamePassword = "password" - optionNamePasswordFile = "password-file" - optionNameAPIAddr = "api-addr" - optionNameP2PAddr = "p2p-addr" - optionNameNATAddr = "nat-addr" - optionNameP2PWSEnable = "p2p-ws-enable" - optionNameDebugAPIEnable = "debug-api-enable" - optionNameDebugAPIAddr = "debug-api-addr" - optionNameBootnodes = "bootnode" - optionNameNetworkID = "network-id" - optionWelcomeMessage = "welcome-message" - optionCORSAllowedOrigins = "cors-allowed-origins" - optionNameTracingEnabled = "tracing-enable" - optionNameTracingEndpoint = "tracing-endpoint" - optionNameTracingHost = "tracing-host" - optionNameTracingPort = "tracing-port" - optionNameTracingServiceName = "tracing-service-name" - optionNameVerbosity = "verbosity" - optionNamePaymentThreshold = "payment-threshold" - optionNamePaymentTolerance = "payment-tolerance-percent" - optionNamePaymentEarly = "payment-early-percent" - optionNameResolverEndpoints = "resolver-options" - optionNameBootnodeMode = "bootnode-mode" - optionNameClefSignerEnable = "clef-signer-enable" - optionNameClefSignerEndpoint = "clef-signer-endpoint" - optionNameClefSignerEthereumAddress = "clef-signer-ethereum-address" - optionNameSwapEndpoint = "swap-endpoint" // deprecated: use rpc endpoint instead - optionNameBlockchainRpcEndpoint = "blockchain-rpc-endpoint" - optionNameSwapFactoryAddress = "swap-factory-address" - optionNameSwapInitialDeposit = "swap-initial-deposit" - optionNameSwapEnable = "swap-enable" - optionNameChequebookEnable = "chequebook-enable" - optionNameSwapDeploymentGasPrice = "swap-deployment-gas-price" - optionNameFullNode = "full-node" - optionNamePostageContractAddress = "postage-stamp-address" - optionNamePostageContractStartBlock = "postage-stamp-start-block" - optionNamePriceOracleAddress = "price-oracle-address" - optionNameRedistributionAddress = "redistribution-address" - optionNameStakingAddress = "staking-address" - optionNameBlockTime = "block-time" - optionWarmUpTime = "warmup-time" - optionNameMainNet = "mainnet" - optionNameRetrievalCaching = "cache-retrieval" - optionNameDevReserveCapacity = "dev-reserve-capacity" - optionNameResync = "resync" - optionNamePProfBlock = "pprof-profile" - optionNamePProfMutex = "pprof-mutex" - optionNameStaticNodes = "static-nodes" - optionNameAllowPrivateCIDRs = "allow-private-cidrs" - optionNameSleepAfter = "sleep-after" - optionNameRestrictedAPI = "restricted" - optionNameTokenEncryptionKey = "token-encryption-key" - optionNameAdminPasswordHash = "admin-password" - optionNameUsePostageSnapshot = "use-postage-snapshot" - optionNameStorageIncentivesEnable = "storage-incentives-enable" - optionNameStateStoreCacheCapacity = "statestore-cache-capacity" - optionNameTargetNeighborhood = "target-neighborhood" + optionNameDataDir = "data-dir" + optionNameCacheCapacity = "cache-capacity" + optionNameDBOpenFilesLimit = "db-open-files-limit" + optionNameDBBlockCacheCapacity = "db-block-cache-capacity" + optionNameDBWriteBufferSize = "db-write-buffer-size" + optionNameDBDisableSeeksCompaction = "db-disable-seeks-compaction" + optionNamePassword = "password" + optionNamePasswordFile = "password-file" + optionNameAPIAddr = "api-addr" + optionNameP2PAddr = "p2p-addr" + optionNameNATAddr = "nat-addr" + optionNameP2PWSEnable = "p2p-ws-enable" + optionNameDebugAPIEnable = "debug-api-enable" + optionNameDebugAPIAddr = "debug-api-addr" + optionNameBootnodes = "bootnode" + optionNameNetworkID = "network-id" + optionWelcomeMessage = "welcome-message" + optionCORSAllowedOrigins = "cors-allowed-origins" + optionNameTracingEnabled = "tracing-enable" + optionNameTracingEndpoint = "tracing-endpoint" + optionNameTracingHost = "tracing-host" + optionNameTracingPort = "tracing-port" + optionNameTracingServiceName = "tracing-service-name" + optionNameVerbosity = "verbosity" + optionNamePaymentThreshold = "payment-threshold" + optionNamePaymentTolerance = "payment-tolerance-percent" + optionNamePaymentEarly = "payment-early-percent" + optionNameResolverEndpoints = "resolver-options" + optionNameBootnodeMode = "bootnode-mode" + optionNameClefSignerEnable = "clef-signer-enable" + optionNameClefSignerEndpoint = "clef-signer-endpoint" + optionNameClefSignerEthereumAddress = "clef-signer-ethereum-address" + optionNameSwapEndpoint = "swap-endpoint" // deprecated: use rpc endpoint instead + optionNameBlockchainRpcEndpoint = "blockchain-rpc-endpoint" + optionNameSwapFactoryAddress = "swap-factory-address" + optionNameSwapInitialDeposit = "swap-initial-deposit" + optionNameSwapEnable = "swap-enable" + optionNameChequebookEnable = "chequebook-enable" + optionNameSwapDeploymentGasPrice = "swap-deployment-gas-price" + optionNameFullNode = "full-node" + optionNamePostageContractAddress = "postage-stamp-address" + optionNamePostageContractStartBlock = "postage-stamp-start-block" + optionNamePriceOracleAddress = "price-oracle-address" + optionNameRedistributionAddress = "redistribution-address" + optionNameStakingAddress = "staking-address" + optionNameBlockTime = "block-time" + optionWarmUpTime = "warmup-time" + optionNameMainNet = "mainnet" + optionNameRetrievalCaching = "cache-retrieval" + optionNameDevReserveCapacity = "dev-reserve-capacity" + optionNameResync = "resync" + optionNamePProfBlock = "pprof-profile" + optionNamePProfMutex = "pprof-mutex" + optionNameStaticNodes = "static-nodes" + optionNameAllowPrivateCIDRs = "allow-private-cidrs" + optionNameSleepAfter = "sleep-after" + optionNameRestrictedAPI = "restricted" + optionNameTokenEncryptionKey = "token-encryption-key" + optionNameAdminPasswordHash = "admin-password" + optionNameUsePostageSnapshot = "use-postage-snapshot" + optionNameStorageIncentivesEnable = "storage-incentives-enable" + optionNameStateStoreCacheCapacity = "statestore-cache-capacity" + optionNameTargetNeighborhood = "target-neighborhood" + optionNameNeighborhoodSuggester = "neighborhood-suggester" + optionNameWhitelistedWithdrawalAddress = "withdrawal-addresses-whitelist" ) // nolint:gochecknoinits @@ -302,6 +304,8 @@ func (c *command) setAllFlags(cmd *cobra.Command) { cmd.Flags().Bool(optionNameStorageIncentivesEnable, true, "enable storage incentives feature") cmd.Flags().Uint64(optionNameStateStoreCacheCapacity, 100_000, "lru memory caching capacity in number of statestore entries") cmd.Flags().String(optionNameTargetNeighborhood, "", "neighborhood to target in binary format (ex: 111111001) for mining the initial overlay") + cmd.Flags().String(optionNameNeighborhoodSuggester, "https://api.swarmscan.io/v1/network/neighborhoods/suggestion", "suggester for target neighborhood") + cmd.Flags().StringSlice(optionNameWhitelistedWithdrawalAddress, []string{}, "withdrawal target addresses") } func newLogger(cmd *cobra.Command, verbosity string) (log.Logger, error) { diff --git a/cmd/bee/cmd/cmd_test.go b/cmd/bee/cmd/cmd_test.go index 7844e4eb342..e7a8cfdb11d 100644 --- a/cmd/bee/cmd/cmd_test.go +++ b/cmd/bee/cmd/cmd_test.go @@ -9,7 +9,7 @@ import ( "os" "testing" - "github.com/ethersphere/bee/cmd/bee/cmd" + "github.com/ethersphere/bee/v2/cmd/bee/cmd" ) var homeDir string diff --git a/cmd/bee/cmd/db.go b/cmd/bee/cmd/db.go index ec94ff7f6d8..882aa02f3b0 100644 --- a/cmd/bee/cmd/db.go +++ b/cmd/bee/cmd/db.go @@ -18,11 +18,11 @@ import ( "strings" "time" - "github.com/ethersphere/bee/pkg/node" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/node" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/spf13/cobra" ) diff --git a/cmd/bee/cmd/db_test.go b/cmd/bee/cmd/db_test.go index 02dcb66b571..3b07d3bf1ea 100644 --- a/cmd/bee/cmd/db_test.go +++ b/cmd/bee/cmd/db_test.go @@ -12,15 +12,15 @@ import ( "strings" "testing" - "github.com/ethersphere/bee/cmd/bee/cmd" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/node" - "github.com/ethersphere/bee/pkg/postage" - storagetest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - kademlia "github.com/ethersphere/bee/pkg/topology/mock" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/cmd/bee/cmd" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/node" + "github.com/ethersphere/bee/v2/pkg/postage" + storagetest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + kademlia "github.com/ethersphere/bee/v2/pkg/topology/mock" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) func TestDBExportImport(t *testing.T) { diff --git a/cmd/bee/cmd/deploy.go b/cmd/bee/cmd/deploy.go index 7b3e8e57734..988918bd074 100644 --- a/cmd/bee/cmd/deploy.go +++ b/cmd/bee/cmd/deploy.go @@ -8,8 +8,8 @@ import ( "fmt" "strings" - "github.com/ethersphere/bee/pkg/node" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" + "github.com/ethersphere/bee/v2/pkg/node" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" "github.com/spf13/cobra" ) diff --git a/cmd/bee/cmd/init.go b/cmd/bee/cmd/init.go index ea56381eea9..3df6b7aeb18 100644 --- a/cmd/bee/cmd/init.go +++ b/cmd/bee/cmd/init.go @@ -8,7 +8,7 @@ import ( "fmt" "strings" - "github.com/ethersphere/bee/pkg/node" + "github.com/ethersphere/bee/v2/pkg/node" "github.com/spf13/cobra" ) diff --git a/cmd/bee/cmd/split.go b/cmd/bee/cmd/split.go index e173ae186fa..e5db047a43e 100644 --- a/cmd/bee/cmd/split.go +++ b/cmd/bee/cmd/split.go @@ -9,41 +9,62 @@ import ( "fmt" "io" "os" + "path/filepath" "strings" + "sync/atomic" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/spf13/cobra" ) // putter is a putter that stores all the split chunk addresses of a file type putter struct { - chunkAddresses []string + cb func(chunk swarm.Chunk) error } -func (s *putter) Put(ctx context.Context, chunk swarm.Chunk) error { - s.chunkAddresses = append(s.chunkAddresses, chunk.Address().String()) - return nil +func (s *putter) Put(_ context.Context, chunk swarm.Chunk) error { + return s.cb(chunk) +} +func newPutter(cb func(ch swarm.Chunk) error) *putter { + return &putter{ + cb: cb, + } } var _ storage.Putter = (*putter)(nil) type pipelineFunc func(context.Context, io.Reader) (swarm.Address, error) -func requestPipelineFn(s storage.Putter, encrypt bool) pipelineFunc { +func requestPipelineFn(s storage.Putter, encrypt bool, rLevel redundancy.Level) pipelineFunc { return func(ctx context.Context, r io.Reader) (swarm.Address, error) { - pipe := builder.NewPipelineBuilder(ctx, s, encrypt, 0) + pipe := builder.NewPipelineBuilder(ctx, s, encrypt, rLevel) return builder.FeedPipeline(ctx, pipe, r) } } func (c *command) initSplitCmd() error { - optionNameInputFile := "input-file" - optionNameOutputFile := "output-file" cmd := &cobra.Command{ Use: "split", - Short: "Split a file into a list chunks. The 1st line is the root hash", + Short: "Split a file into chunks", + } + + splitRefs(cmd) + splitChunks(cmd) + c.root.AddCommand(cmd) + return nil +} + +func splitRefs(cmd *cobra.Command) { + optionNameInputFile := "input-file" + optionNameOutputFile := "output-file" + optionNameRedundancyLevel := "r-level" + + c := &cobra.Command{ + Use: "refs", + Short: "Write only the chunk reference to the output file", RunE: func(cmd *cobra.Command, args []string) error { inputFileName, err := cmd.Flags().GetString(optionNameInputFile) if err != nil { @@ -53,6 +74,10 @@ func (c *command) initSplitCmd() error { if err != nil { return fmt.Errorf("get output file name: %w", err) } + rLevel, err := cmd.Flags().GetInt(optionNameRedundancyLevel) + if err != nil { + return fmt.Errorf("get redundancy level: %w", err) + } v, err := cmd.Flags().GetString(optionNameVerbosity) if err != nil { @@ -70,44 +95,124 @@ func (c *command) initSplitCmd() error { } defer reader.Close() - logger.Info("splitting", "file", inputFileName) - store := new(putter) - - p := requestPipelineFn(store, false) - address, err := p(context.Background(), reader) - if err != nil { - return fmt.Errorf("bmt pipeline: %w", err) - } - + logger.Info("splitting", "file", inputFileName, "rLevel", rLevel) logger.Info("writing output", "file", outputFileName) + + var refs []string + store := newPutter(func(ch swarm.Chunk) error { + refs = append(refs, ch.Address().String()) + return nil + }) writer, err := os.OpenFile(outputFileName, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) if err != nil { return fmt.Errorf("open output file: %w", err) } defer writer.Close() - logger.Debug("write root", "hash", address) - _, err = writer.WriteString(fmt.Sprintf("%s\n", address)) + p := requestPipelineFn(store, false, redundancy.Level(rLevel)) + rootRef, err := p(context.Background(), reader) + if err != nil { + return fmt.Errorf("pipeline: %w", err) + } + + logger.Debug("write root", "hash", rootRef) + _, err = writer.WriteString(fmt.Sprintf("%s\n", rootRef)) if err != nil { return fmt.Errorf("write root hash: %w", err) } - for _, chunkAddress := range store.chunkAddresses { - logger.Debug("write chunk", "hash", chunkAddress) - _, err = writer.WriteString(fmt.Sprintf("%s\n", chunkAddress)) + for _, ref := range refs { + logger.Debug("write chunk", "hash", ref) + _, err = writer.WriteString(fmt.Sprintf("%s\n", ref)) if err != nil { return fmt.Errorf("write chunk address: %w", err) } } - logger.Info("done", "hashes", len(store.chunkAddresses)) + logger.Info("done", "root", rootRef.String(), "chunks", len(refs)) return nil }, } - cmd.Flags().String(optionNameVerbosity, "info", "verbosity level") - cmd.Flags().String(optionNameInputFile, "", "input file") - cmd.Flags().String(optionNameOutputFile, "", "output file") - cmd.MarkFlagsRequiredTogether(optionNameInputFile, optionNameOutputFile) + c.Flags().String(optionNameInputFile, "", "input file") + c.Flags().String(optionNameOutputFile, "", "output file") + c.Flags().Int(optionNameRedundancyLevel, 0, "redundancy level") + c.Flags().String(optionNameVerbosity, "info", "verbosity level") - c.root.AddCommand(cmd) - return nil + c.MarkFlagsRequiredTogether(optionNameInputFile, optionNameOutputFile) + + cmd.AddCommand(c) +} + +func splitChunks(cmd *cobra.Command) { + optionNameInputFile := "input-file" + optionNameOutputDir := "output-dir" + optionNameRedundancyLevel := "r-level" + + c := &cobra.Command{ + Use: "chunks", + Short: "Write the chunks to the output directory", + RunE: func(cmd *cobra.Command, args []string) error { + inputFileName, err := cmd.Flags().GetString(optionNameInputFile) + if err != nil { + return fmt.Errorf("get input file name: %w", err) + } + outputDir, err := cmd.Flags().GetString(optionNameOutputDir) + if err != nil { + return fmt.Errorf("get output file name: %w", err) + } + info, err := os.Stat(outputDir) + if err != nil { + return fmt.Errorf("stat output dir: %w", err) + } + if !info.IsDir() { + return fmt.Errorf("output dir %s is not a directory", outputDir) + } + rLevel, err := cmd.Flags().GetInt(optionNameRedundancyLevel) + if err != nil { + return fmt.Errorf("get redundancy level: %w", err) + } + v, err := cmd.Flags().GetString(optionNameVerbosity) + if err != nil { + return fmt.Errorf("get verbosity: %w", err) + } + v = strings.ToLower(v) + logger, err := newLogger(cmd, v) + if err != nil { + return fmt.Errorf("new logger: %w", err) + } + reader, err := os.Open(inputFileName) + if err != nil { + return fmt.Errorf("open input file: %w", err) + } + defer reader.Close() + + logger.Info("splitting", "file", inputFileName, "rLevel", rLevel) + logger.Info("writing output", "dir", outputDir) + + var chunksCount atomic.Int64 + store := newPutter(func(chunk swarm.Chunk) error { + filePath := filepath.Join(outputDir, chunk.Address().String()) + err := os.WriteFile(filePath, chunk.Data(), 0644) + if err != nil { + return err + } + chunksCount.Add(1) + return nil + }) + + p := requestPipelineFn(store, false, redundancy.Level(rLevel)) + rootRef, err := p(context.Background(), reader) + if err != nil { + return fmt.Errorf("pipeline: %w", err) + } + logger.Info("done", "root", rootRef.String(), "chunks", chunksCount.Load()) + return nil + }, + } + c.Flags().String(optionNameInputFile, "", "input file") + c.Flags().String(optionNameOutputDir, "", "output dir") + c.Flags().Int(optionNameRedundancyLevel, 0, "redundancy level") + c.Flags().String(optionNameVerbosity, "info", "verbosity level") + c.MarkFlagsRequiredTogether(optionNameInputFile, optionNameOutputDir) + + cmd.AddCommand(c) } diff --git a/cmd/bee/cmd/split_test.go b/cmd/bee/cmd/split_test.go index 4151a69b5b7..4e819d6f46e 100644 --- a/cmd/bee/cmd/split_test.go +++ b/cmd/bee/cmd/split_test.go @@ -6,17 +6,26 @@ package cmd_test import ( "bufio" + "bytes" + "context" crand "crypto/rand" + "io" "math/rand" "os" "path" + "path/filepath" + "sync" "testing" - "github.com/ethersphere/bee/cmd/bee/cmd" - "github.com/ethersphere/bee/pkg/api" + "github.com/ethersphere/bee/v2/cmd/bee/cmd" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) -func TestDBSplit(t *testing.T) { +func TestDBSplitRefs(t *testing.T) { t.Parallel() s := (rand.Intn(10) + 10) * 1024 // rand between 10 and 20 KB @@ -34,7 +43,7 @@ func TestDBSplit(t *testing.T) { outputFileName := path.Join(t.TempDir(), "output") - err = newCommand(t, cmd.WithArgs("split", "--input-file", inputFileName, "--output-file", outputFileName)).Execute() + err = newCommand(t, cmd.WithArgs("split", "refs", "--input-file", inputFileName, "--output-file", outputFileName)).Execute() if err != nil { t.Fatal(err) } @@ -60,3 +69,106 @@ func TestDBSplit(t *testing.T) { t.Fatalf("got %d hashes, want %d", gotHashes, wantHashes) } } + +func TestDBSplitChunks(t *testing.T) { + t.Parallel() + + s := (rand.Intn(10) + 10) * 1024 // rand between 10 and 20 KB + buf := make([]byte, s) + _, err := crand.Read(buf) + if err != nil { + t.Fatal(err) + } + + inputFileName := path.Join(t.TempDir(), "input") + err = os.WriteFile(inputFileName, buf, 0644) + if err != nil { + t.Fatal(err) + } + + dir := path.Join(t.TempDir(), "chunks") + err = os.Mkdir(dir, os.ModePerm) + if err != nil { + t.Fatal(err) + } + + err = newCommand(t, cmd.WithArgs("split", "chunks", "--input-file", inputFileName, "--output-dir", dir, "--r-level", "3")).Execute() + if err != nil { + t.Fatal(err) + } + + // split the file manually and compare output with the split commands output. + putter := &putter{chunks: make(map[string]swarm.Chunk)} + p := requestPipelineFn(putter, false, redundancy.Level(3)) + _, err = p(context.Background(), bytes.NewReader(buf)) + if err != nil { + t.Fatal(err) + } + + entries, err := os.ReadDir(dir) + if err != nil { + t.Fatal(err) + } + + if len(entries) != len(putter.chunks) { + t.Fatal("number of chunks does not match") + } + for _, entry := range entries { + ref := entry.Name() + if _, ok := putter.chunks[ref]; !ok { + t.Fatalf("chunk %s not found", ref) + } + err, ok := compare(filepath.Join(dir, ref), putter.chunks[ref]) + if err != nil { + t.Fatal(err) + } + if !ok { + t.Fatalf("chunk %s does not match", ref) + } + delete(putter.chunks, ref) + } + + if len(putter.chunks) != 0 { + t.Fatalf("want 0 chunks left, got %d", len(putter.chunks)) + } +} + +func compare(path string, chunk swarm.Chunk) (error, bool) { + f, err := os.Open(path) + if err != nil { + return err, false + } + defer f.Close() + + b, err := io.ReadAll(f) + if err != nil { + return err, false + } + + if !bytes.Equal(b, chunk.Data()) { + return nil, false + } + + return nil, true +} + +type putter struct { + chunks map[string]swarm.Chunk + mu sync.Mutex +} + +func (s *putter) Put(_ context.Context, chunk swarm.Chunk) error { + s.mu.Lock() + defer s.mu.Unlock() + s.chunks[chunk.Address().String()] = chunk + return nil +} + +type pipelineFunc func(context.Context, io.Reader) (swarm.Address, error) + +func requestPipelineFn(s storage.Putter, encrypt bool, rLevel redundancy.Level) pipelineFunc { + return func(ctx context.Context, r io.Reader) (swarm.Address, error) { + pipe := builder.NewPipelineBuilder(ctx, s, encrypt, rLevel) + return builder.FeedPipeline(ctx, pipe, r) + } +} diff --git a/cmd/bee/cmd/start.go b/cmd/bee/cmd/start.go index ee287a2104a..4e967285428 100644 --- a/cmd/bee/cmd/start.go +++ b/cmd/bee/cmd/start.go @@ -23,18 +23,18 @@ import ( "github.com/ethereum/go-ethereum/accounts/external" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rpc" - "github.com/ethersphere/bee" - chaincfg "github.com/ethersphere/bee/pkg/config" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/crypto/clef" - "github.com/ethersphere/bee/pkg/keystore" - filekeystore "github.com/ethersphere/bee/pkg/keystore/file" - memkeystore "github.com/ethersphere/bee/pkg/keystore/mem" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/node" - "github.com/ethersphere/bee/pkg/resolver/multiresolver" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2" + chaincfg "github.com/ethersphere/bee/v2/pkg/config" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto/clef" + "github.com/ethersphere/bee/v2/pkg/keystore" + filekeystore "github.com/ethersphere/bee/v2/pkg/keystore/file" + memkeystore "github.com/ethersphere/bee/v2/pkg/keystore/mem" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/node" + "github.com/ethersphere/bee/v2/pkg/resolver/multiresolver" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/kardianos/service" "github.com/spf13/cobra" ) @@ -287,6 +287,11 @@ func buildBeeNode(ctx context.Context, c *command, cmd *cobra.Command, logger lo blockchainRpcEndpoint = swapEndpoint } + var neighborhoodSuggester string + if networkID == chaincfg.Mainnet.NetworkID { + neighborhoodSuggester = c.config.GetString(optionNameNeighborhoodSuggester) + } + b, err := node.NewBee(ctx, c.config.GetString(optionNameP2PAddr), signerConfig.publicKey, signerConfig.signer, networkID, logger, signerConfig.libp2pPrivateKey, signerConfig.pssPrivateKey, &node.Options{ DataDir: c.config.GetString(optionNameDataDir), CacheCapacity: c.config.GetUint64(optionNameCacheCapacity), @@ -339,6 +344,8 @@ func buildBeeNode(ctx context.Context, c *command, cmd *cobra.Command, logger lo EnableStorageIncentives: c.config.GetBool(optionNameStorageIncentivesEnable), StatestoreCacheCapacity: c.config.GetUint64(optionNameStateStoreCacheCapacity), TargetNeighborhood: c.config.GetString(optionNameTargetNeighborhood), + NeighborhoodSuggester: neighborhoodSuggester, + WhitelistedWithdrawalAddress: c.config.GetStringSlice(optionNameWhitelistedWithdrawalAddress), }) return b, err diff --git a/cmd/bee/cmd/start_dev.go b/cmd/bee/cmd/start_dev.go index 39b9e32d35b..a372094bf20 100644 --- a/cmd/bee/cmd/start_dev.go +++ b/cmd/bee/cmd/start_dev.go @@ -11,7 +11,7 @@ import ( "strings" "syscall" - "github.com/ethersphere/bee/pkg/node" + "github.com/ethersphere/bee/v2/pkg/node" "github.com/kardianos/service" "github.com/spf13/cobra" ) diff --git a/cmd/bee/cmd/start_unix.go b/cmd/bee/cmd/start_unix.go index e50f8e54bfb..19e3d5b7807 100644 --- a/cmd/bee/cmd/start_unix.go +++ b/cmd/bee/cmd/start_unix.go @@ -9,7 +9,7 @@ package cmd import ( "errors" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/log" ) func isWindowsService() (bool, error) { diff --git a/cmd/bee/cmd/start_windows.go b/cmd/bee/cmd/start_windows.go index 419cc3f7eb0..3153e80041c 100644 --- a/cmd/bee/cmd/start_windows.go +++ b/cmd/bee/cmd/start_windows.go @@ -13,7 +13,7 @@ import ( "golang.org/x/sys/windows/svc/debug" "golang.org/x/sys/windows/svc/eventlog" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/log" ) func isWindowsService() (bool, error) { diff --git a/cmd/bee/cmd/timebomb.go b/cmd/bee/cmd/timebomb.go index c1013795757..f53f74627c3 100644 --- a/cmd/bee/cmd/timebomb.go +++ b/cmd/bee/cmd/timebomb.go @@ -8,8 +8,8 @@ import ( "strconv" "time" - "github.com/ethersphere/bee" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2" + "github.com/ethersphere/bee/v2/pkg/log" ) const ( diff --git a/cmd/bee/cmd/version.go b/cmd/bee/cmd/version.go index c438838f13d..d5ea260d859 100644 --- a/cmd/bee/cmd/version.go +++ b/cmd/bee/cmd/version.go @@ -5,7 +5,7 @@ package cmd import ( - "github.com/ethersphere/bee" + "github.com/ethersphere/bee/v2" "github.com/spf13/cobra" ) diff --git a/cmd/bee/cmd/version_test.go b/cmd/bee/cmd/version_test.go index 9bbc327bf6f..982e5e0edcf 100644 --- a/cmd/bee/cmd/version_test.go +++ b/cmd/bee/cmd/version_test.go @@ -8,8 +8,8 @@ import ( "bytes" "testing" - "github.com/ethersphere/bee" - "github.com/ethersphere/bee/cmd/bee/cmd" + "github.com/ethersphere/bee/v2" + "github.com/ethersphere/bee/v2/cmd/bee/cmd" ) func TestVersionCmd(t *testing.T) { diff --git a/cmd/bee/main.go b/cmd/bee/main.go index 575ffeb4498..a7b953b8cd0 100644 --- a/cmd/bee/main.go +++ b/cmd/bee/main.go @@ -8,7 +8,7 @@ import ( "fmt" "os" - "github.com/ethersphere/bee/cmd/bee/cmd" + "github.com/ethersphere/bee/v2/cmd/bee/cmd" ) func main() { diff --git a/go.mod b/go.mod index 5d3e61c85ec..2bb64394f18 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/ethersphere/bee +module github.com/ethersphere/bee/v2 go 1.21 @@ -148,7 +148,7 @@ require ( github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/qtls-go1-20 v0.3.3 // indirect - github.com/quic-go/quic-go v0.38.1 // indirect + github.com/quic-go/quic-go v0.38.2 // indirect github.com/quic-go/webtransport-go v0.5.3 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect github.com/shirou/gopsutil v3.21.5+incompatible // indirect diff --git a/go.sum b/go.sum index c2938b6ec32..6799b8b5a71 100644 --- a/go.sum +++ b/go.sum @@ -793,8 +793,8 @@ github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM= github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE= -github.com/quic-go/quic-go v0.38.1/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= +github.com/quic-go/quic-go v0.38.2 h1:VWv/6gxIoB8hROQJhx1JEyiegsUQ+zMN3em3kynTGdg= +github.com/quic-go/quic-go v0.38.2/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= github.com/quic-go/webtransport-go v0.5.3 h1:5XMlzemqB4qmOlgIus5zB45AcZ2kCgCy2EptUrfOPWU= github.com/quic-go/webtransport-go v0.5.3/go.mod h1:OhmmgJIzTTqXK5xvtuX0oBpLV2GkLWNDA+UeTGJXErU= github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= diff --git a/openapi/Swarm.yaml b/openapi/Swarm.yaml index 61b446d1095..72e41ec5665 100644 --- a/openapi/Swarm.yaml +++ b/openapi/Swarm.yaml @@ -179,6 +179,26 @@ paths: $ref: "SwarmCommon.yaml#/components/responses/400" default: description: Default response + head: + summary: Requests the headers containing the content type and length for the reference + tags: + - Bytes + parameters: + - in: path + name: address + schema: + $ref: "SwarmCommon.yaml#/components/schemas/SwarmAddress" + required: true + description: Swarm address of chunk + responses: + "200": + description: Chunk exists + "400": + $ref: "SwarmCommon.yaml#/components/responses/400" + "404": + $ref: "SwarmCommon.yaml#/components/responses/404" + default: + description: Default response "/chunks": post: @@ -332,6 +352,26 @@ paths: $ref: "SwarmCommon.yaml#/components/responses/500" default: description: Default response + head: + summary: Get the headers containing the content type and length for the reference + tags: + - BZZ + parameters: + - in: path + name: address + schema: + $ref: "SwarmCommon.yaml#/components/schemas/SwarmAddress" + required: true + description: Swarm address of chunk + responses: + "200": + description: Chunk exists + "400": + $ref: "SwarmCommon.yaml#/components/responses/400" + "404": + $ref: "SwarmCommon.yaml#/components/responses/404" + default: + description: Default response "/bzz/{reference}/{path}": get: @@ -598,6 +638,30 @@ paths: default: description: Default response + "/pins/check": + get: + summary: Validate pinned chunks integerity + tags: + - Pinning + parameters: + - in: query + name: ref + schema: + $ref: "SwarmCommon.yaml#/components/schemas/SwarmOnlyReference" + required: false + description: The number of items to skip before starting to collect the result set. + responses: + "200": + description: List of checked root hash references + content: + application/json: + schema: + $ref: "SwarmCommon.yaml#/components/schemas/PinCheckResponse" + "500": + $ref: "SwarmCommon.yaml#/components/responses/500" + default: + description: Default response + "/pss/send/{topic}/{targets}": post: summary: Send to recipient or target with Postal Service for Swarm @@ -1913,6 +1977,44 @@ paths: default: description: Default response + "/rchash/{depth}/{anchor1}/{anchor2}": + get: + summary: Get reserve commitment hash with sample proofs + tags: + - RChash + parameters: + - in: path + name: depth + schema: + type: integer + minimum: 0 + default: 0 + required: true + description: The storage depth. + - in: path + name: anchor1 + schema: + $ref: "#/components/schemas/HexString" + required: true + description: The first anchor. + - in: path + name: anchor2 + schema: + $ref: "#/components/schemas/HexString" + required: true + description: The second anchor. + responses: + "200": + description: Reserve sample response + content: + application/json: + schema: + $ref: "SwarmCommon.yaml#/components/schemas/ApiRCHashResponse" + "500": + $ref: "SwarmCommon.yaml#/components/responses/500" + default: + description: Default response + components: securitySchemes: basicAuth: diff --git a/openapi/SwarmCommon.yaml b/openapi/SwarmCommon.yaml index 07119cc6894..21ede2e5400 100644 --- a/openapi/SwarmCommon.yaml +++ b/openapi/SwarmCommon.yaml @@ -1,6 +1,6 @@ openapi: 3.0.3 info: - version: 3.2.6 + version: 3.2.7 title: Common Data Types description: | \*****bzzz***** @@ -602,15 +602,28 @@ components: - $ref: "#/components/schemas/SwarmAddress" - $ref: "#/components/schemas/SwarmEncryptedReference" + PinCheckResponse: + type: object + properties: + reference: + $ref: "#/components/schemas/SwarmOnlyReference" + total: + type: integer + missing: + type: integer + invalid: + type: integer + SwarmOnlyReferencesList: type: object properties: - references: + reference: type: array nullable: false items: $ref: "#/components/schemas/SwarmOnlyReference" + SwarmReference: oneOf: - $ref: "#/components/schemas/SwarmAddress" @@ -839,6 +852,8 @@ components: type: integer reserveSize: type: integer + reserveSizeWithinRadius: + type: interger pullsyncRate: type: number storageRadius: @@ -864,6 +879,83 @@ components: items: $ref: "#/components/schemas/StatusSnapshotResponse" + ApiChunkInclusionProof: + type: object + properties: + chunkSpan: + minimum: 0 + type: integer + postageProof: + $ref: '#/components/schemas/ApiPostageProof' + proofSegments: + items: + type: string + nullable: true + type: array + proofSegments2: + items: + type: string + nullable: true + type: array + proofSegments3: + items: + type: string + nullable: true + type: array + proveSegment: + type: string + proveSegment2: + type: string + socProof: + items: + $ref: '#/components/schemas/ApiSOCProof' + nullable: true + type: array + + ApiChunkInclusionProofs: + type: object + properties: + proof1: + $ref: '#/components/schemas/ApiChunkInclusionProof' + proof2: + $ref: '#/components/schemas/ApiChunkInclusionProof' + proofLast: + $ref: '#/components/schemas/ApiChunkInclusionProof' + + ApiPostageProof: + type: object + properties: + index: + type: string + postageId: + type: string + signature: + type: string + timeStamp: + type: string + + ApiRCHashResponse: + type: object + properties: + duration: + type: integer + hash: + $ref: '#/components/schemas/SwarmAddress' + proofs: + $ref: '#/components/schemas/ApiChunkInclusionProofs' + + ApiSOCProof: + type: object + properties: + chunkAddr: + type: string + identifier: + type: string + signature: + type: string + signer: + type: string + headers: SwarmTag: description: "Tag UID" @@ -1041,6 +1133,8 @@ components: description: "Determines if the download data should be cached on the node. By default the download will be cached" responses: + "200": + description: OK. "204": description: The resource was deleted successfully. "400": diff --git a/openapi/SwarmDebug.yaml b/openapi/SwarmDebug.yaml index 11d7b1a5fdb..516fba3399d 100644 --- a/openapi/SwarmDebug.yaml +++ b/openapi/SwarmDebug.yaml @@ -1,6 +1,6 @@ openapi: 3.0.3 info: - version: 4.1.0 + version: 4.1.1 title: Bee Debug API description: "A list of the currently provided debug interfaces to interact with the bee node" @@ -689,6 +689,41 @@ paths: $ref: "SwarmCommon.yaml#/components/responses/500" default: description: Default response + "/wallet/withdraw/{coin}": + post: + summary: Allows withdrawals of BZZ or xDAI to provided (whitelisted) address + tags: + - Wallet + parameters: + - in: query + name: amount + required: true + schema: + $ref: "#/components/schemas/BigInt" + - in: query + name: address + required: true + schema: + $ref: "#/components/schemas/EthereumAddress" + - in: path + name: coin + required: true + schema: + $ref: "#/components/schemas/SwarmAddress" + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/WalletTxResponse' + description: OK + "400": + $ref: "SwarmCommon.yaml#/components/responses/400" + description: Amount greater than ballance or coin is other than BZZ/xDAI + "500": + $ref: "SwarmCommon.yaml#/components/responses/500" + default: + description: Default response "/transactions": get: @@ -1133,3 +1168,11 @@ paths: $ref: "SwarmCommon.yaml#/components/responses/400" default: description: Default response. + +components: + schemas: + WalletTxResponse: + type: object + properties: + transactionHash: + $ref: "#/components/schemas/TransactionHash" diff --git a/pkg/accounting/accounting.go b/pkg/accounting/accounting.go index 787e794b865..5e92596c94f 100644 --- a/pkg/accounting/accounting.go +++ b/pkg/accounting/accounting.go @@ -15,12 +15,12 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/pricing" - "github.com/ethersphere/bee/pkg/settlement/pseudosettle" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/pricing" + "github.com/ethersphere/bee/v2/pkg/settlement/pseudosettle" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // loggerName is the tree path name of the logger for this package. diff --git a/pkg/accounting/accounting_test.go b/pkg/accounting/accounting_test.go index f240325f944..509b5e5e14b 100644 --- a/pkg/accounting/accounting_test.go +++ b/pkg/accounting/accounting_test.go @@ -12,13 +12,13 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - p2pmock "github.com/ethersphere/bee/pkg/p2p/mock" - "github.com/ethersphere/bee/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + p2pmock "github.com/ethersphere/bee/v2/pkg/p2p/mock" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ( diff --git a/pkg/accounting/export_test.go b/pkg/accounting/export_test.go index 85046388c9a..5358b288067 100644 --- a/pkg/accounting/export_test.go +++ b/pkg/accounting/export_test.go @@ -7,7 +7,7 @@ package accounting import ( "time" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func (a *Accounting) SetTimeNow(f func() time.Time) { diff --git a/pkg/accounting/metrics.go b/pkg/accounting/metrics.go index 573bab6ed29..e38bdbbd989 100644 --- a/pkg/accounting/metrics.go +++ b/pkg/accounting/metrics.go @@ -5,7 +5,7 @@ package accounting import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/accounting/mock/accounting.go b/pkg/accounting/mock/accounting.go index 14f0bb9189f..e5e0d98130e 100644 --- a/pkg/accounting/mock/accounting.go +++ b/pkg/accounting/mock/accounting.go @@ -11,8 +11,8 @@ import ( "math/big" "sync" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Service is the mock Accounting service. diff --git a/pkg/addressbook/addressbook.go b/pkg/addressbook/addressbook.go index 3a2eba66493..eafba314d09 100644 --- a/pkg/addressbook/addressbook.go +++ b/pkg/addressbook/addressbook.go @@ -9,9 +9,9 @@ import ( "fmt" "strings" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const keyPrefix = "addressbook_entry_" diff --git a/pkg/addressbook/addressbook_test.go b/pkg/addressbook/addressbook_test.go index 360d7c197f9..1b5c22490b5 100644 --- a/pkg/addressbook/addressbook_test.go +++ b/pkg/addressbook/addressbook_test.go @@ -9,11 +9,11 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/api/accounting.go b/pkg/api/accounting.go index ad8b476fc35..fce1056bbb7 100644 --- a/pkg/api/accounting.go +++ b/pkg/api/accounting.go @@ -7,8 +7,8 @@ package api import ( "net/http" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" ) const ( diff --git a/pkg/api/accounting_test.go b/pkg/api/accounting_test.go index a5e8c28aff9..7a807aa811e 100644 --- a/pkg/api/accounting_test.go +++ b/pkg/api/accounting_test.go @@ -11,12 +11,12 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/accounting/mock" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/accounting/mock" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" ) func TestAccountingInfo(t *testing.T) { diff --git a/pkg/api/api.go b/pkg/api/api.go index 7d6ee42e175..72100cc0d9b 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -27,38 +27,38 @@ import ( "unicode/utf8" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/auth" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/pingpong" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - "github.com/ethersphere/bee/pkg/pss" - "github.com/ethersphere/bee/pkg/resolver" - "github.com/ethersphere/bee/pkg/resolver/client/ens" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/settlement" - "github.com/ethersphere/bee/pkg/settlement/swap" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" - "github.com/ethersphere/bee/pkg/status" - "github.com/ethersphere/bee/pkg/steward" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storageincentives" - "github.com/ethersphere/bee/pkg/storageincentives/staking" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/topology/lightnode" - "github.com/ethersphere/bee/pkg/tracing" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/auth" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/pingpong" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + "github.com/ethersphere/bee/v2/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/resolver" + "github.com/ethersphere/bee/v2/pkg/resolver/client/ens" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/settlement" + "github.com/ethersphere/bee/v2/pkg/settlement/swap" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" + "github.com/ethersphere/bee/v2/pkg/status" + "github.com/ethersphere/bee/v2/pkg/steward" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storageincentives" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/topology/lightnode" + "github.com/ethersphere/bee/v2/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/transaction" "github.com/go-playground/validator/v10" "github.com/gorilla/mux" "github.com/hashicorp/go-multierror" @@ -131,6 +131,10 @@ type Storer interface { storer.Debugger } +type PinIntegrity interface { + Check(ctx context.Context, logger log.Logger, pin string, out chan storer.PinStat) +} + type Service struct { auth auth.Authenticator storer Storer @@ -174,7 +178,9 @@ type Service struct { batchStore postage.Storer stamperStore storage.Store - syncStatus func() (bool, error) + pinIntegrity PinIntegrity + + syncStatus func() (bool, error) swap swap.Interface transaction transaction.Service @@ -191,6 +197,8 @@ type Service struct { erc20Service erc20.Service chainID int64 + whitelistedWithdrawalAddress []common.Address + preMapHooks map[string]func(v string) (string, error) validate *validator.Validate @@ -242,11 +250,13 @@ type ExtraOptions struct { Steward steward.Interface SyncStatus func() (bool, error) NodeStatus *status.Service + PinIntegrity PinIntegrity } func New( publicKey, pssPublicKey ecdsa.PublicKey, ethereumAddress common.Address, + whitelistedWithdrawalAddress []string, logger log.Logger, transaction transaction.Service, batchStore postage.Storer, @@ -296,6 +306,10 @@ func New( }) s.stamperStore = stamperStore + for _, v := range whitelistedWithdrawalAddress { + s.whitelistedWithdrawalAddress = append(s.whitelistedWithdrawalAddress, common.HexToAddress(v)) + } + return s } @@ -348,6 +362,8 @@ func (s *Service) Configure(signer crypto.Signer, auth auth.Authenticator, trace return "", err } } + + s.pinIntegrity = e.PinIntegrity } func (s *Service) SetProbe(probe *Probe) { diff --git a/pkg/api/api_test.go b/pkg/api/api_test.go index b06e5808479..164709b7ca9 100644 --- a/pkg/api/api_test.go +++ b/pkg/api/api_test.go @@ -23,53 +23,53 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - accountingmock "github.com/ethersphere/bee/pkg/accounting/mock" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/auth" - mockauth "github.com/ethersphere/bee/pkg/auth/mock" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" - p2pmock "github.com/ethersphere/bee/pkg/p2p/mock" - "github.com/ethersphere/bee/pkg/pingpong" - "github.com/ethersphere/bee/pkg/postage" - mockbatchstore "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - contractMock "github.com/ethersphere/bee/pkg/postage/postagecontract/mock" - "github.com/ethersphere/bee/pkg/pss" - "github.com/ethersphere/bee/pkg/pusher" - "github.com/ethersphere/bee/pkg/resolver" - resolverMock "github.com/ethersphere/bee/pkg/resolver/mock" - "github.com/ethersphere/bee/pkg/settlement/pseudosettle" - chequebookmock "github.com/ethersphere/bee/pkg/settlement/swap/chequebook/mock" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" - erc20mock "github.com/ethersphere/bee/pkg/settlement/swap/erc20/mock" - swapmock "github.com/ethersphere/bee/pkg/settlement/swap/mock" - "github.com/ethersphere/bee/pkg/spinlock" - statestore "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/status" - "github.com/ethersphere/bee/pkg/steward" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - testingc "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storageincentives" - "github.com/ethersphere/bee/pkg/storageincentives/redistribution" - "github.com/ethersphere/bee/pkg/storageincentives/staking" - mock2 "github.com/ethersphere/bee/pkg/storageincentives/staking/mock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology/lightnode" - topologymock "github.com/ethersphere/bee/pkg/topology/mock" - "github.com/ethersphere/bee/pkg/tracing" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/transaction/backendmock" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/testutil" + accountingmock "github.com/ethersphere/bee/v2/pkg/accounting/mock" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/auth" + mockauth "github.com/ethersphere/bee/v2/pkg/auth/mock" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" + p2pmock "github.com/ethersphere/bee/v2/pkg/p2p/mock" + "github.com/ethersphere/bee/v2/pkg/pingpong" + "github.com/ethersphere/bee/v2/pkg/postage" + mockbatchstore "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + contractMock "github.com/ethersphere/bee/v2/pkg/postage/postagecontract/mock" + "github.com/ethersphere/bee/v2/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/pusher" + "github.com/ethersphere/bee/v2/pkg/resolver" + resolverMock "github.com/ethersphere/bee/v2/pkg/resolver/mock" + "github.com/ethersphere/bee/v2/pkg/settlement/pseudosettle" + chequebookmock "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook/mock" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" + erc20mock "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20/mock" + swapmock "github.com/ethersphere/bee/v2/pkg/settlement/swap/mock" + "github.com/ethersphere/bee/v2/pkg/spinlock" + statestore "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/status" + "github.com/ethersphere/bee/v2/pkg/steward" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + testingc "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storageincentives" + "github.com/ethersphere/bee/v2/pkg/storageincentives/redistribution" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking" + mock2 "github.com/ethersphere/bee/v2/pkg/storageincentives/staking/mock" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology/lightnode" + topologymock "github.com/ethersphere/bee/v2/pkg/topology/mock" + "github.com/ethersphere/bee/v2/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction/backendmock" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "github.com/gorilla/websocket" "resenje.org/web" ) @@ -131,6 +131,8 @@ type testServerOptions struct { BeeMode api.BeeNodeMode RedistributionAgent *storageincentives.Agent NodeStatus *status.Service + PinIntegrity api.PinIntegrity + WhitelistedAddr string } func newTestServer(t *testing.T, o testServerOptions) (*http.Client, *websocket.Conn, string, *chanStorer) { @@ -201,6 +203,7 @@ func newTestServer(t *testing.T, o testServerOptions) (*http.Client, *websocket. SyncStatus: o.SyncStatus, Staking: o.StakingContract, NodeStatus: o.NodeStatus, + PinIntegrity: o.PinIntegrity, } // By default bee mode is set to full mode. @@ -208,7 +211,7 @@ func newTestServer(t *testing.T, o testServerOptions) (*http.Client, *websocket. o.BeeMode = api.FullMode } - s := api.New(o.PublicKey, o.PSSPublicKey, o.EthereumAddress, o.Logger, transaction, o.BatchStore, o.BeeMode, true, true, backend, o.CORSAllowedOrigins, inmemstore.New()) + s := api.New(o.PublicKey, o.PSSPublicKey, o.EthereumAddress, []string{o.WhitelistedAddr}, o.Logger, transaction, o.BatchStore, o.BeeMode, true, true, backend, o.CORSAllowedOrigins, inmemstore.New()) testutil.CleanupCloser(t, s) s.SetP2P(o.P2P) @@ -393,7 +396,7 @@ func TestParseName(t *testing.T) { pk, _ := crypto.GenerateSecp256k1Key() signer := crypto.NewDefaultSigner(pk) - s := api.New(pk.PublicKey, pk.PublicKey, common.Address{}, log, nil, nil, 1, false, false, nil, []string{"*"}, inmemstore.New()) + s := api.New(pk.PublicKey, pk.PublicKey, common.Address{}, nil, log, nil, nil, 1, false, false, nil, []string{"*"}, inmemstore.New()) s.Configure(signer, nil, nil, api.Options{}, api.ExtraOptions{Resolver: tC.res}, 1, nil) s.MountAPI() diff --git a/pkg/api/auth_test.go b/pkg/api/auth_test.go index 496d1a8f2dd..f2cb0a99d59 100644 --- a/pkg/api/auth_test.go +++ b/pkg/api/auth_test.go @@ -9,11 +9,11 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/auth/mock" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/auth/mock" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" ) // nolint:paralleltest diff --git a/pkg/api/balances.go b/pkg/api/balances.go index 94400669597..f55b8aeec32 100644 --- a/pkg/api/balances.go +++ b/pkg/api/balances.go @@ -8,10 +8,10 @@ import ( "errors" "net/http" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/api/balances_test.go b/pkg/api/balances_test.go index 4cb985fefc0..174196d253a 100644 --- a/pkg/api/balances_test.go +++ b/pkg/api/balances_test.go @@ -11,13 +11,13 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/accounting/mock" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/accounting/mock" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestBalances(t *testing.T) { diff --git a/pkg/api/bytes.go b/pkg/api/bytes.go index 4cb90c1b763..9b5d9b902d6 100644 --- a/pkg/api/bytes.go +++ b/pkg/api/bytes.go @@ -11,16 +11,15 @@ import ( "net/http" "strconv" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/postage" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/postage" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/tracing" "github.com/gorilla/mux" "github.com/opentracing/opentracing-go/ext" - "github.com/opentracing/opentracing-go/log" olog "github.com/opentracing/opentracing-go/log" ) @@ -63,7 +62,7 @@ func (s *Service) bytesUploadHandler(w http.ResponseWriter, r *http.Request) { default: jsonhttp.InternalServerError(w, "cannot get or create tag") } - ext.LogError(span, err, log.String("action", "tag.create")) + ext.LogError(span, err, olog.String("action", "tag.create")) return } span.SetTag("tagID", tag) @@ -90,7 +89,7 @@ func (s *Service) bytesUploadHandler(w http.ResponseWriter, r *http.Request) { default: jsonhttp.BadRequest(w, nil) } - ext.LogError(span, err, log.String("action", "new.StamperPutter")) + ext.LogError(span, err, olog.String("action", "new.StamperPutter")) return } @@ -111,7 +110,7 @@ func (s *Service) bytesUploadHandler(w http.ResponseWriter, r *http.Request) { default: jsonhttp.InternalServerError(ow, "split write all failed") } - ext.LogError(span, err, log.String("action", "split.WriteAll")) + ext.LogError(span, err, olog.String("action", "split.WriteAll")) return } @@ -122,7 +121,7 @@ func (s *Service) bytesUploadHandler(w http.ResponseWriter, r *http.Request) { logger.Debug("done split failed", "error", err) logger.Error(nil, "done split failed") jsonhttp.InternalServerError(ow, "done split failed") - ext.LogError(span, err, log.String("action", "putter.Done")) + ext.LogError(span, err, olog.String("action", "putter.Done")) return } @@ -154,7 +153,7 @@ func (s *Service) bytesGetHandler(w http.ResponseWriter, r *http.Request) { ContentTypeHeader: {"application/octet-stream"}, } - s.downloadHandler(logger, w, r, paths.Address, additionalHeaders, true) + s.downloadHandler(logger, w, r, paths.Address, additionalHeaders, true, false) } func (s *Service) bytesHeadHandler(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/bytes_test.go b/pkg/api/bytes_test.go index abae06bc2c6..e2acc99a9d6 100644 --- a/pkg/api/bytes_test.go +++ b/pkg/api/bytes_test.go @@ -12,14 +12,14 @@ import ( "strconv" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" - mockbatchstore "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" + mockbatchstore "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" "gitlab.com/nolash/go-mockbytes" ) diff --git a/pkg/api/bzz.go b/pkg/api/bzz.go index 2cf1d66d53d..65ded851f12 100644 --- a/pkg/api/bzz.go +++ b/pkg/api/bzz.go @@ -21,20 +21,20 @@ import ( olog "github.com/opentracing/opentracing-go/log" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/file/joiner" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/file/redundancy/getter" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/manifest" - "github.com/ethersphere/bee/pkg/postage" - storage "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/file/joiner" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/file/redundancy/getter" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/manifest" + "github.com/ethersphere/bee/v2/pkg/postage" + storage "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/tracing" "github.com/ethersphere/langos" "github.com/gorilla/mux" ) @@ -299,18 +299,36 @@ func (s *Service) bzzDownloadHandler(w http.ResponseWriter, r *http.Request) { paths.Path = strings.TrimRight(paths.Path, "/") + "/" // NOTE: leave one slash if there was some. } - s.serveReference(logger, paths.Address, paths.Path, w, r) + s.serveReference(logger, paths.Address, paths.Path, w, r, false) } -func (s *Service) serveReference(logger log.Logger, address swarm.Address, pathVar string, w http.ResponseWriter, r *http.Request) { +func (s *Service) bzzHeadHandler(w http.ResponseWriter, r *http.Request) { + logger := tracing.NewLoggerWithTraceID(r.Context(), s.logger.WithName("head_bzz_by_path").Build()) + + paths := struct { + Address swarm.Address `map:"address,resolve" validate:"required"` + Path string `map:"path"` + }{} + if response := s.mapStructure(mux.Vars(r), &paths); response != nil { + response("invalid path params", logger, w) + return + } + + if strings.HasSuffix(paths.Path, "/") { + paths.Path = strings.TrimRight(paths.Path, "/") + "/" // NOTE: leave one slash if there was some. + } + + s.serveReference(logger, paths.Address, paths.Path, w, r, true) +} + +func (s *Service) serveReference(logger log.Logger, address swarm.Address, pathVar string, w http.ResponseWriter, r *http.Request, headerOnly bool) { loggerV1 := logger.V(1).Build() headers := struct { - Cache *bool `map:"Swarm-Cache"` - Strategy getter.Strategy `map:"Swarm-Redundancy-Strategy"` - FallbackMode bool `map:"Swarm-Redundancy-Fallback-Mode"` - ChunkRetrievalTimeout string `map:"Swarm-Chunk-Retrieval-Timeout"` - LookaheadBufferSize *string `map:"Swarm-Lookahead-Buffer-Size"` + Cache *bool `map:"Swarm-Cache"` + Strategy *getter.Strategy `map:"Swarm-Redundancy-Strategy"` + FallbackMode *bool `map:"Swarm-Redundancy-Fallback-Mode"` + ChunkRetrievalTimeout *string `map:"Swarm-Chunk-Retrieval-Timeout"` }{} if response := s.mapStructure(r.Header, &headers); response != nil { @@ -326,7 +344,12 @@ func (s *Service) serveReference(logger log.Logger, address swarm.Address, pathV feedDereferenced := false ctx := r.Context() - ctx = getter.SetConfigInContext(ctx, headers.Strategy, headers.FallbackMode, headers.ChunkRetrievalTimeout, getter.DefaultStrategyTimeout.String()) + ctx, err := getter.SetConfigInContext(ctx, headers.Strategy, headers.FallbackMode, headers.ChunkRetrievalTimeout, logger) + if err != nil { + logger.Error(err, err.Error()) + jsonhttp.BadRequest(w, "could not parse headers") + return + } FETCH: // read manifest entry @@ -398,7 +421,7 @@ FETCH: // index document exists logger.Debug("bzz download: serving path", "path", pathWithIndex) - s.serveManifestEntry(logger, w, r, indexDocumentManifestEntry, !feedDereferenced) + s.serveManifestEntry(logger, w, r, indexDocumentManifestEntry, !feedDereferenced, headerOnly) return } } @@ -441,7 +464,7 @@ FETCH: // index document exists logger.Debug("bzz download: serving path", "path", pathWithIndex) - s.serveManifestEntry(logger, w, r, indexDocumentManifestEntry, !feedDereferenced) + s.serveManifestEntry(logger, w, r, indexDocumentManifestEntry, !feedDereferenced, headerOnly) return } } @@ -455,7 +478,7 @@ FETCH: // error document exists logger.Debug("bzz download: serving path", "path", errorDocumentPath) - s.serveManifestEntry(logger, w, r, errorDocumentManifestEntry, !feedDereferenced) + s.serveManifestEntry(logger, w, r, errorDocumentManifestEntry, !feedDereferenced, headerOnly) return } } @@ -469,7 +492,7 @@ FETCH: } // serve requested path - s.serveManifestEntry(logger, w, r, me, !feedDereferenced) + s.serveManifestEntry(logger, w, r, me, !feedDereferenced, headerOnly) } func (s *Service) serveManifestEntry( @@ -477,7 +500,7 @@ func (s *Service) serveManifestEntry( w http.ResponseWriter, r *http.Request, manifestEntry manifest.Entry, - etag bool, + etag, headersOnly bool, ) { additionalHeaders := http.Header{} mtdt := manifestEntry.Metadata() @@ -490,17 +513,17 @@ func (s *Service) serveManifestEntry( additionalHeaders[ContentTypeHeader] = []string{mimeType} } - s.downloadHandler(logger, w, r, manifestEntry.Reference(), additionalHeaders, etag) + s.downloadHandler(logger, w, r, manifestEntry.Reference(), additionalHeaders, etag, headersOnly) } // downloadHandler contains common logic for dowloading Swarm file from API -func (s *Service) downloadHandler(logger log.Logger, w http.ResponseWriter, r *http.Request, reference swarm.Address, additionalHeaders http.Header, etag bool) { +func (s *Service) downloadHandler(logger log.Logger, w http.ResponseWriter, r *http.Request, reference swarm.Address, additionalHeaders http.Header, etag, headersOnly bool) { headers := struct { - Cache *bool `map:"Swarm-Cache"` - Strategy getter.Strategy `map:"Swarm-Redundancy-Strategy"` - FallbackMode bool `map:"Swarm-Redundancy-Fallback-Mode"` - ChunkRetrievalTimeout string `map:"Swarm-Chunk-Retrieval-Timeout"` - LookaheadBufferSize *int `map:"Swarm-Lookahead-Buffer-Size"` + Strategy *getter.Strategy `map:"Swarm-Redundancy-Strategy"` + FallbackMode *bool `map:"Swarm-Redundancy-Fallback-Mode"` + ChunkRetrievalTimeout *string `map:"Swarm-Chunk-Retrieval-Timeout"` + LookaheadBufferSize *int `map:"Swarm-Lookahead-Buffer-Size"` + Cache *bool `map:"Swarm-Cache"` }{} if response := s.mapStructure(r.Header, &headers); response != nil { @@ -513,7 +536,13 @@ func (s *Service) downloadHandler(logger log.Logger, w http.ResponseWriter, r *h } ctx := r.Context() - ctx = getter.SetConfigInContext(ctx, headers.Strategy, headers.FallbackMode, headers.ChunkRetrievalTimeout, getter.DefaultStrategyTimeout.String()) + ctx, err := getter.SetConfigInContext(ctx, headers.Strategy, headers.FallbackMode, headers.ChunkRetrievalTimeout, logger) + if err != nil { + logger.Error(err, err.Error()) + jsonhttp.BadRequest(w, "could not parse headers") + return + } + reader, l, err := joiner.New(ctx, s.storer.Download(cache), s.storer.Cache(), reference) if err != nil { if errors.Is(err, storage.ErrNotFound) || errors.Is(err, topology.ErrNotFound) { @@ -537,6 +566,12 @@ func (s *Service) downloadHandler(logger log.Logger, w http.ResponseWriter, r *h } w.Header().Set(ContentLengthHeader, strconv.FormatInt(l, 10)) w.Header().Set("Access-Control-Expose-Headers", ContentDispositionHeader) + + if headersOnly { + w.WriteHeader(http.StatusOK) + return + } + bufSize := lookaheadBufferSize(l) if headers.LookaheadBufferSize != nil { bufSize = *(headers.LookaheadBufferSize) diff --git a/pkg/api/bzz_test.go b/pkg/api/bzz_test.go index 634d4eb0166..7d1e1b27bfe 100644 --- a/pkg/api/bzz_test.go +++ b/pkg/api/bzz_test.go @@ -16,21 +16,20 @@ import ( "strconv" "strings" "testing" - "time" - - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/manifest" - mockbatchstore "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil/pseudorand" + + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/manifest" + mockbatchstore "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil/pseudorand" ) // nolint:paralleltest,tparallel,thelper @@ -63,7 +62,9 @@ import ( // using redundancy to reconstruct the file and find the file recoverable. // // nolint:thelper -func TestBzzUploadDownloadWithRedundancy(t *testing.T) { +func TestBzzUploadDownloadWithRedundancy_FLAKY(t *testing.T) { + t.Skip("flaky") + t.Parallel() fileUploadResource := "/bzz" fileDownloadResource := func(addr string) string { return "/bzz/" + addr + "/" } @@ -73,7 +74,6 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) { if err != nil { t.Fatal(err) } - fetchTimeout := 100 * time.Millisecond store := mockstorer.NewForgettingStore(inmemchunkstore.New()) storerMock := mockstorer.NewWithChunkStore(store) client, _, _, _ := newTestServer(t, testServerOptions{ @@ -131,7 +131,6 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) { jsonhttptest.WithRequestHeader(api.SwarmRedundancyLevelHeader, "0"), jsonhttptest.WithRequestHeader(api.SwarmRedundancyStrategyHeader, "0"), jsonhttptest.WithRequestHeader(api.SwarmRedundancyFallbackModeHeader, "false"), - jsonhttptest.WithRequestHeader(api.SwarmChunkRetrievalTimeoutHeader, fetchTimeout.String()), jsonhttptest.WithPutResponseBody(&body), ) @@ -151,30 +150,42 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) { if rLevel == 0 { t.Skip("NA") } - ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) - defer cancel() - req, err := http.NewRequestWithContext(ctx, "GET", fileDownloadResource(refResponse.Reference.String()), nil) + req, err := http.NewRequestWithContext(context.Background(), "GET", fileDownloadResource(refResponse.Reference.String()), nil) if err != nil { t.Fatal(err) } req.Header.Set(api.SwarmRedundancyStrategyHeader, "0") req.Header.Set(api.SwarmRedundancyFallbackModeHeader, "false") - req.Header.Set(api.SwarmChunkRetrievalTimeoutHeader, fetchTimeout.String()) - _, err = client.Do(req) - if !errors.Is(err, context.DeadlineExceeded) { - t.Fatalf("expected error %v; got %v", io.ErrUnexpectedEOF, err) + resp, err := client.Do(req) + if err != nil { + t.Fatal(err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + t.Fatalf("expected status %d; got %d", http.StatusOK, resp.StatusCode) + } + _, err = dataReader.Seek(0, io.SeekStart) + if err != nil { + t.Fatal(err) + } + ok, err := dataReader.Equal(resp.Body) + if err != nil { + t.Fatal(err) + } + if ok { + t.Fatal("there should be missing data") } }) t.Run("download with redundancy should succeed", func(t *testing.T) { - req, err := http.NewRequestWithContext(context.TODO(), "GET", fileDownloadResource(refResponse.Reference.String()), nil) + req, err := http.NewRequestWithContext(context.Background(), "GET", fileDownloadResource(refResponse.Reference.String()), nil) if err != nil { t.Fatal(err) } req.Header.Set(api.SwarmRedundancyStrategyHeader, "3") req.Header.Set(api.SwarmRedundancyFallbackModeHeader, "true") - req.Header.Set(api.SwarmChunkRetrievalTimeoutHeader, fetchTimeout.String()) resp, err := client.Do(req) if err != nil { @@ -507,8 +518,18 @@ func TestBzzFiles(t *testing.T) { jsonhttptest.WithRequestHeader(api.ContentTypeHeader, "text/html; charset=utf-8"), jsonhttptest.WithNonEmptyResponseHeader(api.SwarmTagHeader), ) - }) + t.Run("head", func(t *testing.T) { + rootHash := "65148cd89b58e91616773f5acea433f7b5a6274f2259e25f4893a332b74a7e28" + + jsonhttptest.Request(t, client, http.MethodHead, fileDownloadResource(rootHash), http.StatusOK, + jsonhttptest.WithRequestHeader(api.SwarmPostageBatchIdHeader, batchOkStr), + jsonhttptest.WithRequestBody(bytes.NewReader(simpleData)), + jsonhttptest.WithRequestHeader(api.ContentTypeHeader, "text/html; charset=utf-8"), + jsonhttptest.WithExpectedContentLength(21), + ) + }) + }) } // TestRangeRequests validates that all endpoints are serving content with diff --git a/pkg/api/chequebook.go b/pkg/api/chequebook.go index b1ee31361ff..33cd75d9767 100644 --- a/pkg/api/chequebook.go +++ b/pkg/api/chequebook.go @@ -10,13 +10,13 @@ import ( "net/http" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - "github.com/ethersphere/bee/pkg/settlement/swap" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + "github.com/ethersphere/bee/v2/pkg/settlement/swap" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/api/chequebook_test.go b/pkg/api/chequebook_test.go index f12d41be999..b9b9cbdef32 100644 --- a/pkg/api/chequebook_test.go +++ b/pkg/api/chequebook_test.go @@ -13,16 +13,16 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook/mock" - swapmock "github.com/ethersphere/bee/pkg/settlement/swap/mock" - - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook/mock" + swapmock "github.com/ethersphere/bee/v2/pkg/settlement/swap/mock" + + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestChequebookBalance(t *testing.T) { diff --git a/pkg/api/chunk.go b/pkg/api/chunk.go index 25e1d6c65ed..a572cacdcdf 100644 --- a/pkg/api/chunk.go +++ b/pkg/api/chunk.go @@ -12,12 +12,13 @@ import ( "net/http" "strconv" - "github.com/ethersphere/bee/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/soc" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) @@ -111,10 +112,31 @@ func (s *Service) chunkUploadHandler(w http.ResponseWriter, r *http.Request) { chunk, err := cac.NewWithDataSpan(data) if err != nil { + // not a valid cac chunk. Check if it's a replica soc chunk. logger.Debug("chunk upload: create chunk failed", "error", err) - logger.Error(nil, "chunk upload: create chunk error") - jsonhttp.InternalServerError(ow, "create chunk error") - return + + // FromChunk only uses the chunk data to recreate the soc chunk. So the address is irrelevant. + sch, err := soc.FromChunk(swarm.NewChunk(swarm.EmptyAddress, data)) + if err != nil { + logger.Debug("chunk upload: create soc chunk from data failed", "error", err) + logger.Error(nil, "chunk upload: create chunk error") + jsonhttp.InternalServerError(ow, "create chunk error") + return + } + chunk, err = sch.Chunk() + if err != nil { + logger.Debug("chunk upload: create chunk from soc failed", "error", err) + logger.Error(nil, "chunk upload: create chunk error") + jsonhttp.InternalServerError(ow, "create chunk error") + return + } + + if !soc.Valid(chunk) { + logger.Debug("chunk upload: invalid soc chunk") + logger.Error(nil, "chunk upload: create chunk error") + jsonhttp.InternalServerError(ow, "create chunk error") + return + } } err = putter.Put(r.Context(), chunk) diff --git a/pkg/api/chunk_address.go b/pkg/api/chunk_address.go index 7c99225c078..6f214a0ea03 100644 --- a/pkg/api/chunk_address.go +++ b/pkg/api/chunk_address.go @@ -7,8 +7,8 @@ package api import ( "net/http" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/api/chunk_stream.go b/pkg/api/chunk_stream.go index 005ba5020d1..4ae045a9d4f 100644 --- a/pkg/api/chunk_stream.go +++ b/pkg/api/chunk_stream.go @@ -10,13 +10,13 @@ import ( "net/http" "time" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - storage "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + storage "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/websocket" ) diff --git a/pkg/api/chunk_stream_test.go b/pkg/api/chunk_stream_test.go index 24a3bdab841..47c8e860b51 100644 --- a/pkg/api/chunk_stream_test.go +++ b/pkg/api/chunk_stream_test.go @@ -10,12 +10,12 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/api" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/spinlock" - testingc "github.com/ethersphere/bee/pkg/storage/testing" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/spinlock" + testingc "github.com/ethersphere/bee/v2/pkg/storage/testing" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/websocket" ) diff --git a/pkg/api/chunk_test.go b/pkg/api/chunk_test.go index 21c98a8c011..c0e1fe9de9c 100644 --- a/pkg/api/chunk_test.go +++ b/pkg/api/chunk_test.go @@ -13,17 +13,17 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/log" - mockbatchstore "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/spinlock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - testingc "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + mockbatchstore "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/spinlock" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + testingc "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // nolint:paralleltest,tparallel diff --git a/pkg/api/cors_test.go b/pkg/api/cors_test.go index c8b9fae3512..73c3b343414 100644 --- a/pkg/api/cors_test.go +++ b/pkg/api/cors_test.go @@ -9,8 +9,8 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" ) func TestCORSHeaders(t *testing.T) { @@ -137,7 +137,7 @@ func TestCors(t *testing.T) { expectedMethods: "POST", }, { endpoint: "bzz/0101011", - expectedMethods: "GET", + expectedMethods: "GET, HEAD", }, { endpoint: "chunks", diff --git a/pkg/api/debugstorage.go b/pkg/api/debugstorage.go index 13325997b19..d3e209b0dc2 100644 --- a/pkg/api/debugstorage.go +++ b/pkg/api/debugstorage.go @@ -7,8 +7,8 @@ package api import ( "net/http" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/tracing" ) func (s *Service) debugStorage(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/debugstorage_test.go b/pkg/api/debugstorage_test.go index 72d8800b882..bb12a5585fd 100644 --- a/pkg/api/debugstorage_test.go +++ b/pkg/api/debugstorage_test.go @@ -8,9 +8,9 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/storer" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/storer" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" ) func TestDebugStorage(t *testing.T) { diff --git a/pkg/api/dirs.go b/pkg/api/dirs.go index 06aff9c59d6..f54a02807c9 100644 --- a/pkg/api/dirs.go +++ b/pkg/api/dirs.go @@ -18,16 +18,16 @@ import ( "strconv" "strings" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/manifest" - "github.com/ethersphere/bee/pkg/postage" - storage "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/manifest" + "github.com/ethersphere/bee/v2/pkg/postage" + storage "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/tracing" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" olog "github.com/opentracing/opentracing-go/log" @@ -276,25 +276,14 @@ func (m *multipartReader) Next() (*FileInfo, error) { if filePath == "" { filePath = part.FormName() } - if filePath == "" { - return nil, errors.New("filepath missing") - } fileName := filepath.Base(filePath) contentType := part.Header.Get(ContentTypeHeader) - if contentType == "" { - return nil, errors.New("content-type missing") - } contentLength := part.Header.Get(ContentLengthHeader) - if contentLength == "" { - return nil, errors.New("content-length missing") - } - fileSize, err := strconv.ParseInt(contentLength, 10, 64) - if err != nil { - return nil, errors.New("invalid file size") - } + + fileSize, _ := strconv.ParseInt(contentLength, 10, 64) return &FileInfo{ Path: filePath, diff --git a/pkg/api/dirs_test.go b/pkg/api/dirs_test.go index b43e9b3bca4..d49f0d281d6 100644 --- a/pkg/api/dirs_test.go +++ b/pkg/api/dirs_test.go @@ -17,14 +17,14 @@ import ( "strconv" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/manifest" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/manifest" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // nolint:paralleltest diff --git a/pkg/api/export_test.go b/pkg/api/export_test.go index 030a27d9001..812ce522ba0 100644 --- a/pkg/api/export_test.go +++ b/pkg/api/export_test.go @@ -5,8 +5,8 @@ package api import ( - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type ( @@ -95,6 +95,7 @@ type ( PostageStampBucketsResponse = postageStampBucketsResponse BucketData = bucketData WalletResponse = walletResponse + WalletTxResponse = walletTxResponse GetStakeResponse = getStakeResponse WithdrawAllStakeResponse = withdrawAllStakeResponse StatusSnapshotResponse = statusSnapshotResponse diff --git a/pkg/api/feed.go b/pkg/api/feed.go index 23961e6d5fc..09fdf6515ec 100644 --- a/pkg/api/feed.go +++ b/pkg/api/feed.go @@ -13,17 +13,17 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/manifest" - "github.com/ethersphere/bee/pkg/manifest/mantaray" - "github.com/ethersphere/bee/pkg/manifest/simple" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/soc" - storage "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/manifest" + "github.com/ethersphere/bee/v2/pkg/manifest/mantaray" + "github.com/ethersphere/bee/v2/pkg/manifest/simple" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/soc" + storage "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/api/feed_test.go b/pkg/api/feed_test.go index e71e8d77b04..a35b9ce3423 100644 --- a/pkg/api/feed_test.go +++ b/pkg/api/feed_test.go @@ -14,18 +14,18 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/manifest" - "github.com/ethersphere/bee/pkg/postage" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - testingsoc "github.com/ethersphere/bee/pkg/soc/testing" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/manifest" + "github.com/ethersphere/bee/v2/pkg/postage" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + testingsoc "github.com/ethersphere/bee/v2/pkg/soc/testing" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ownerString = "8d3766440f0d7b949a5e32995d09619a7f86e632" diff --git a/pkg/api/health.go b/pkg/api/health.go index 3d6e132a015..33b6481b6ee 100644 --- a/pkg/api/health.go +++ b/pkg/api/health.go @@ -7,8 +7,8 @@ package api import ( "net/http" - "github.com/ethersphere/bee" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" ) type healthStatusResponse struct { diff --git a/pkg/api/health_test.go b/pkg/api/health_test.go index fb5f49e2b57..3446e167895 100644 --- a/pkg/api/health_test.go +++ b/pkg/api/health_test.go @@ -8,9 +8,9 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" ) func TestHealth(t *testing.T) { diff --git a/pkg/api/logger.go b/pkg/api/logger.go index cb371d6a851..95efc08e428 100644 --- a/pkg/api/logger.go +++ b/pkg/api/logger.go @@ -11,8 +11,8 @@ import ( "regexp" "strings" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/log" "github.com/gorilla/mux" ) diff --git a/pkg/api/logger_test.go b/pkg/api/logger_test.go index e29341355a1..b8420b79067 100644 --- a/pkg/api/logger_test.go +++ b/pkg/api/logger_test.go @@ -11,10 +11,10 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/api/metrics.go b/pkg/api/metrics.go index 9146d1079a4..7635468f4e3 100644 --- a/pkg/api/metrics.go +++ b/pkg/api/metrics.go @@ -9,8 +9,8 @@ import ( "strconv" "time" - "github.com/ethersphere/bee" - m "github.com/ethersphere/bee/pkg/metrics" + "github.com/ethersphere/bee/v2" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/collectors" ) @@ -108,9 +108,6 @@ type UpgradedResponseWriter interface { http.Pusher http.Hijacker http.Flusher - // staticcheck SA1019 CloseNotifier interface is required by gorilla compress handler - // nolint:staticcheck - http.CloseNotifier } type responseWriter struct { diff --git a/pkg/api/metrics_test.go b/pkg/api/metrics_test.go index eb2f8db0481..299f0321eef 100644 --- a/pkg/api/metrics_test.go +++ b/pkg/api/metrics_test.go @@ -7,7 +7,7 @@ package api_test import ( "testing" - "github.com/ethersphere/bee/pkg/api" + "github.com/ethersphere/bee/v2/pkg/api" ) func TestToFileSizeBucket(t *testing.T) { diff --git a/pkg/api/node.go b/pkg/api/node.go index 9a14da4685b..9a3f6228538 100644 --- a/pkg/api/node.go +++ b/pkg/api/node.go @@ -7,7 +7,7 @@ package api import ( "net/http" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" ) type BeeNodeMode uint diff --git a/pkg/api/node_test.go b/pkg/api/node_test.go index 9cb3c6d8b90..5a076c4685d 100644 --- a/pkg/api/node_test.go +++ b/pkg/api/node_test.go @@ -7,7 +7,7 @@ package api_test import ( "testing" - "github.com/ethersphere/bee/pkg/api" + "github.com/ethersphere/bee/v2/pkg/api" ) func TestBeeNodeMode_String(t *testing.T) { diff --git a/pkg/api/p2p.go b/pkg/api/p2p.go index 3ae0ee4a259..9494b9ccbd0 100644 --- a/pkg/api/p2p.go +++ b/pkg/api/p2p.go @@ -9,9 +9,9 @@ import ( "net/http" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/api/p2p_test.go b/pkg/api/p2p_test.go index e184906734a..5cf9de6124c 100644 --- a/pkg/api/p2p_test.go +++ b/pkg/api/p2p_test.go @@ -11,12 +11,12 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/p2p/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/p2p/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/api/peer.go b/pkg/api/peer.go index a6dfc8f7aeb..3213b55a8ef 100644 --- a/pkg/api/peer.go +++ b/pkg/api/peer.go @@ -8,9 +8,9 @@ import ( "errors" "net/http" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/api/peer_test.go b/pkg/api/peer_test.go index eb1ec3ffb6a..0697a6277d2 100644 --- a/pkg/api/peer_test.go +++ b/pkg/api/peer_test.go @@ -11,14 +11,14 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/api/pin.go b/pkg/api/pin.go index 7c80e5f196b..6fc115fd1b1 100644 --- a/pkg/api/pin.go +++ b/pkg/api/pin.go @@ -5,14 +5,16 @@ package api import ( + "encoding/json" "errors" "net/http" "sync" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/traversal" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/traversal" "github.com/gorilla/mux" "golang.org/x/sync/semaphore" ) @@ -199,3 +201,53 @@ func (s *Service) listPinnedRootHashes(w http.ResponseWriter, r *http.Request) { References: pinned, }) } + +type PinIntegrityResponse struct { + Reference swarm.Address `json:"reference"` + Total int `json:"total"` + Missing int `json:"missing"` + Invalid int `json:"invalid"` +} + +func (s *Service) pinIntegrityHandler(w http.ResponseWriter, r *http.Request) { + logger := s.logger.WithName("get_pin_integrity").Build() + + querie := struct { + Ref swarm.Address `map:"ref"` + }{} + + if response := s.mapStructure(r.URL.Query(), &querie); response != nil { + response("invalid query params", logger, w) + return + } + + out := make(chan storer.PinStat) + + go s.pinIntegrity.Check(r.Context(), logger, querie.Ref.String(), out) + + flusher, ok := w.(http.Flusher) + if !ok { + http.NotFound(w, r) + return + } + + w.Header().Set("Transfer-Encoding", "chunked") + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(http.StatusOK) + flusher.Flush() + + enc := json.NewEncoder(w) + + for v := range out { + resp := PinIntegrityResponse{ + Reference: v.Ref, + Total: v.Total, + Missing: v.Missing, + Invalid: v.Invalid, + } + if err := enc.Encode(resp); err != nil { + break + } + flusher.Flush() + } +} diff --git a/pkg/api/pin_test.go b/pkg/api/pin_test.go index 751b93b1d65..a85c34a9594 100644 --- a/pkg/api/pin_test.go +++ b/pkg/api/pin_test.go @@ -5,16 +5,21 @@ package api_test import ( + "context" "net/http" "strings" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + storer "github.com/ethersphere/bee/v2/pkg/storer" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func checkPinHandlers(t *testing.T, client *http.Client, rootHash string, createPin bool) { @@ -185,3 +190,52 @@ func TestPinHandlersInvalidInputs(t *testing.T) { } } } + +const pinRef = "620fcd78c7ce54da2d1b7cc2274a02e190cbe8fecbc3bd244690ab6517ce8f39" + +func TestIntegrityHandler(t *testing.T) { + + t.Parallel() + + t.Run("ok", func(t *testing.T) { + t.Parallel() + testServer, _, _, _ := newTestServer(t, testServerOptions{ + PinIntegrity: &mockPinIntegrity{ + Store: inmemstore.New(), + tester: t, + }, + }) + + endp := "/pins/check?ref=" + pinRef + + // When probe is not set health endpoint should indicate that node is not healthy + jsonhttptest.Request(t, testServer, http.MethodGet, endp, http.StatusOK, jsonhttptest.WithExpectedResponse(nil)) + }) + + t.Run("wrong hash format", func(t *testing.T) { + t.Parallel() + testServer, _, _, _ := newTestServer(t, testServerOptions{ + PinIntegrity: &mockPinIntegrity{ + Store: inmemstore.New(), + tester: t, + }, + }) + + endp := "/pins/check?ref=0xbadhash" + + // When probe is not set health endpoint should indicate that node is not healthy + jsonhttptest.Request(t, testServer, http.MethodGet, endp, http.StatusBadRequest, jsonhttptest.WithExpectedResponse(nil)) + }) +} + +type mockPinIntegrity struct { + tester *testing.T + Store storage.Store +} + +func (p *mockPinIntegrity) Check(ctx context.Context, logger log.Logger, pin string, out chan storer.PinStat) { + if pin != pinRef { + p.tester.Fatal("bad pin", pin) + } + close(out) +} diff --git a/pkg/api/pingpong.go b/pkg/api/pingpong.go index 0c3bbc45323..6cb1c4ae23e 100644 --- a/pkg/api/pingpong.go +++ b/pkg/api/pingpong.go @@ -8,9 +8,9 @@ import ( "errors" "net/http" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/api/pingpong_test.go b/pkg/api/pingpong_test.go index b97bdd77413..4dffae5b0e6 100644 --- a/pkg/api/pingpong_test.go +++ b/pkg/api/pingpong_test.go @@ -11,12 +11,12 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/p2p" - pingpongmock "github.com/ethersphere/bee/pkg/pingpong/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/p2p" + pingpongmock "github.com/ethersphere/bee/v2/pkg/pingpong/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestPingpong(t *testing.T) { diff --git a/pkg/api/postage.go b/pkg/api/postage.go index 457b0dc0f63..ba1f1499d9f 100644 --- a/pkg/api/postage.go +++ b/pkg/api/postage.go @@ -13,12 +13,12 @@ import ( "net/http" "time" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/tracing" "github.com/gorilla/mux" ) diff --git a/pkg/api/postage_test.go b/pkg/api/postage_test.go index a7055ed098a..ebf808c1c7a 100644 --- a/pkg/api/postage_test.go +++ b/pkg/api/postage_test.go @@ -18,19 +18,19 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - contractMock "github.com/ethersphere/bee/pkg/postage/postagecontract/mock" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/sctx" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/transaction/backendmock" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + contractMock "github.com/ethersphere/bee/v2/pkg/postage/postagecontract/mock" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/sctx" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/transaction/backendmock" ) func TestPostageCreateStamp(t *testing.T) { diff --git a/pkg/api/pss.go b/pkg/api/pss.go index aa87a6165c8..ef1c3a84d47 100644 --- a/pkg/api/pss.go +++ b/pkg/api/pss.go @@ -14,11 +14,11 @@ import ( "strings" "time" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/pss" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" "github.com/gorilla/websocket" ) diff --git a/pkg/api/pss_test.go b/pkg/api/pss_test.go index d40a4889d4e..6624e6d8d21 100644 --- a/pkg/api/pss_test.go +++ b/pkg/api/pss_test.go @@ -19,19 +19,19 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/pss" - "github.com/ethersphere/bee/pkg/pushsync" - "github.com/ethersphere/bee/pkg/spinlock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/pushsync" + "github.com/ethersphere/bee/v2/pkg/spinlock" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "github.com/gorilla/websocket" ) diff --git a/pkg/api/rchash.go b/pkg/api/rchash.go index ad7a25f9992..3aec3e3836a 100644 --- a/pkg/api/rchash.go +++ b/pkg/api/rchash.go @@ -10,9 +10,9 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/storageincentives/redistribution" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/storageincentives/redistribution" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/api/readiness_test.go b/pkg/api/readiness_test.go index f91419af8cb..52677214919 100644 --- a/pkg/api/readiness_test.go +++ b/pkg/api/readiness_test.go @@ -8,8 +8,8 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" ) func TestReadiness(t *testing.T) { diff --git a/pkg/api/redistribution.go b/pkg/api/redistribution.go index ba335342a9c..5df3fbf0682 100644 --- a/pkg/api/redistribution.go +++ b/pkg/api/redistribution.go @@ -8,9 +8,9 @@ import ( "net/http" "time" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/tracing" ) type redistributionStatusResponse struct { diff --git a/pkg/api/redistribution_test.go b/pkg/api/redistribution_test.go index b13f4d9af93..88bf00abe51 100644 --- a/pkg/api/redistribution_test.go +++ b/pkg/api/redistribution_test.go @@ -11,13 +11,13 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - statestore "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/storageincentives" - "github.com/ethersphere/bee/pkg/transaction/backendmock" - "github.com/ethersphere/bee/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + statestore "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/storageincentives" + "github.com/ethersphere/bee/v2/pkg/transaction/backendmock" + "github.com/ethersphere/bee/v2/pkg/transaction/mock" ) func TestRedistributionStatus(t *testing.T) { diff --git a/pkg/api/router.go b/pkg/api/router.go index 7c854543b88..18c2bfb9a46 100644 --- a/pkg/api/router.go +++ b/pkg/api/router.go @@ -11,10 +11,10 @@ import ( "net/http/pprof" "strings" - "github.com/ethersphere/bee/pkg/auth" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/log/httpaccess" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/auth" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/log/httpaccess" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/handlers" "github.com/gorilla/mux" "github.com/prometheus/client_golang/prometheus/promhttp" @@ -220,7 +220,7 @@ func (s *Service) mountAPI() { handle("/chunks", jsonhttp.MethodHandler{ "POST": web.ChainHandlers( - jsonhttp.NewMaxBodyBytesHandler(swarm.ChunkWithSpanSize), + jsonhttp.NewMaxBodyBytesHandler(swarm.SocMaxChunkSize), web.FinalHandlerFunc(s.chunkUploadHandler), ), }) @@ -270,6 +270,9 @@ func (s *Service) mountAPI() { s.newTracingHandler("bzz-download"), web.FinalHandlerFunc(s.bzzDownloadHandler), ), + "HEAD": web.ChainHandlers( + web.FinalHandlerFunc(s.bzzHeadHandler), + ), }) handle("/pss/send/{topic}/{targets}", web.ChainHandlers( @@ -312,6 +315,12 @@ func (s *Service) mountAPI() { })), ) + handle("/pins/check", web.ChainHandlers( + web.FinalHandler(jsonhttp.MethodHandler{ + "GET": http.HandlerFunc(s.pinIntegrityHandler), + }), + )) + handle("/pins/{reference}", web.ChainHandlers( web.FinalHandler(jsonhttp.MethodHandler{ "GET": http.HandlerFunc(s.getPinnedRootHash), @@ -488,6 +497,12 @@ func (s *Service) mountBusinessDebug(restricted bool) { handle("/wallet", jsonhttp.MethodHandler{ "GET": http.HandlerFunc(s.walletHandler), }) + handle("/wallet/withdraw/{coin}", jsonhttp.MethodHandler{ + "POST": web.ChainHandlers( + s.gasConfigMiddleware("wallet withdraw"), + web.FinalHandlerFunc(s.walletWithdrawHandler), + ), + }) } } diff --git a/pkg/api/settlements.go b/pkg/api/settlements.go index 83ff7480f51..b6564925d13 100644 --- a/pkg/api/settlements.go +++ b/pkg/api/settlements.go @@ -9,11 +9,11 @@ import ( "math/big" "net/http" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - "github.com/ethersphere/bee/pkg/settlement" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + "github.com/ethersphere/bee/v2/pkg/settlement" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/api/settlements_test.go b/pkg/api/settlements_test.go index bc06f540452..86f2e2e42e1 100644 --- a/pkg/api/settlements_test.go +++ b/pkg/api/settlements_test.go @@ -11,13 +11,13 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/settlement" - "github.com/ethersphere/bee/pkg/settlement/swap/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/settlement" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestSettlements(t *testing.T) { diff --git a/pkg/api/soc.go b/pkg/api/soc.go index 6dfafadda28..0abf338deb9 100644 --- a/pkg/api/soc.go +++ b/pkg/api/soc.go @@ -9,12 +9,12 @@ import ( "io" "net/http" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/soc" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/soc" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/api/soc_test.go b/pkg/api/soc_test.go index 5e9fe93d901..79e72ffb603 100644 --- a/pkg/api/soc_test.go +++ b/pkg/api/soc_test.go @@ -13,13 +13,13 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - testingsoc "github.com/ethersphere/bee/pkg/soc/testing" - "github.com/ethersphere/bee/pkg/spinlock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + testingsoc "github.com/ethersphere/bee/v2/pkg/soc/testing" + "github.com/ethersphere/bee/v2/pkg/spinlock" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // nolint:paralleltest diff --git a/pkg/api/staking.go b/pkg/api/staking.go index 77e8a7e836c..5ca5b06d409 100644 --- a/pkg/api/staking.go +++ b/pkg/api/staking.go @@ -9,10 +9,10 @@ import ( "math/big" "net/http" - "github.com/ethersphere/bee/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/storageincentives/staking" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking" "github.com/gorilla/mux" ) diff --git a/pkg/api/staking_test.go b/pkg/api/staking_test.go index 8f10d4f6e24..e6f4d0b2296 100644 --- a/pkg/api/staking_test.go +++ b/pkg/api/staking_test.go @@ -12,14 +12,14 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/bigint" - - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/storageincentives/staking" - stakingContractMock "github.com/ethersphere/bee/pkg/storageincentives/staking/mock" + "github.com/ethersphere/bee/v2/pkg/bigint" + + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking" + stakingContractMock "github.com/ethersphere/bee/v2/pkg/storageincentives/staking/mock" ) func TestDepositStake(t *testing.T) { diff --git a/pkg/api/status.go b/pkg/api/status.go index af0b5b99a27..b20cafb15a7 100644 --- a/pkg/api/status.go +++ b/pkg/api/status.go @@ -11,23 +11,24 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" ) type statusSnapshotResponse struct { - Peer string `json:"peer"` - Proximity uint8 `json:"proximity"` - BeeMode string `json:"beeMode"` - ReserveSize uint64 `json:"reserveSize"` - PullsyncRate float64 `json:"pullsyncRate"` - StorageRadius uint8 `json:"storageRadius"` - ConnectedPeers uint64 `json:"connectedPeers"` - NeighborhoodSize uint64 `json:"neighborhoodSize"` - RequestFailed bool `json:"requestFailed,omitempty"` - BatchCommitment uint64 `json:"batchCommitment"` - IsReachable bool `json:"isReachable"` + Peer string `json:"peer"` + Proximity uint8 `json:"proximity"` + BeeMode string `json:"beeMode"` + ReserveSize uint64 `json:"reserveSize"` + ReserveSizeWithinRadius uint64 `json:"reserveSizeWithinRadius"` + PullsyncRate float64 `json:"pullsyncRate"` + StorageRadius uint8 `json:"storageRadius"` + ConnectedPeers uint64 `json:"connectedPeers"` + NeighborhoodSize uint64 `json:"neighborhoodSize"` + RequestFailed bool `json:"requestFailed,omitempty"` + BatchCommitment uint64 `json:"batchCommitment"` + IsReachable bool `json:"isReachable"` } type statusResponse struct { @@ -70,15 +71,16 @@ func (s *Service) statusGetHandler(w http.ResponseWriter, _ *http.Request) { } jsonhttp.OK(w, statusSnapshotResponse{ - Peer: s.overlay.String(), - BeeMode: ss.BeeMode, - ReserveSize: ss.ReserveSize, - PullsyncRate: ss.PullsyncRate, - StorageRadius: uint8(ss.StorageRadius), - ConnectedPeers: ss.ConnectedPeers, - NeighborhoodSize: ss.NeighborhoodSize, - BatchCommitment: ss.BatchCommitment, - IsReachable: ss.IsReachable, + Peer: s.overlay.String(), + BeeMode: ss.BeeMode, + ReserveSize: ss.ReserveSize, + ReserveSizeWithinRadius: ss.ReserveSizeWithinRadius, + PullsyncRate: ss.PullsyncRate, + StorageRadius: uint8(ss.StorageRadius), + ConnectedPeers: ss.ConnectedPeers, + NeighborhoodSize: ss.NeighborhoodSize, + BatchCommitment: ss.BatchCommitment, + IsReachable: ss.IsReachable, }) } @@ -118,6 +120,7 @@ func (s *Service) statusGetPeersHandler(w http.ResponseWriter, r *http.Request) } else { snapshot.BeeMode = ss.BeeMode snapshot.ReserveSize = ss.ReserveSize + snapshot.ReserveSizeWithinRadius = ss.ReserveSizeWithinRadius snapshot.PullsyncRate = ss.PullsyncRate snapshot.StorageRadius = uint8(ss.StorageRadius) snapshot.ConnectedPeers = ss.ConnectedPeers diff --git a/pkg/api/status_test.go b/pkg/api/status_test.go index b7a9b92dc57..cc2c568abf4 100644 --- a/pkg/api/status_test.go +++ b/pkg/api/status_test.go @@ -8,12 +8,12 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/status" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/status" + "github.com/ethersphere/bee/v2/pkg/topology" ) func TestGetStatus(t *testing.T) { @@ -26,21 +26,23 @@ func TestGetStatus(t *testing.T) { mode := api.FullMode ssr := api.StatusSnapshotResponse{ - BeeMode: mode.String(), - ReserveSize: 128, - PullsyncRate: 64, - StorageRadius: 8, - ConnectedPeers: 0, - NeighborhoodSize: 0, - BatchCommitment: 1, - IsReachable: true, + BeeMode: mode.String(), + ReserveSize: 128, + ReserveSizeWithinRadius: 64, + PullsyncRate: 64, + StorageRadius: 8, + ConnectedPeers: 0, + NeighborhoodSize: 0, + BatchCommitment: 1, + IsReachable: true, } ssMock := &statusSnapshotMock{ - syncRate: ssr.PullsyncRate, - reserveSize: int(ssr.ReserveSize), - storageRadius: ssr.StorageRadius, - commitment: ssr.BatchCommitment, + syncRate: ssr.PullsyncRate, + reserveSize: int(ssr.ReserveSize), + reserveSizeWithinRadius: ssr.ReserveSizeWithinRadius, + storageRadius: ssr.StorageRadius, + commitment: ssr.BatchCommitment, } statusSvc := status.NewService( @@ -109,13 +111,17 @@ func (m *topologyPeersIterNoopMock) IsReachable() bool { // - status.SyncReporter // - postage.CommitmentGetter type statusSnapshotMock struct { - syncRate float64 - reserveSize int - storageRadius uint8 - commitment uint64 + syncRate float64 + reserveSize int + reserveSizeWithinRadius uint64 + storageRadius uint8 + commitment uint64 } func (m *statusSnapshotMock) SyncRate() float64 { return m.syncRate } func (m *statusSnapshotMock) ReserveSize() int { return m.reserveSize } func (m *statusSnapshotMock) StorageRadius() uint8 { return m.storageRadius } func (m *statusSnapshotMock) Commitment() (uint64, error) { return m.commitment, nil } +func (m *statusSnapshotMock) ReserveSizeWithinRadius() uint64 { + return m.reserveSizeWithinRadius +} diff --git a/pkg/api/stewardship.go b/pkg/api/stewardship.go index e617549d88f..99d330f78cc 100644 --- a/pkg/api/stewardship.go +++ b/pkg/api/stewardship.go @@ -8,11 +8,11 @@ import ( "errors" "net/http" - "github.com/ethersphere/bee/pkg/postage" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/postage" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" "github.com/gorilla/mux" ) diff --git a/pkg/api/stewardship_test.go b/pkg/api/stewardship_test.go index 005b0bd66ad..e0f93957de5 100644 --- a/pkg/api/stewardship_test.go +++ b/pkg/api/stewardship_test.go @@ -9,14 +9,14 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/steward/mock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/steward/mock" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // nolint:paralleltest diff --git a/pkg/api/subdomain.go b/pkg/api/subdomain.go index 2e90c4ac1ce..5d5cede467a 100644 --- a/pkg/api/subdomain.go +++ b/pkg/api/subdomain.go @@ -8,8 +8,8 @@ import ( "net/http" "strings" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/tracing" "github.com/gorilla/mux" ) @@ -28,5 +28,5 @@ func (s *Service) subdomainHandler(w http.ResponseWriter, r *http.Request) { paths.Path = strings.TrimRight(paths.Path, "/") + "/" // NOTE: leave one slash if there was some. } - s.serveReference(logger, paths.Subdomain, paths.Path, w, r) + s.serveReference(logger, paths.Subdomain, paths.Path, w, r, false) } diff --git a/pkg/api/subdomain_test.go b/pkg/api/subdomain_test.go index 9dfd0143bde..6f8efc0b0f2 100644 --- a/pkg/api/subdomain_test.go +++ b/pkg/api/subdomain_test.go @@ -10,13 +10,13 @@ import ( "path" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/log" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - resolverMock "github.com/ethersphere/bee/pkg/resolver/mock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/log" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + resolverMock "github.com/ethersphere/bee/v2/pkg/resolver/mock" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestSubdomains(t *testing.T) { diff --git a/pkg/api/tag.go b/pkg/api/tag.go index 8241c25d285..6a38fd7a65b 100644 --- a/pkg/api/tag.go +++ b/pkg/api/tag.go @@ -11,10 +11,10 @@ import ( "net/http" "time" - "github.com/ethersphere/bee/pkg/jsonhttp" - storage "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + storage "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/api/tag_test.go b/pkg/api/tag_test.go index dea820e3860..d3b8edeb4dc 100644 --- a/pkg/api/tag_test.go +++ b/pkg/api/tag_test.go @@ -11,14 +11,14 @@ import ( "strconv" "testing" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" ) func tagsWithIdResource(id uint64) string { return fmt.Sprintf("/tags/%d", id) } diff --git a/pkg/api/topology.go b/pkg/api/topology.go index 9721454ea44..3cae56313c3 100644 --- a/pkg/api/topology.go +++ b/pkg/api/topology.go @@ -10,7 +10,7 @@ import ( "io" "net/http" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" ) func (s *Service) topologyHandler(w http.ResponseWriter, _ *http.Request) { diff --git a/pkg/api/topology_test.go b/pkg/api/topology_test.go index a7d90994821..ebd22532f3b 100644 --- a/pkg/api/topology_test.go +++ b/pkg/api/topology_test.go @@ -8,7 +8,7 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" ) func TestTopologyOK(t *testing.T) { diff --git a/pkg/api/transaction.go b/pkg/api/transaction.go index 71eecdd8c95..6f93be7ca57 100644 --- a/pkg/api/transaction.go +++ b/pkg/api/transaction.go @@ -12,10 +12,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/transaction" "github.com/gorilla/mux" ) diff --git a/pkg/api/transaction_test.go b/pkg/api/transaction_test.go index 7c202aa9def..46e066c4091 100644 --- a/pkg/api/transaction_test.go +++ b/pkg/api/transaction_test.go @@ -14,12 +14,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction/mock" ) func TestTransactionStoredTransaction(t *testing.T) { diff --git a/pkg/api/util.go b/pkg/api/util.go index 950be4ab068..a1ad148f6d5 100644 --- a/pkg/api/util.go +++ b/pkg/api/util.go @@ -15,8 +15,8 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/pss" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/hashicorp/go-multierror" "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/api/util_test.go b/pkg/api/util_test.go index 5f8dd3564b4..6aa55fbf891 100644 --- a/pkg/api/util_test.go +++ b/pkg/api/util_test.go @@ -14,8 +14,8 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/api/wallet.go b/pkg/api/wallet.go index c98e83b5987..5cdd0de087d 100644 --- a/pkg/api/wallet.go +++ b/pkg/api/wallet.go @@ -5,11 +5,18 @@ package api import ( + "math/big" "net/http" + "strings" + + "slices" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/gorilla/mux" ) type walletResponse struct { @@ -47,3 +54,97 @@ func (s *Service) walletHandler(w http.ResponseWriter, r *http.Request) { WalletAddress: s.ethereumAddress, }) } + +type walletTxResponse struct { + TransactionHash common.Hash `json:"transactionHash"` +} + +func (s *Service) walletWithdrawHandler(w http.ResponseWriter, r *http.Request) { + logger := s.logger.WithName("post_wallet_withdraw").Build() + + queries := struct { + Amount *big.Int `map:"amount" validate:"required"` + Address *common.Address `map:"address" validate:"required"` + }{} + + if response := s.mapStructure(r.URL.Query(), &queries); response != nil { + response("invalid query params", logger, w) + return + } + + path := struct { + Coin *string `map:"coin" validate:"required"` + }{} + + if response := s.mapStructure(mux.Vars(r), &path); response != nil { + response("invalid query params", logger, w) + return + } + + var bzz bool + + if strings.EqualFold("BZZ", *path.Coin) { + bzz = true + } else if !strings.EqualFold("NativeToken", *path.Coin) { + jsonhttp.BadRequest(w, "only BZZ or NativeToken options are accepted") + return + } + + if !slices.Contains(s.whitelistedWithdrawalAddress, *queries.Address) { + jsonhttp.BadRequest(w, "provided address not whitelisted") + return + } + + if bzz { + currentBalance, err := s.erc20Service.BalanceOf(r.Context(), s.ethereumAddress) + if err != nil { + logger.Error(err, "unable to get balance") + jsonhttp.InternalServerError(w, "unable to get balance") + return + } + + if queries.Amount.Cmp(currentBalance) > 0 { + logger.Error(err, "not enough balance") + jsonhttp.BadRequest(w, "not enough balance") + return + } + + txHash, err := s.erc20Service.Transfer(r.Context(), *queries.Address, queries.Amount) + if err != nil { + logger.Error(err, "unable to transfer") + jsonhttp.InternalServerError(w, "unable to transfer amount") + return + } + jsonhttp.OK(w, walletTxResponse{TransactionHash: txHash}) + return + } + + nativeToken, err := s.chainBackend.BalanceAt(r.Context(), s.ethereumAddress, nil) + if err != nil { + logger.Error(err, "unable to acquire balance from the chain backend") + jsonhttp.InternalServerError(w, "unable to acquire balance from the chain backend") + return + } + + if queries.Amount.Cmp(nativeToken) > 0 { + jsonhttp.BadRequest(w, "not enough balance") + return + } + + req := &transaction.TxRequest{ + To: queries.Address, + GasPrice: sctx.GetGasPrice(r.Context()), + GasLimit: sctx.GetGasLimitWithDefault(r.Context(), 300_000), + Value: queries.Amount, + Description: "native token withdraw", + } + + txHash, err := s.transaction.Send(r.Context(), req, transaction.DefaultTipBoostPercent) + if err != nil { + logger.Error(err, "unable to transfer") + jsonhttp.InternalServerError(w, "unable to transfer") + return + } + + jsonhttp.OK(w, walletTxResponse{TransactionHash: txHash}) +} diff --git a/pkg/api/wallet_test.go b/pkg/api/wallet_test.go index a5a881f7b24..c6f7449d51a 100644 --- a/pkg/api/wallet_test.go +++ b/pkg/api/wallet_test.go @@ -11,12 +11,14 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/bigint" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - erc20mock "github.com/ethersphere/bee/pkg/settlement/swap/erc20/mock" - "github.com/ethersphere/bee/pkg/transaction/backendmock" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + erc20mock "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20/mock" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction/backendmock" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" ) func TestWallet(t *testing.T) { @@ -86,3 +88,203 @@ func TestWallet(t *testing.T) { })) }) } + +func TestWalletWithdraw(t *testing.T) { + t.Parallel() + + t.Run("address not whitelisted", func(t *testing.T) { + t.Parallel() + + srv, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true}) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/BZZ?address=0xaf&amount=99999999", http.StatusBadRequest, + jsonhttptest.WithExpectedJSONResponse(jsonhttp.StatusResponse{ + Message: "provided address not whitelisted", + Code: 400, + })) + }) + + t.Run("invalid coin type", func(t *testing.T) { + t.Parallel() + + srv, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true}) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/BTC?address=0xaf&amount=99999999", http.StatusBadRequest, + jsonhttptest.WithExpectedJSONResponse(jsonhttp.StatusResponse{ + Message: "only BZZ or NativeToken options are accepted", + Code: 400, + })) + }) + + t.Run("BZZ erc20 balance error", func(t *testing.T) { + t.Parallel() + + srv, _, _, _ := newTestServer(t, testServerOptions{ + DebugAPI: true, + WhitelistedAddr: "0xaf", + }) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/BZZ?address=0xaf&amount=99999999", http.StatusInternalServerError, + jsonhttptest.WithExpectedJSONResponse(jsonhttp.StatusResponse{ + Message: "unable to get balance", + Code: 500, + })) + }) + + t.Run("BZZ erc20 balance insufficient", func(t *testing.T) { + t.Parallel() + + srv, _, _, _ := newTestServer(t, testServerOptions{ + DebugAPI: true, + WhitelistedAddr: "0xaf", + Erc20Opts: []erc20mock.Option{ + erc20mock.WithBalanceOfFunc(func(ctx context.Context, address common.Address) (*big.Int, error) { + return big.NewInt(88888888), nil + }), + }, + }) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/BZZ?address=0xaf&amount=99999999", http.StatusBadRequest, + jsonhttptest.WithExpectedJSONResponse(jsonhttp.StatusResponse{ + Message: "not enough balance", + Code: 400, + })) + }) + + t.Run("BZZ erc20 transfer error", func(t *testing.T) { + t.Parallel() + + srv, _, _, _ := newTestServer(t, testServerOptions{ + DebugAPI: true, + WhitelistedAddr: "0xaf", + Erc20Opts: []erc20mock.Option{ + erc20mock.WithBalanceOfFunc(func(ctx context.Context, address common.Address) (*big.Int, error) { + return big.NewInt(100000000), nil + }), + }, + }) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/BZZ?address=0xaf&amount=99999999", http.StatusInternalServerError, + jsonhttptest.WithExpectedJSONResponse(jsonhttp.StatusResponse{ + Message: "unable to transfer amount", + Code: 500, + })) + }) + + t.Run("BZZ erc20 transfer ok", func(t *testing.T) { + t.Parallel() + + txHash := common.HexToHash("0x00f") + + srv, _, _, _ := newTestServer(t, testServerOptions{ + DebugAPI: true, + WhitelistedAddr: "0xaf", + Erc20Opts: []erc20mock.Option{ + erc20mock.WithBalanceOfFunc(func(ctx context.Context, address common.Address) (*big.Int, error) { + return big.NewInt(100000000), nil + }), + erc20mock.WithTransferFunc(func(ctx context.Context, address common.Address, value *big.Int) (common.Hash, error) { + if address != common.HexToAddress("0xaf") { + t.Fatalf("want addr 0xaf, got %s", address) + } + if value.Cmp(big.NewInt(99999999)) != 0 { + t.Fatalf("want value 99999999, got %s", value) + } + return txHash, nil + }), + }, + }) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/BZZ?address=0xaf&amount=99999999", http.StatusOK, + jsonhttptest.WithExpectedJSONResponse(api.WalletTxResponse{ + TransactionHash: txHash, + })) + }) + + t.Run("native balance error", func(t *testing.T) { + t.Parallel() + + srv, _, _, _ := newTestServer(t, testServerOptions{ + DebugAPI: true, + WhitelistedAddr: "0xaf", + }) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/NativeToken?address=0xaf&amount=99999999", http.StatusInternalServerError, + jsonhttptest.WithExpectedJSONResponse(jsonhttp.StatusResponse{ + Message: "unable to acquire balance from the chain backend", + Code: 500, + })) + }) + + t.Run("native insufficient balance", func(t *testing.T) { + t.Parallel() + + srv, _, _, _ := newTestServer(t, testServerOptions{ + DebugAPI: true, + WhitelistedAddr: "0xaf", + BackendOpts: []backendmock.Option{ + backendmock.WithBalanceAt(func(ctx context.Context, address common.Address, block *big.Int) (*big.Int, error) { + return big.NewInt(99999990), nil + }), + }, + }) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/NativeToken?address=0xaf&amount=99999999", http.StatusBadRequest, + jsonhttptest.WithExpectedJSONResponse(jsonhttp.StatusResponse{ + Message: "not enough balance", + Code: 400, + })) + }) + + t.Run("native backend send error", func(t *testing.T) { + t.Parallel() + + srv, _, _, _ := newTestServer(t, testServerOptions{ + DebugAPI: true, + WhitelistedAddr: "0xaf", + BackendOpts: []backendmock.Option{ + backendmock.WithBalanceAt(func(ctx context.Context, address common.Address, block *big.Int) (*big.Int, error) { + return big.NewInt(100000000), nil + }), + }, + }) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/NativeToken?address=0xaf&amount=99999999", http.StatusInternalServerError, + jsonhttptest.WithExpectedJSONResponse(jsonhttp.StatusResponse{ + Message: "unable to transfer", + Code: 500, + })) + }) + + t.Run("native ok", func(t *testing.T) { + t.Parallel() + + txHash := common.HexToHash("0x00f") + + srv, _, _, _ := newTestServer(t, testServerOptions{ + DebugAPI: true, + WhitelistedAddr: "0xaf", + BackendOpts: []backendmock.Option{ + backendmock.WithBalanceAt(func(ctx context.Context, address common.Address, block *big.Int) (*big.Int, error) { + return big.NewInt(100000000), nil + }), + }, + TransactionOpts: []transactionmock.Option{ + transactionmock.WithSendFunc(func(ctx context.Context, tx *transaction.TxRequest, i int) (common.Hash, error) { + if tx.Value.Cmp(big.NewInt(99999999)) != 0 { + t.Fatalf("bad value, want 99999999, got %s", tx.Value) + } + if tx.To.Cmp(common.HexToAddress("0xaf")) != 0 { + t.Fatalf("bad address, want 0xaf, got %s", tx.To) + } + return txHash, nil + }), + }, + }) + + jsonhttptest.Request(t, srv, http.MethodPost, "/wallet/withdraw/NativeToken?address=0xaf&amount=99999999", http.StatusOK, + jsonhttptest.WithExpectedJSONResponse(api.WalletTxResponse{ + TransactionHash: txHash, + })) + }) +} diff --git a/pkg/api/welcome_message.go b/pkg/api/welcome_message.go index 0d51d4977f7..e19b9b01a9b 100644 --- a/pkg/api/welcome_message.go +++ b/pkg/api/welcome_message.go @@ -8,7 +8,7 @@ import ( "encoding/json" "net/http" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" ) const welcomeMessageMaxRequestSize = 512 diff --git a/pkg/api/welcome_message_test.go b/pkg/api/welcome_message_test.go index 8bfc4075302..39d7c19a039 100644 --- a/pkg/api/welcome_message_test.go +++ b/pkg/api/welcome_message_test.go @@ -11,10 +11,10 @@ import ( "net/http" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" - "github.com/ethersphere/bee/pkg/p2p/mock" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/p2p/mock" ) func TestGetWelcomeMessage(t *testing.T) { diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index 5638c29c26c..ee3b8a65290 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -18,7 +18,7 @@ import ( "github.com/casbin/casbin/v2" "github.com/casbin/casbin/v2/model" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/log" "golang.org/x/crypto/bcrypt" ) @@ -242,7 +242,7 @@ func (e encrypter) decrypt(data []byte) ([]byte, error) { func applyPolicies(e *casbin.Enforcer) error { _, err := e.AddPolicies([][]string{ - {"consumer", "/bytes/*", "GET"}, + {"consumer", "/bytes/*", "(GET)|(HEAD)"}, {"creator", "/bytes", "POST"}, {"consumer", "/chunks/*", "GET"}, {"creator", "/chunks", "POST"}, @@ -250,7 +250,7 @@ func applyPolicies(e *casbin.Enforcer) error { {"creator", "/bzz/*", "PATCH"}, {"creator", "/bzz", "POST"}, {"creator", "/bzz?*", "POST"}, - {"consumer", "/bzz/*/*", "GET"}, + {"consumer", "/bzz/*/*", "(GET)|(HEAD)"}, {"creator", "/tags", "GET"}, {"creator", "/tags?*", "GET"}, {"creator", "/tags", "POST"}, @@ -291,6 +291,7 @@ func applyPolicies(e *casbin.Enforcer) error { {"maintainer", "/chequebook/address", "GET"}, {"maintainer", "/chequebook/balance", "GET"}, {"maintainer", "/wallet", "GET"}, + {"maintainer", "/wallet/withdraw/*", "POST"}, {"maintainer", "/chunks/*", "(GET)|(DELETE)"}, {"maintainer", "/reservestate", "GET"}, {"maintainer", "/chainstate", "GET"}, diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index 28f16b58e0e..0d107a764a2 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/auth" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/auth" + "github.com/ethersphere/bee/v2/pkg/log" ) const ( diff --git a/pkg/auth/handler.go b/pkg/auth/handler.go index 2e79ee42e73..6a54b9269be 100644 --- a/pkg/auth/handler.go +++ b/pkg/auth/handler.go @@ -9,7 +9,7 @@ import ( "net/http" "strings" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" ) type auth interface { diff --git a/pkg/bigint/bigint_test.go b/pkg/bigint/bigint_test.go index 4cbde9034f9..f51aff05c46 100644 --- a/pkg/bigint/bigint_test.go +++ b/pkg/bigint/bigint_test.go @@ -11,7 +11,7 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/bigint" + "github.com/ethersphere/bee/v2/pkg/bigint" ) func TestMarshaling(t *testing.T) { diff --git a/pkg/blocker/blocker.go b/pkg/blocker/blocker.go index 151d8ad3dfb..5b916c81732 100644 --- a/pkg/blocker/blocker.go +++ b/pkg/blocker/blocker.go @@ -9,9 +9,9 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" "go.uber.org/atomic" ) diff --git a/pkg/blocker/blocker_test.go b/pkg/blocker/blocker_test.go index fc5ad1be247..269de291441 100644 --- a/pkg/blocker/blocker_test.go +++ b/pkg/blocker/blocker_test.go @@ -11,11 +11,11 @@ import ( "go.uber.org/goleak" - "github.com/ethersphere/bee/pkg/blocker" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/blocker" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) const ( diff --git a/pkg/bmt/benchmark_test.go b/pkg/bmt/benchmark_test.go index 55416437df1..2f49ce37179 100644 --- a/pkg/bmt/benchmark_test.go +++ b/pkg/bmt/benchmark_test.go @@ -8,10 +8,10 @@ import ( "fmt" "testing" - "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/bmt/reference" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/bmt/reference" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "golang.org/x/sync/errgroup" ) diff --git a/pkg/bmt/bmt.go b/pkg/bmt/bmt.go index f314e012776..55091ceb3a5 100644 --- a/pkg/bmt/bmt.go +++ b/pkg/bmt/bmt.go @@ -8,7 +8,7 @@ import ( "encoding/binary" "hash" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var _ Hash = (*Hasher)(nil) diff --git a/pkg/bmt/bmt_test.go b/pkg/bmt/bmt_test.go index c74e5bdf0e8..9bb5589eb6a 100644 --- a/pkg/bmt/bmt_test.go +++ b/pkg/bmt/bmt_test.go @@ -13,10 +13,10 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/bmt/reference" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/bmt/reference" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "golang.org/x/sync/errgroup" ) diff --git a/pkg/bmt/proof_test.go b/pkg/bmt/proof_test.go index 1b7f6d3b3dd..d9b4ae19438 100644 --- a/pkg/bmt/proof_test.go +++ b/pkg/bmt/proof_test.go @@ -12,8 +12,8 @@ import ( "io" "testing" - "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestProofCorrectness(t *testing.T) { diff --git a/pkg/bmt/reference/reference_test.go b/pkg/bmt/reference/reference_test.go index e2dcc556d83..f11954d522c 100644 --- a/pkg/bmt/reference/reference_test.go +++ b/pkg/bmt/reference/reference_test.go @@ -12,7 +12,7 @@ import ( "io" "testing" - "github.com/ethersphere/bee/pkg/bmt/reference" + "github.com/ethersphere/bee/v2/pkg/bmt/reference" "golang.org/x/crypto/sha3" ) diff --git a/pkg/bmtpool/bmtpool.go b/pkg/bmtpool/bmtpool.go index d5187e49fb8..88c1ad32dba 100644 --- a/pkg/bmtpool/bmtpool.go +++ b/pkg/bmtpool/bmtpool.go @@ -7,8 +7,8 @@ package bmtpool import ( - "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const Capacity = 32 diff --git a/pkg/bzz/address.go b/pkg/bzz/address.go index 41a32496ea3..42fa8fd90b4 100644 --- a/pkg/bzz/address.go +++ b/pkg/bzz/address.go @@ -16,8 +16,8 @@ import ( "fmt" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/swarm" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/bzz/address_test.go b/pkg/bzz/address_test.go index c6ebe850396..969216d29d7 100644 --- a/pkg/bzz/address_test.go +++ b/pkg/bzz/address_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/crypto" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/bzz/utilities_test.go b/pkg/bzz/utilities_test.go index dad1110b504..7e4666b66ac 100644 --- a/pkg/bzz/utilities_test.go +++ b/pkg/bzz/utilities_test.go @@ -9,9 +9,9 @@ import ( ma "github.com/multiformats/go-multiaddr" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) func Test_ContainsAddress(t *testing.T) { diff --git a/pkg/cac/cac.go b/pkg/cac/cac.go index 44af58d573b..70a20b8baf0 100644 --- a/pkg/cac/cac.go +++ b/pkg/cac/cac.go @@ -9,8 +9,8 @@ import ( "encoding/binary" "fmt" - "github.com/ethersphere/bee/pkg/bmtpool" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmtpool" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/cac/cac_test.go b/pkg/cac/cac_test.go index 0e70c2b392b..2f1384aa2a0 100644 --- a/pkg/cac/cac_test.go +++ b/pkg/cac/cac_test.go @@ -12,9 +12,9 @@ import ( "math/rand" "testing" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) func TestNew(t *testing.T) { diff --git a/pkg/crypto/clef/clef.go b/pkg/crypto/clef/clef.go index 8c111f88f36..7d30ab6335a 100644 --- a/pkg/crypto/clef/clef.go +++ b/pkg/crypto/clef/clef.go @@ -17,8 +17,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/crypto/eip712" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto/eip712" ) var ( diff --git a/pkg/crypto/clef/clef_test.go b/pkg/crypto/clef/clef_test.go index 79820c6bb8f..34573de4d1c 100644 --- a/pkg/crypto/clef/clef_test.go +++ b/pkg/crypto/clef/clef_test.go @@ -15,9 +15,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/crypto/clef" - "github.com/ethersphere/bee/pkg/crypto/eip712" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto/clef" + "github.com/ethersphere/bee/v2/pkg/crypto/eip712" ) type mockClef struct { diff --git a/pkg/crypto/crypto.go b/pkg/crypto/crypto.go index a2e0ba2e468..d10c14a9991 100644 --- a/pkg/crypto/crypto.go +++ b/pkg/crypto/crypto.go @@ -14,7 +14,7 @@ import ( "fmt" "github.com/btcsuite/btcd/btcec/v2" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" "golang.org/x/crypto/sha3" ) diff --git a/pkg/crypto/crypto_test.go b/pkg/crypto/crypto_test.go index 4911be7032f..8a477730108 100644 --- a/pkg/crypto/crypto_test.go +++ b/pkg/crypto/crypto_test.go @@ -11,8 +11,8 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestGenerateSecp256k1Key(t *testing.T) { diff --git a/pkg/crypto/dh_test.go b/pkg/crypto/dh_test.go index 67cb26ebbd2..a1dfbff6487 100644 --- a/pkg/crypto/dh_test.go +++ b/pkg/crypto/dh_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/btcsuite/btcd/btcec/v2" - "github.com/ethersphere/bee/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto" ) func TestECDHCorrect(t *testing.T) { diff --git a/pkg/crypto/mock/signer.go b/pkg/crypto/mock/signer.go index 4cd7d82142a..0f007fd47e3 100644 --- a/pkg/crypto/mock/signer.go +++ b/pkg/crypto/mock/signer.go @@ -10,8 +10,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/crypto/eip712" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto/eip712" ) type signerMock struct { diff --git a/pkg/crypto/signer.go b/pkg/crypto/signer.go index b7d1927aafe..150a05ef953 100644 --- a/pkg/crypto/signer.go +++ b/pkg/crypto/signer.go @@ -14,7 +14,7 @@ import ( btcecdsa "github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/crypto/eip712" + "github.com/ethersphere/bee/v2/pkg/crypto/eip712" ) var ( diff --git a/pkg/crypto/signer_test.go b/pkg/crypto/signer_test.go index 4c2294de1ef..b3b09ae04af 100644 --- a/pkg/crypto/signer_test.go +++ b/pkg/crypto/signer_test.go @@ -14,8 +14,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/crypto/eip712" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto/eip712" ) func TestDefaultSigner(t *testing.T) { diff --git a/pkg/discovery/discovery.go b/pkg/discovery/discovery.go index a9dd5254f2e..fe65ba26fea 100644 --- a/pkg/discovery/discovery.go +++ b/pkg/discovery/discovery.go @@ -9,7 +9,7 @@ package discovery import ( "context" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type Driver interface { diff --git a/pkg/discovery/mock/mock.go b/pkg/discovery/mock/mock.go index 48ca1d4ccb3..8fc9b861589 100644 --- a/pkg/discovery/mock/mock.go +++ b/pkg/discovery/mock/mock.go @@ -8,7 +8,7 @@ import ( "context" "sync" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type Discovery struct { diff --git a/pkg/encryption/chunk_encryption.go b/pkg/encryption/chunk_encryption.go index 0cb6a901083..72f60fcdcd9 100644 --- a/pkg/encryption/chunk_encryption.go +++ b/pkg/encryption/chunk_encryption.go @@ -5,7 +5,7 @@ package encryption import ( - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" "golang.org/x/crypto/sha3" ) @@ -20,22 +20,21 @@ func NewChunkEncrypter() ChunkEncrypter { return &chunkEncrypter{} } func (c *chunkEncrypter) EncryptChunk(chunkData []byte) (Key, []byte, []byte, error) { key := GenerateRandomKey(KeyLength) - encryptedSpan, err := newSpanEncryption(key).Encrypt(chunkData[:8]) + encryptedSpan, err := NewSpanEncryption(key).Encrypt(chunkData[:8]) if err != nil { return nil, nil, nil, err } - encryptedData, err := newDataEncryption(key).Encrypt(chunkData[8:]) + encryptedData, err := NewDataEncryption(key).Encrypt(chunkData[8:]) if err != nil { return nil, nil, nil, err } return key, encryptedSpan, encryptedData, nil } -func newSpanEncryption(key Key) Interface { - refSize := int64(swarm.HashSize + KeyLength) - return New(key, 0, uint32(swarm.ChunkSize/refSize), sha3.NewLegacyKeccak256) +func NewSpanEncryption(key Key) Interface { + return New(key, 0, uint32(swarm.ChunkSize/KeyLength), sha3.NewLegacyKeccak256) } -func newDataEncryption(key Key) Interface { +func NewDataEncryption(key Key) Interface { return New(key, int(swarm.ChunkSize), 0, sha3.NewLegacyKeccak256) } diff --git a/pkg/encryption/elgamal/encryption.go b/pkg/encryption/elgamal/encryption.go index 6629bde3188..f3293b5f7ce 100644 --- a/pkg/encryption/elgamal/encryption.go +++ b/pkg/encryption/elgamal/encryption.go @@ -8,8 +8,8 @@ import ( "crypto/ecdsa" "hash" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/encryption" ) // New constructs an encryption interface (the modified blockcipher) with a base key derived from diff --git a/pkg/encryption/elgamal/encryption_test.go b/pkg/encryption/elgamal/encryption_test.go index da00b070701..ea14c77bc9f 100644 --- a/pkg/encryption/elgamal/encryption_test.go +++ b/pkg/encryption/elgamal/encryption_test.go @@ -10,9 +10,9 @@ import ( "io" "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/encryption/elgamal" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/encryption/elgamal" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestElgamalCorrect(t *testing.T) { diff --git a/pkg/encryption/encryption_test.go b/pkg/encryption/encryption_test.go index 9c7f58db591..01d7c70d687 100644 --- a/pkg/encryption/encryption_test.go +++ b/pkg/encryption/encryption_test.go @@ -21,9 +21,9 @@ import ( "encoding/hex" "testing" - "github.com/ethersphere/bee/pkg/encryption" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "golang.org/x/crypto/sha3" ) diff --git a/pkg/encryption/mock/chunk_encryption.go b/pkg/encryption/mock/chunk_encryption.go index a49f5ba4b6d..48049ab58db 100644 --- a/pkg/encryption/mock/chunk_encryption.go +++ b/pkg/encryption/mock/chunk_encryption.go @@ -5,7 +5,7 @@ package mock import ( - "github.com/ethersphere/bee/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/encryption" ) type chunkEncrypter struct { diff --git a/pkg/encryption/mock/mock.go b/pkg/encryption/mock/mock.go index 731b86fead3..66420fb2f1b 100644 --- a/pkg/encryption/mock/mock.go +++ b/pkg/encryption/mock/mock.go @@ -7,7 +7,7 @@ package mock import ( "errors" - "github.com/ethersphere/bee/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/encryption" ) var _ encryption.Interface = (*Encryptor)(nil) diff --git a/pkg/encryption/mock/mock_test.go b/pkg/encryption/mock/mock_test.go index 69b7bf94e1d..97e52b7777c 100644 --- a/pkg/encryption/mock/mock_test.go +++ b/pkg/encryption/mock/mock_test.go @@ -9,7 +9,7 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/encryption/mock" + "github.com/ethersphere/bee/v2/pkg/encryption/mock" ) var errTest = errors.New("test error") diff --git a/pkg/encryption/store/decrypt_store.go b/pkg/encryption/store/decrypt_store.go index 7a9f0395e91..66a6341ae84 100644 --- a/pkg/encryption/store/decrypt_store.go +++ b/pkg/encryption/store/decrypt_store.go @@ -8,12 +8,11 @@ import ( "context" "encoding/binary" - "github.com/ethersphere/bee/pkg/encryption" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/file/redundancy" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "golang.org/x/crypto/sha3" + "github.com/ethersphere/bee/v2/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type decryptingStore struct { @@ -73,22 +72,13 @@ func DecryptChunkData(chunkData []byte, encryptionKey encryption.Key) ([]byte, e } func decrypt(chunkData []byte, key encryption.Key) ([]byte, []byte, error) { - decryptedSpan, err := newSpanEncryption(key).Decrypt(chunkData[:swarm.SpanSize]) + decryptedSpan, err := encryption.NewSpanEncryption(key).Decrypt(chunkData[:swarm.SpanSize]) if err != nil { return nil, nil, err } - decryptedData, err := newDataEncryption(key).Decrypt(chunkData[swarm.SpanSize:]) + decryptedData, err := encryption.NewDataEncryption(key).Decrypt(chunkData[swarm.SpanSize:]) if err != nil { return nil, nil, err } return decryptedSpan, decryptedData, nil } - -func newSpanEncryption(key encryption.Key) encryption.Interface { - refSize := int64(swarm.HashSize + encryption.KeyLength) - return encryption.New(key, 0, uint32(swarm.ChunkSize/refSize), sha3.NewLegacyKeccak256) -} - -func newDataEncryption(key encryption.Key) encryption.Interface { - return encryption.New(key, int(swarm.ChunkSize), 0, sha3.NewLegacyKeccak256) -} diff --git a/pkg/feeds/epochs/epoch.go b/pkg/feeds/epochs/epoch.go index b59f7ce2e00..dee107c44e6 100644 --- a/pkg/feeds/epochs/epoch.go +++ b/pkg/feeds/epochs/epoch.go @@ -10,8 +10,8 @@ import ( "encoding/binary" "fmt" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" ) const ( diff --git a/pkg/feeds/epochs/finder.go b/pkg/feeds/epochs/finder.go index ad826ac1c01..a85ab309e76 100644 --- a/pkg/feeds/epochs/finder.go +++ b/pkg/feeds/epochs/finder.go @@ -8,9 +8,9 @@ import ( "context" "errors" - "github.com/ethersphere/bee/pkg/feeds" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/feeds" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var _ feeds.Lookup = (*finder)(nil) diff --git a/pkg/feeds/epochs/lookup_benchmark_test.go b/pkg/feeds/epochs/lookup_benchmark_test.go index 2226e94bbef..8f964bc553b 100644 --- a/pkg/feeds/epochs/lookup_benchmark_test.go +++ b/pkg/feeds/epochs/lookup_benchmark_test.go @@ -9,11 +9,11 @@ import ( "fmt" "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/feeds/epochs" - feedstesting "github.com/ethersphere/bee/pkg/feeds/testing" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/feeds/epochs" + feedstesting "github.com/ethersphere/bee/v2/pkg/feeds/testing" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" ) func BenchmarkFinder(b *testing.B) { diff --git a/pkg/feeds/epochs/lookup_test.go b/pkg/feeds/epochs/lookup_test.go index 7318940532a..e89d8b62b74 100644 --- a/pkg/feeds/epochs/lookup_test.go +++ b/pkg/feeds/epochs/lookup_test.go @@ -7,11 +7,11 @@ package epochs_test import ( "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/feeds/epochs" - feedstesting "github.com/ethersphere/bee/pkg/feeds/testing" - storage "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/feeds/epochs" + feedstesting "github.com/ethersphere/bee/v2/pkg/feeds/testing" + storage "github.com/ethersphere/bee/v2/pkg/storage" ) func TestFinder_FLAKY(t *testing.T) { diff --git a/pkg/feeds/epochs/updater.go b/pkg/feeds/epochs/updater.go index 70629d2d18c..b36d77e7d96 100644 --- a/pkg/feeds/epochs/updater.go +++ b/pkg/feeds/epochs/updater.go @@ -7,9 +7,9 @@ package epochs import ( "context" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - storage "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + storage "github.com/ethersphere/bee/v2/pkg/storage" ) var _ feeds.Updater = (*updater)(nil) diff --git a/pkg/feeds/factory/factory.go b/pkg/feeds/factory/factory.go index ed20a3f1f43..1d555416407 100644 --- a/pkg/feeds/factory/factory.go +++ b/pkg/feeds/factory/factory.go @@ -5,10 +5,10 @@ package factory import ( - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/feeds/epochs" - "github.com/ethersphere/bee/pkg/feeds/sequence" - storage "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/feeds/epochs" + "github.com/ethersphere/bee/v2/pkg/feeds/sequence" + storage "github.com/ethersphere/bee/v2/pkg/storage" ) type factory struct { diff --git a/pkg/feeds/feed.go b/pkg/feeds/feed.go index 30a113a78ed..7c9495cdfac 100644 --- a/pkg/feeds/feed.go +++ b/pkg/feeds/feed.go @@ -15,10 +15,10 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ErrFeedTypeNotFound = errors.New("no such feed type") diff --git a/pkg/feeds/getter.go b/pkg/feeds/getter.go index 19c002bee20..77b7599dd9e 100644 --- a/pkg/feeds/getter.go +++ b/pkg/feeds/getter.go @@ -11,9 +11,9 @@ import ( "fmt" "time" - "github.com/ethersphere/bee/pkg/soc" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/soc" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Lookup is the interface for time based feed lookup diff --git a/pkg/feeds/putter.go b/pkg/feeds/putter.go index 21db4c6a1d7..633276f8f63 100644 --- a/pkg/feeds/putter.go +++ b/pkg/feeds/putter.go @@ -8,11 +8,11 @@ import ( "context" "encoding/binary" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/soc" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/soc" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Updater is the generic interface f diff --git a/pkg/feeds/sequence/lookup_benchmark_test.go b/pkg/feeds/sequence/lookup_benchmark_test.go index 44da69acd09..e81d8cc9a61 100644 --- a/pkg/feeds/sequence/lookup_benchmark_test.go +++ b/pkg/feeds/sequence/lookup_benchmark_test.go @@ -9,11 +9,11 @@ import ( "fmt" "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/feeds/sequence" - feedstesting "github.com/ethersphere/bee/pkg/feeds/testing" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/feeds/sequence" + feedstesting "github.com/ethersphere/bee/v2/pkg/feeds/testing" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" ) func BenchmarkFinder(b *testing.B) { diff --git a/pkg/feeds/sequence/lookup_test.go b/pkg/feeds/sequence/lookup_test.go index 8e0d17cc90b..4396736a519 100644 --- a/pkg/feeds/sequence/lookup_test.go +++ b/pkg/feeds/sequence/lookup_test.go @@ -7,11 +7,11 @@ package sequence_test import ( "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/feeds/sequence" - feedstesting "github.com/ethersphere/bee/pkg/feeds/testing" - storage "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/feeds/sequence" + feedstesting "github.com/ethersphere/bee/v2/pkg/feeds/testing" + storage "github.com/ethersphere/bee/v2/pkg/storage" ) func TestFinder(t *testing.T) { diff --git a/pkg/feeds/sequence/sequence.go b/pkg/feeds/sequence/sequence.go index f01c7a8dd84..5361086de4b 100644 --- a/pkg/feeds/sequence/sequence.go +++ b/pkg/feeds/sequence/sequence.go @@ -18,10 +18,10 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // DefaultLevels is the number of concurrent lookaheads diff --git a/pkg/feeds/testing/lookup.go b/pkg/feeds/testing/lookup.go index 1c70ec1183f..8c71098f5a6 100644 --- a/pkg/feeds/testing/lookup.go +++ b/pkg/feeds/testing/lookup.go @@ -15,11 +15,11 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type Timeout struct { diff --git a/pkg/file/addresses/addresses_getter.go b/pkg/file/addresses/addresses_getter.go index 1ef32a9f4cd..6c9c4af82d9 100644 --- a/pkg/file/addresses/addresses_getter.go +++ b/pkg/file/addresses/addresses_getter.go @@ -7,8 +7,8 @@ package addresses import ( "context" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type addressesGetterStore struct { diff --git a/pkg/file/addresses/addresses_getter_test.go b/pkg/file/addresses/addresses_getter_test.go index a5fe9d00000..b71edbe8314 100644 --- a/pkg/file/addresses/addresses_getter_test.go +++ b/pkg/file/addresses/addresses_getter_test.go @@ -11,12 +11,12 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/file/addresses" - "github.com/ethersphere/bee/pkg/file/joiner" - filetest "github.com/ethersphere/bee/pkg/file/testing" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/file/addresses" + "github.com/ethersphere/bee/v2/pkg/file/joiner" + filetest "github.com/ethersphere/bee/v2/pkg/file/testing" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestAddressesGetterIterateChunkAddresses(t *testing.T) { diff --git a/pkg/file/buffer.go b/pkg/file/buffer.go index 57e0381828d..976eca20fa0 100644 --- a/pkg/file/buffer.go +++ b/pkg/file/buffer.go @@ -7,7 +7,7 @@ package file import ( "io" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ( diff --git a/pkg/file/buffer_test.go b/pkg/file/buffer_test.go index b1760f9948f..3416db1084a 100644 --- a/pkg/file/buffer_test.go +++ b/pkg/file/buffer_test.go @@ -12,9 +12,9 @@ import ( "strconv" "testing" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) // TestChunkPipe verifies that the reads are correctly buffered for diff --git a/pkg/file/file.go b/pkg/file/file.go index fa613cea218..40241cdabaa 100644 --- a/pkg/file/file.go +++ b/pkg/file/file.go @@ -9,7 +9,7 @@ import ( "context" "io" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type Reader interface { diff --git a/pkg/file/file_test.go b/pkg/file/file_test.go index cc677336b64..f99fb081f0d 100644 --- a/pkg/file/file_test.go +++ b/pkg/file/file_test.go @@ -13,12 +13,12 @@ import ( "strings" "testing" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/file/joiner" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - test "github.com/ethersphere/bee/pkg/file/testing" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/file/joiner" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + test "github.com/ethersphere/bee/v2/pkg/file/testing" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/file/io.go b/pkg/file/io.go index 562b39742f6..8bb7ce54254 100644 --- a/pkg/file/io.go +++ b/pkg/file/io.go @@ -12,7 +12,7 @@ import ( "io" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // simpleReadCloser wraps a byte slice in a io.ReadCloser implementation. diff --git a/pkg/file/joiner/joiner.go b/pkg/file/joiner/joiner.go index dc9c850084c..fcd7e790c10 100644 --- a/pkg/file/joiner/joiner.go +++ b/pkg/file/joiner/joiner.go @@ -12,15 +12,15 @@ import ( "sync" "sync/atomic" - "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/encryption" - "github.com/ethersphere/bee/pkg/encryption/store" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/file/redundancy/getter" - "github.com/ethersphere/bee/pkg/replicas" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/encryption/store" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/file/redundancy/getter" + "github.com/ethersphere/bee/v2/pkg/replicas" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" "golang.org/x/sync/errgroup" ) @@ -67,9 +67,16 @@ func fingerprint(addrs []swarm.Address) string { // GetOrCreate returns a decoder for the given chunk address func (g *decoderCache) GetOrCreate(addrs []swarm.Address, shardCnt int) storage.Getter { + + // since a recovery decoder is not allowed, simply return the underlying netstore + if g.config.Strict && g.config.Strategy == getter.NONE { + return g.fetcher + } + if len(addrs) == shardCnt { return g.fetcher } + key := fingerprint(addrs) g.mu.Lock() defer g.mu.Unlock() @@ -80,10 +87,16 @@ func (g *decoderCache) GetOrCreate(addrs []swarm.Address, shardCnt int) storage. } return d } - remove := func() { + remove := func(err error) { g.mu.Lock() defer g.mu.Unlock() - g.cache[key] = nil + if err != nil { + // signals that a new getter is needed to reattempt to recover the data + delete(g.cache, key) + } else { + // signals that the chunks were fetched/recovered/cached so a future getter is not needed + g.cache[key] = nil + } } d = getter.New(addrs, shardCnt, g.fetcher, g.putter, remove, g.config) g.cache[key] = d @@ -129,7 +142,7 @@ func New(ctx context.Context, g storage.Getter, putter storage.Putter, address s maxBranching = rLevel.GetMaxShards() } } else { - // if root chunk has no redundancy, strategy is ignored and set to NONE and strict is set to true + // if root chunk has no redundancy, strategy is ignored and set to DATA and strict is set to true conf.Strategy = getter.DATA conf.Strict = true } @@ -222,7 +235,7 @@ func (j *joiner) readAtOffset( } // fast forward the cursor - sec := j.subtrieSection(data, cursor, pSize, parity, subTrieSize) + sec := j.subtrieSection(cursor, pSize, parity, subTrieSize) if cur+sec <= off { cur += sec continue @@ -277,7 +290,7 @@ func (j *joiner) getShards(payloadSize, parities int) int { } // brute-forces the subtrie size for each of the sections in this intermediate chunk -func (j *joiner) subtrieSection(data []byte, startIdx, payloadSize, parities int, subtrieSize int64) int64 { +func (j *joiner) subtrieSection(startIdx, payloadSize, parities int, subtrieSize int64) int64 { // assume we have a trie of size `y` then we can assume that all of // the forks except for the last one on the right are of equal size // this is due to how the splitter wraps levels. @@ -375,7 +388,7 @@ func (j *joiner) processChunkAddresses(ctx context.Context, fn swarm.AddressIter if j.refLength == encryption.ReferenceSize { cursor += swarm.HashSize * min(i, shardCnt) } - sec := j.subtrieSection(data, cursor, eSize, parity, subTrieSize) + sec := j.subtrieSection(cursor, eSize, parity, subTrieSize) if sec <= swarm.ChunkSize { continue } diff --git a/pkg/file/joiner/joiner_test.go b/pkg/file/joiner/joiner_test.go index 15d46bf220b..7938b1260ee 100644 --- a/pkg/file/joiner/joiner_test.go +++ b/pkg/file/joiner/joiner_test.go @@ -17,21 +17,21 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/file/joiner" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/file/redundancy/getter" - "github.com/ethersphere/bee/pkg/file/splitter" - filetest "github.com/ethersphere/bee/pkg/file/testing" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - testingc "github.com/ethersphere/bee/pkg/storage/testing" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" - "github.com/ethersphere/bee/pkg/util/testutil/pseudorand" - "github.com/ethersphere/bee/pkg/util/testutil/racedetection" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/file/joiner" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/file/redundancy/getter" + "github.com/ethersphere/bee/v2/pkg/file/splitter" + filetest "github.com/ethersphere/bee/v2/pkg/file/testing" + "github.com/ethersphere/bee/v2/pkg/log" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + testingc "github.com/ethersphere/bee/v2/pkg/storage/testing" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/util/testutil/pseudorand" "gitlab.com/nolash/go-mockbytes" "golang.org/x/sync/errgroup" ) @@ -88,7 +88,7 @@ func TestJoinerSingleChunk(t *testing.T) { } } -// TestJoinerDecryptingStore_NormalChunk verifies the the mock store that uses +// TestJoinerDecryptingStore_NormalChunk verifies the mock store that uses // the decrypting store manages to retrieve a normal chunk which is not encrypted func TestJoinerDecryptingStore_NormalChunk(t *testing.T) { t.Parallel() @@ -1109,12 +1109,19 @@ func TestJoinerRedundancy(t *testing.T) { if err != nil { t.Fatal(err) } - strategyTimeout := 100 * time.Millisecond // all data can be read back readCheck := func(t *testing.T, expErr error) { - ctx, cancel := context.WithTimeout(context.Background(), 15*strategyTimeout) - defer cancel() - ctx = getter.SetConfigInContext(ctx, getter.RACE, true, (10 * strategyTimeout).String(), strategyTimeout.String()) + ctx := context.Background() + + decodeTimeoutStr := time.Second.String() + fallback := true + s := getter.RACE + + ctx, err := getter.SetConfigInContext(ctx, &s, &fallback, &decodeTimeoutStr, log.Noop) + if err != nil { + t.Fatal(err) + } + joinReader, rootSpan, err := joiner.New(ctx, store, store, swarmAddr) if err != nil { t.Fatal(err) @@ -1159,14 +1166,14 @@ func TestJoinerRedundancy(t *testing.T) { } } t.Run("no recovery possible with no chunk stored", func(t *testing.T) { - readCheck(t, context.DeadlineExceeded) + readCheck(t, storage.ErrNotFound) }) if err := putter.store(shardCnt - 1); err != nil { t.Fatal(err) } t.Run("no recovery possible with 1 short of shardCnt chunks stored", func(t *testing.T) { - readCheck(t, context.DeadlineExceeded) + readCheck(t, storage.ErrNotFound) }) if err := putter.store(1); err != nil { @@ -1220,7 +1227,7 @@ func TestJoinerRedundancy(t *testing.T) { // nolint:thelper func TestJoinerRedundancyMultilevel(t *testing.T) { t.Parallel() - test := func(t *testing.T, rLevel redundancy.Level, encrypt bool, levels, size int) { + test := func(t *testing.T, rLevel redundancy.Level, encrypt bool, size int) { t.Helper() store := mockstorer.NewForgettingStore(inmemchunkstore.New()) testutil.CleanupCloser(t, store) @@ -1240,16 +1247,16 @@ func TestJoinerRedundancyMultilevel(t *testing.T) { expRead := swarm.ChunkSize buf := make([]byte, expRead) offset := mrand.Intn(size) * expRead - canReadRange := func(t *testing.T, s getter.Strategy, fallback bool, levels int, canRead bool) { + canReadRange := func(t *testing.T, s getter.Strategy, fallback bool, canRead bool) { ctx := context.Background() - strategyTimeout := 100 * time.Millisecond - decodingTimeout := 600 * time.Millisecond - if racedetection.IsOn() { - decodingTimeout *= 2 + + decodingTimeoutStr := (200 * time.Millisecond).String() + + ctx, err := getter.SetConfigInContext(ctx, &s, &fallback, &decodingTimeoutStr, log.Noop) + if err != nil { + t.Fatal(err) } - ctx = getter.SetConfigInContext(ctx, s, fallback, (2 * strategyTimeout).String(), strategyTimeout.String()) - ctx, cancel := context.WithTimeout(ctx, time.Duration(levels)*(3*strategyTimeout+decodingTimeout)) - defer cancel() + j, _, err := joiner.New(ctx, store, store, addr) if err != nil { t.Fatal(err) @@ -1280,39 +1287,39 @@ func TestJoinerRedundancyMultilevel(t *testing.T) { } } - // first sanity check and and recover a range + // first sanity check and recover a range t.Run("NONE w/o fallback CAN retrieve", func(t *testing.T) { store.Record() defer store.Unrecord() - canReadRange(t, getter.NONE, false, levels, true) + canReadRange(t, getter.NONE, false, true) }) // do not forget the root chunk store.Unmiss(swarm.NewAddress(addr.Bytes()[:swarm.HashSize])) // after we forget the chunks on the way to the range, we should not be able to retrieve t.Run("NONE w/o fallback CANNOT retrieve", func(t *testing.T) { - canReadRange(t, getter.NONE, false, levels, false) + canReadRange(t, getter.NONE, false, false) }) // we lost a data chunk, we cannot recover using DATA only strategy with no fallback t.Run("DATA w/o fallback CANNOT retrieve", func(t *testing.T) { - canReadRange(t, getter.DATA, false, levels, false) + canReadRange(t, getter.DATA, false, false) }) if rLevel == 0 { // allowing fallback mode will not help if no redundancy used for upload t.Run("DATA w fallback CANNOT retrieve", func(t *testing.T) { - canReadRange(t, getter.DATA, true, levels, false) + canReadRange(t, getter.DATA, true, false) }) return } // allowing fallback mode will make the range retrievable using erasure decoding t.Run("DATA w fallback CAN retrieve", func(t *testing.T) { - canReadRange(t, getter.DATA, true, levels, true) + canReadRange(t, getter.DATA, true, true) }) // after the reconstructed data is stored, we can retrieve the range using DATA only mode t.Run("after recovery, NONE w/o fallback CAN retrieve", func(t *testing.T) { - canReadRange(t, getter.NONE, false, levels, true) + canReadRange(t, getter.NONE, false, true) }) } r2level := []int{2, 1, 2, 3, 2} @@ -1342,7 +1349,7 @@ func TestJoinerRedundancyMultilevel(t *testing.T) { if r2level[rLevel] != levels || encrypt != encryptChunk[rLevel] { t.Skip("skipping to save time") } - test(t, rLevel, encrypt, levels, chunkCnt) + test(t, rLevel, encrypt, chunkCnt) }) switch levels { case 1: @@ -1353,7 +1360,7 @@ func TestJoinerRedundancyMultilevel(t *testing.T) { continue } t.Run(fmt.Sprintf("encrypt=%v levels=%d chunks=%d full", encrypt, levels, chunkCnt), func(t *testing.T) { - test(t, rLevel, encrypt, levels, chunkCnt) + test(t, rLevel, encrypt, chunkCnt) }) } } diff --git a/pkg/file/loadsave/loadsave.go b/pkg/file/loadsave/loadsave.go index 1d65e45ab6b..6a2a0bbf782 100644 --- a/pkg/file/loadsave/loadsave.go +++ b/pkg/file/loadsave/loadsave.go @@ -11,12 +11,12 @@ import ( "context" "errors" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/file/joiner" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/file/joiner" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var errReadonlyLoadSave = errors.New("readonly manifest loadsaver") diff --git a/pkg/file/loadsave/loadsave_test.go b/pkg/file/loadsave/loadsave_test.go index 64154859757..f159b7056e6 100644 --- a/pkg/file/loadsave/loadsave_test.go +++ b/pkg/file/loadsave/loadsave_test.go @@ -11,12 +11,12 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/file/pipeline/bmt/bmt.go b/pkg/file/pipeline/bmt/bmt.go index 9f28b976226..669b20b8252 100644 --- a/pkg/file/pipeline/bmt/bmt.go +++ b/pkg/file/pipeline/bmt/bmt.go @@ -7,9 +7,9 @@ package bmt import ( "errors" - "github.com/ethersphere/bee/pkg/bmtpool" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmtpool" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/file/pipeline/bmt/bmt_test.go b/pkg/file/pipeline/bmt/bmt_test.go index fad40e3e3f7..109a9cc9d42 100644 --- a/pkg/file/pipeline/bmt/bmt_test.go +++ b/pkg/file/pipeline/bmt/bmt_test.go @@ -11,9 +11,9 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/bmt" - mock "github.com/ethersphere/bee/pkg/file/pipeline/mock" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/bmt" + mock "github.com/ethersphere/bee/v2/pkg/file/pipeline/mock" ) // TestStoreWriter tests that store writer stores the provided data and calls the next chain writer. diff --git a/pkg/file/pipeline/builder/builder.go b/pkg/file/pipeline/builder/builder.go index d022ed5724a..50a05e56c4d 100644 --- a/pkg/file/pipeline/builder/builder.go +++ b/pkg/file/pipeline/builder/builder.go @@ -10,16 +10,16 @@ import ( "fmt" "io" - "github.com/ethersphere/bee/pkg/encryption" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/bmt" - enc "github.com/ethersphere/bee/pkg/file/pipeline/encryption" - "github.com/ethersphere/bee/pkg/file/pipeline/feeder" - "github.com/ethersphere/bee/pkg/file/pipeline/hashtrie" - "github.com/ethersphere/bee/pkg/file/pipeline/store" - "github.com/ethersphere/bee/pkg/file/redundancy" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/bmt" + enc "github.com/ethersphere/bee/v2/pkg/file/pipeline/encryption" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/feeder" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/hashtrie" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/store" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // NewPipelineBuilder returns the appropriate pipeline according to the specified parameters diff --git a/pkg/file/pipeline/builder/builder_test.go b/pkg/file/pipeline/builder/builder_test.go index 266474d9376..9f8070b1510 100644 --- a/pkg/file/pipeline/builder/builder_test.go +++ b/pkg/file/pipeline/builder/builder_test.go @@ -12,11 +12,11 @@ import ( "strconv" "testing" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - test "github.com/ethersphere/bee/pkg/file/testing" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + test "github.com/ethersphere/bee/v2/pkg/file/testing" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) func TestPartialWrites(t *testing.T) { diff --git a/pkg/file/pipeline/encryption/encryption.go b/pkg/file/pipeline/encryption/encryption.go index 0471c4121f0..905b031254e 100644 --- a/pkg/file/pipeline/encryption/encryption.go +++ b/pkg/file/pipeline/encryption/encryption.go @@ -5,8 +5,8 @@ package encryption import ( - "github.com/ethersphere/bee/pkg/encryption" - "github.com/ethersphere/bee/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" ) type encryptionWriter struct { diff --git a/pkg/file/pipeline/encryption/encryption_test.go b/pkg/file/pipeline/encryption/encryption_test.go index 8c0811ee947..49306a7d27b 100644 --- a/pkg/file/pipeline/encryption/encryption_test.go +++ b/pkg/file/pipeline/encryption/encryption_test.go @@ -9,10 +9,10 @@ import ( "encoding/binary" "testing" - mockenc "github.com/ethersphere/bee/pkg/encryption/mock" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/encryption" - mock "github.com/ethersphere/bee/pkg/file/pipeline/mock" + mockenc "github.com/ethersphere/bee/v2/pkg/encryption/mock" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/encryption" + mock "github.com/ethersphere/bee/v2/pkg/file/pipeline/mock" ) var ( diff --git a/pkg/file/pipeline/feeder/feeder.go b/pkg/file/pipeline/feeder/feeder.go index 03d77cfb49c..8e5e29617a8 100644 --- a/pkg/file/pipeline/feeder/feeder.go +++ b/pkg/file/pipeline/feeder/feeder.go @@ -7,8 +7,8 @@ package feeder import ( "encoding/binary" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const span = swarm.SpanSize diff --git a/pkg/file/pipeline/feeder/feeder_test.go b/pkg/file/pipeline/feeder/feeder_test.go index 470dbd7f032..51c56dd6a3b 100644 --- a/pkg/file/pipeline/feeder/feeder_test.go +++ b/pkg/file/pipeline/feeder/feeder_test.go @@ -10,8 +10,8 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/feeder" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/feeder" ) // TestFeeder tests that partial writes work correctly. diff --git a/pkg/file/pipeline/hashtrie/hashtrie.go b/pkg/file/pipeline/hashtrie/hashtrie.go index b3c898c76e1..b9fa52b90b8 100644 --- a/pkg/file/pipeline/hashtrie/hashtrie.go +++ b/pkg/file/pipeline/hashtrie/hashtrie.go @@ -10,11 +10,11 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/replicas" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/replicas" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/file/pipeline/hashtrie/hashtrie_test.go b/pkg/file/pipeline/hashtrie/hashtrie_test.go index 4a966e265f3..7fb7cd4a542 100644 --- a/pkg/file/pipeline/hashtrie/hashtrie_test.go +++ b/pkg/file/pipeline/hashtrie/hashtrie_test.go @@ -12,21 +12,21 @@ import ( "sync/atomic" "testing" - bmtUtils "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/encryption" - dec "github.com/ethersphere/bee/pkg/encryption/store" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/bmt" - enc "github.com/ethersphere/bee/pkg/file/pipeline/encryption" - "github.com/ethersphere/bee/pkg/file/pipeline/hashtrie" - "github.com/ethersphere/bee/pkg/file/pipeline/mock" - "github.com/ethersphere/bee/pkg/file/pipeline/store" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" + bmtUtils "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/encryption" + dec "github.com/ethersphere/bee/v2/pkg/encryption/store" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/bmt" + enc "github.com/ethersphere/bee/v2/pkg/file/pipeline/encryption" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/hashtrie" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/mock" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/store" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/file/pipeline/mock/writer.go b/pkg/file/pipeline/mock/writer.go index af76e6339d1..19f505123b2 100644 --- a/pkg/file/pipeline/mock/writer.go +++ b/pkg/file/pipeline/mock/writer.go @@ -7,7 +7,7 @@ package mock import ( "sync" - "github.com/ethersphere/bee/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" ) type MockChainWriter struct { diff --git a/pkg/file/pipeline/store/store.go b/pkg/file/pipeline/store/store.go index ec3621900c8..c1d7f4f4949 100644 --- a/pkg/file/pipeline/store/store.go +++ b/pkg/file/pipeline/store/store.go @@ -8,9 +8,9 @@ import ( "context" "errors" - "github.com/ethersphere/bee/pkg/file/pipeline" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var errInvalidData = errors.New("store: invalid data") diff --git a/pkg/file/pipeline/store/store_test.go b/pkg/file/pipeline/store/store_test.go index a3a39bace05..d7db1c885e4 100644 --- a/pkg/file/pipeline/store/store_test.go +++ b/pkg/file/pipeline/store/store_test.go @@ -10,11 +10,11 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/file/pipeline" - mock "github.com/ethersphere/bee/pkg/file/pipeline/mock" - "github.com/ethersphere/bee/pkg/file/pipeline/store" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + mock "github.com/ethersphere/bee/v2/pkg/file/pipeline/mock" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/store" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // TestStoreWriter tests that store writer stores the provided data and calls the next chain writer. diff --git a/pkg/file/redundancy/getter/getter.go b/pkg/file/redundancy/getter/getter.go index 4e8da1b6390..85bbec34435 100644 --- a/pkg/file/redundancy/getter/getter.go +++ b/pkg/file/redundancy/getter/getter.go @@ -6,80 +6,81 @@ package getter import ( "context" - "io" + "errors" "sync" "sync/atomic" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/klauspost/reedsolomon" ) +var ( + errStrategyNotAllowed = errors.New("strategy not allowed") + errStrategyFailed = errors.New("strategy failed") +) + // decoder is a private implementation of storage.Getter // if retrieves children of an intermediate chunk potentially using erasure decoding // it caches sibling chunks if erasure decoding started already type decoder struct { - fetcher storage.Getter // network retrieval interface to fetch chunks - putter storage.Putter // interface to local storage to save reconstructed chunks - addrs []swarm.Address // all addresses of the intermediate chunk - inflight []atomic.Bool // locks to protect wait channels and RS buffer - cache map[string]int // map from chunk address shard position index - waits []chan struct{} // wait channels for each chunk - rsbuf [][]byte // RS buffer of data + parity shards for erasure decoding - ready chan struct{} // signal channel for successful retrieval of shardCnt chunks - lastLen int // length of the last data chunk in the RS buffer - shardCnt int // number of data shards - parityCnt int // number of parity shards - wg sync.WaitGroup // wait group to wait for all goroutines to finish - mu sync.Mutex // mutex to protect buffer - err error // error of the last erasure decoding - fetchedCnt atomic.Int32 // count successful retrievals - cancel func() // cancel function for RS decoding - remove func() // callback to remove decoder from decoders cache - config Config // configuration -} - -type Getter interface { - storage.Getter - io.Closer + fetcher storage.Getter // network retrieval interface to fetch chunks + putter storage.Putter // interface to local storage to save reconstructed chunks + addrs []swarm.Address // all addresses of the intermediate chunk + inflight []atomic.Bool // locks to protect wait channels and RS buffer + cache map[string]int // map from chunk address shard position index + waits []chan error // wait channels for each chunk + rsbuf [][]byte // RS buffer of data + parity shards for erasure decoding + goodRecovery chan struct{} // signal channel for successful retrieval of shardCnt chunks + badRecovery chan struct{} // signals that either the recovery has failed or not allowed to run + initRecovery chan struct{} // signals that the recovery has been initialized + lastLen int // length of the last data chunk in the RS buffer + shardCnt int // number of data shards + parityCnt int // number of parity shards + mu sync.Mutex // mutex to protect buffer + fetchedCnt atomic.Int32 // count successful retrievals + failedCnt atomic.Int32 // count successful retrievals + remove func(error) // callback to remove decoder from decoders cache + config Config // configuration + logger log.Logger } // New returns a decoder object used to retrieve children of an intermediate chunk -func New(addrs []swarm.Address, shardCnt int, g storage.Getter, p storage.Putter, remove func(), conf Config) Getter { - ctx, cancel := context.WithCancel(context.Background()) +func New(addrs []swarm.Address, shardCnt int, g storage.Getter, p storage.Putter, remove func(error), conf Config) storage.Getter { size := len(addrs) - rsg := &decoder{ - fetcher: g, - putter: p, - addrs: addrs, - inflight: make([]atomic.Bool, size), - cache: make(map[string]int, size), - waits: make([]chan struct{}, shardCnt), - rsbuf: make([][]byte, size), - ready: make(chan struct{}, 1), - cancel: cancel, - remove: remove, - shardCnt: shardCnt, - parityCnt: size - shardCnt, - config: conf, + d := &decoder{ + fetcher: g, + putter: p, + addrs: addrs, + inflight: make([]atomic.Bool, size), + cache: make(map[string]int, size), + waits: make([]chan error, size), + rsbuf: make([][]byte, size), + goodRecovery: make(chan struct{}), + badRecovery: make(chan struct{}), + initRecovery: make(chan struct{}), + remove: remove, + shardCnt: shardCnt, + parityCnt: size - shardCnt, + config: conf, + logger: conf.Logger.WithName("redundancy").Build(), } // after init, cache and wait channels are immutable, need no locking for i := 0; i < shardCnt; i++ { - rsg.cache[addrs[i].ByteString()] = i - rsg.waits[i] = make(chan struct{}) + d.cache[addrs[i].ByteString()] = i } - // prefetch chunks according to strategy - if !conf.Strict || conf.Strategy != NONE { - rsg.wg.Add(1) - go func() { - rsg.err = rsg.prefetch(ctx) - rsg.wg.Done() - }() + // after init, cache and wait channels are immutable, need no locking + for i := 0; i < size; i++ { + d.waits[i] = make(chan error) } - return rsg + + go d.prefetch() + + return d } // Get will call parities and other sibling chunks if the chunk address cannot be retrieved @@ -89,110 +90,206 @@ func (g *decoder) Get(ctx context.Context, addr swarm.Address) (swarm.Chunk, err if !ok { return nil, storage.ErrNotFound } - if g.fly(i, true) { - g.wg.Add(1) - go func() { - g.fetch(ctx, i) - g.wg.Done() - }() + err := g.fetch(ctx, i, true) + if err != nil { + return nil, err + } + return swarm.NewChunk(addr, g.getData(i)), nil +} + +// fetch retrieves a chunk from the netstore if it is the first time the chunk is fetched. +// If the fetch fails and waiting for the recovery is allowed, the function will wait +// for either a good or bad recovery signal. +func (g *decoder) fetch(ctx context.Context, i int, waitForRecovery bool) (err error) { + + waitRecovery := func(err error) error { + if !waitForRecovery { + return err + } + + select { + case <-g.badRecovery: + return storage.ErrNotFound + case <-g.goodRecovery: + g.logger.Debug("recovered chunk", "address", g.addrs[i]) + return nil + case <-ctx.Done(): + return ctx.Err() + } + } + + // recovery has started, wait for result instead of fetching from the network + select { + case <-g.initRecovery: + return waitRecovery(nil) + default: + } + + // first time + if g.fly(i) { + + fctx, cancel := context.WithTimeout(ctx, g.config.FetchTimeout) + defer cancel() + + // when the recovery is triggered, we can terminate any inflight requests. + // we do the extra bool check to not fire an unnecessary goroutine + if waitForRecovery { + go func() { + defer cancel() + select { + case <-g.initRecovery: + case <-fctx.Done(): + } + }() + } + + // retrieval + ch, err := g.fetcher.Get(fctx, g.addrs[i]) + if err != nil { + g.failedCnt.Add(1) + close(g.waits[i]) + return waitRecovery(err) + } + + g.fetchedCnt.Add(1) + g.setData(i, ch.Data()) + close(g.waits[i]) + return nil } + select { case <-g.waits[i]: case <-ctx.Done(): - return nil, ctx.Err() + return ctx.Err() } - return swarm.NewChunk(addr, g.getData(i)), nil -} -// setData sets the data shard in the RS buffer -func (g *decoder) setData(i int, chdata []byte) { - data := chdata - // pad the chunk with zeros if it is smaller than swarm.ChunkSize - if len(data) < swarm.ChunkWithSpanSize { - g.lastLen = len(data) - data = make([]byte, swarm.ChunkWithSpanSize) - copy(data, chdata) + if g.getData(i) != nil { + return nil } - g.rsbuf[i] = data -} -// getData returns the data shard from the RS buffer -func (g *decoder) getData(i int) []byte { - if i == g.shardCnt-1 && g.lastLen > 0 { - return g.rsbuf[i][:g.lastLen] // cut padding - } - return g.rsbuf[i] + return waitRecovery(storage.ErrNotFound) } -// fly commits to retrieve the chunk (fly and land) -// it marks a chunk as inflight and returns true unless it is already inflight -// the atomic bool implements a singleflight pattern -func (g *decoder) fly(i int, up bool) (success bool) { - return g.inflight[i].CompareAndSwap(!up, up) -} +func (g *decoder) prefetch() { + + var err error + defer func() { + if err != nil { + close(g.badRecovery) + } else { + close(g.goodRecovery) + } + g.remove(err) + }() + + s := g.config.Strategy + for ; s < strategyCnt; s++ { + + err = g.runStrategy(s) + if err != nil && s == DATA || s == RACE { + g.logger.Debug("failed strategy", "strategy", s) + } + + if err == nil || g.config.Strict { + break + } + } -// fetch retrieves a chunk from the underlying storage -// it must be called asynchonously and only once for each chunk (singleflight pattern) -// it races with erasure recovery which takes precedence even if it started later -// due to the fact that erasure recovery could only implement global locking on all shards -func (g *decoder) fetch(ctx context.Context, i int) { - fctx, cancel := context.WithTimeout(ctx, g.config.FetchTimeout) - defer cancel() - ch, err := g.fetcher.Get(fctx, g.addrs[i]) if err != nil { - _ = g.fly(i, false) // unset inflight return } - g.mu.Lock() - defer g.mu.Unlock() - if i < len(g.waits) { - select { - case <-g.waits[i]: // if chunk is retrieved, ignore - return - default: + close(g.initRecovery) + + err = g.recover() + if err == nil && s > DATA { + g.logger.Debug("successful recovery", "strategy", s) + } + +} + +func (g *decoder) runStrategy(s Strategy) error { + + // across the different strategies, the common goal is to fetch at least as many chunks + // as the number of data shards. + // DATA strategy has a max error tolerance of zero. + // RACE strategy has a max error tolerance of number of parity chunks. + var allowedErrs int + var m []int + + switch s { + case NONE: + return errStrategyNotAllowed + case DATA: + // only retrieve data shards + m = g.unattemptedDataShards() + allowedErrs = 0 + case PROX: + // proximity driven selective fetching + // NOT IMPLEMENTED + return errStrategyNotAllowed + case RACE: + allowedErrs = g.parityCnt + // retrieve all chunks at once enabling race among chunks + m = g.unattemptedDataShards() + for i := g.shardCnt; i < len(g.addrs); i++ { + m = append(m, i) } } - select { - case <-ctx.Done(): // if context is cancelled, ignore - _ = g.fly(i, false) // unset inflight - return - default: + if len(m) == 0 { + return nil } - // write chunk to rsbuf and signal waiters - g.setData(i, ch.Data()) // save the chunk in the RS buffer - if i < len(g.waits) { // if the chunk is a data shard - close(g.waits[i]) // signal that the chunk is retrieved + c := make(chan error, len(m)) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + for _, i := range m { + go func(i int) { + c <- g.fetch(ctx, i, false) + }(i) } - // if all chunks are retrieved, signal ready - n := g.fetchedCnt.Add(1) - if n == int32(g.shardCnt) { - close(g.ready) // signal that just enough chunks are retrieved for decoding + for range c { + if g.fetchedCnt.Load() >= int32(g.shardCnt) { + return nil + } + if g.failedCnt.Load() > int32(allowedErrs) { + return errStrategyFailed + } } + + return nil } -// missing gathers missing data shards not yet retrieved -// it sets the chunk as inflight and returns the index of the missing data shards -func (g *decoder) missing() (m []int) { - for i := 0; i < g.shardCnt; i++ { - select { - case <-g.waits[i]: // if chunk is retrieved, ignore - continue - default: - } - _ = g.fly(i, true) // commit (RS) or will commit to retrieve the chunk - m = append(m, i) // remember the missing chunk +// recover wraps the stages of data shard recovery: +// 1. gather missing data shards +// 2. decode using Reed-Solomon decoder +// 3. save reconstructed chunks +func (g *decoder) recover() error { + // gather missing shards + m := g.missingDataShards() + if len(m) == 0 { + return nil // recovery is not needed as there are no missing data chunks } - return m + + // decode using Reed-Solomon decoder + if err := g.decode(); err != nil { + return err + } + + // save chunks + return g.save(m) } // decode uses Reed-Solomon erasure coding decoder to recover data shards // it must be called after shqrdcnt shards are retrieved -// it must be called under g.mu mutex protection -func (g *decoder) decode(ctx context.Context) error { +func (g *decoder) decode() error { + g.mu.Lock() + defer g.mu.Unlock() + enc, err := reedsolomon.New(g.shardCnt, g.parityCnt) if err != nil { return err @@ -202,51 +299,68 @@ func (g *decoder) decode(ctx context.Context) error { return enc.ReconstructData(g.rsbuf) } -// recover wraps the stages of data shard recovery: -// 1. gather missing data shards -// 2. decode using Reed-Solomon decoder -// 3. save reconstructed chunks -func (g *decoder) recover(ctx context.Context) error { - // buffer lock acquired - g.mu.Lock() - defer g.mu.Unlock() +func (g *decoder) unattemptedDataShards() (m []int) { + for i := 0; i < g.shardCnt; i++ { + select { + case <-g.waits[i]: // attempted + continue + default: + m = append(m, i) // remember the missing chunk + } + } + return m +} - // gather missing shards - m := g.missing() - if len(m) == 0 { - return nil +// it must be called under mutex protection +func (g *decoder) missingDataShards() (m []int) { + for i := 0; i < g.shardCnt; i++ { + if g.getData(i) == nil { + m = append(m, i) + } } + return m +} - // decode using Reed-Solomon decoder - if err := g.decode(ctx); err != nil { - return err +// setData sets the data shard in the RS buffer +func (g *decoder) setData(i int, chdata []byte) { + g.mu.Lock() + defer g.mu.Unlock() + + data := chdata + // pad the chunk with zeros if it is smaller than swarm.ChunkSize + if len(data) < swarm.ChunkWithSpanSize { + g.lastLen = len(data) + data = make([]byte, swarm.ChunkWithSpanSize) + copy(data, chdata) } + g.rsbuf[i] = data +} - // close wait channels for missing chunks - for _, i := range m { - close(g.waits[i]) +// getData returns the data shard from the RS buffer +func (g *decoder) getData(i int) []byte { + g.mu.Lock() + defer g.mu.Unlock() + if i == g.shardCnt-1 && g.lastLen > 0 { + return g.rsbuf[i][:g.lastLen] // cut padding } + return g.rsbuf[i] +} - // save chunks - return g.save(ctx, m) +// fly commits to retrieve the chunk (fly and land) +// it marks a chunk as inflight and returns true unless it is already inflight +// the atomic bool implements a singleflight pattern +func (g *decoder) fly(i int) (success bool) { + return g.inflight[i].CompareAndSwap(false, true) } // save iterate over reconstructed shards and puts the corresponding chunks to local storage -func (g *decoder) save(ctx context.Context, missing []int) error { +func (g *decoder) save(missing []int) error { + g.mu.Lock() + defer g.mu.Unlock() for _, i := range missing { - if err := g.putter.Put(ctx, swarm.NewChunk(g.addrs[i], g.rsbuf[i])); err != nil { + if err := g.putter.Put(context.Background(), swarm.NewChunk(g.addrs[i], g.rsbuf[i])); err != nil { return err } } return nil } - -// Close terminates the prefetch loop, waits for all goroutines to finish and -// removes the decoder from the cache -// it implements the io.Closer interface -func (g *decoder) Close() error { - g.cancel() - g.wg.Wait() - g.remove() - return nil -} diff --git a/pkg/file/redundancy/getter/getter_test.go b/pkg/file/redundancy/getter/getter_test.go index b18caa55c12..c229126d904 100644 --- a/pkg/file/redundancy/getter/getter_test.go +++ b/pkg/file/redundancy/getter/getter_test.go @@ -17,13 +17,12 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/file/redundancy/getter" - "github.com/ethersphere/bee/pkg/storage" - inmem "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil/racedetection" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/file/redundancy/getter" + "github.com/ethersphere/bee/v2/pkg/storage" + inmem "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/klauspost/reedsolomon" "golang.org/x/sync/errgroup" ) @@ -72,6 +71,7 @@ func TestGetterRACE(t *testing.T) { // TestGetterFallback tests the retrieval of chunks with missing data shards // using the strict or fallback mode starting with NONE and DATA strategies func TestGetterFallback(t *testing.T) { + t.Skip("removed strategy timeout") t.Run("GET", func(t *testing.T) { t.Run("NONE", func(t *testing.T) { t.Run("strict", func(t *testing.T) { @@ -94,10 +94,6 @@ func TestGetterFallback(t *testing.T) { func testDecodingRACE(t *testing.T, bufSize, shardCnt, erasureCnt int) { t.Helper() - strategyTimeout := 100 * time.Millisecond - if racedetection.On { - strategyTimeout *= 2 - } store := inmem.New() buf := make([][]byte, bufSize) addrs := initData(t, buf, shardCnt, store) @@ -113,30 +109,12 @@ func testDecodingRACE(t *testing.T, bufSize, shardCnt, erasureCnt int) { if len(addr.Bytes()) == 0 { t.Skip("no data shard erased") } - ctx, cancel := context.WithCancel(context.TODO()) - defer cancel() - conf := getter.Config{ - Strategy: getter.RACE, - FetchTimeout: 2 * strategyTimeout, - StrategyTimeout: strategyTimeout, - } - g := getter.New(addrs, shardCnt, store, store, func() {}, conf) - defer g.Close() + + g := getter.New(addrs, shardCnt, store, store, func(error) {}, getter.DefaultConfig) + parityCnt := len(buf) - shardCnt - q := make(chan error, 1) - go func() { - _, err := g.Get(ctx, addr) - q <- err - }() - err := context.DeadlineExceeded - wait := strategyTimeout * 2 - if racedetection.On { - wait *= 2 - } - select { - case err = <-q: - case <-time.After(wait): - } + _, err := g.Get(context.Background(), addr) + switch { case erasureCnt > parityCnt: t.Run("unable to recover", func(t *testing.T) { @@ -191,13 +169,11 @@ func testDecodingFallback(t *testing.T, s getter.Strategy, strict bool) { // create getter start := time.Now() conf := getter.Config{ - Strategy: s, - Strict: strict, - FetchTimeout: strategyTimeout / 2, - StrategyTimeout: strategyTimeout, + Strategy: s, + Strict: strict, + FetchTimeout: strategyTimeout / 2, } - g := getter.New(addrs, shardCnt, store, store, func() {}, conf) - defer g.Close() + g := getter.New(addrs, shardCnt, store, store, func(error) {}, conf) // launch delayed and erased chunk retrieval wg := sync.WaitGroup{} diff --git a/pkg/file/redundancy/getter/strategies.go b/pkg/file/redundancy/getter/strategies.go index bb5188e9cc2..e632f95f8c2 100644 --- a/pkg/file/redundancy/getter/strategies.go +++ b/pkg/file/redundancy/getter/strategies.go @@ -6,32 +6,33 @@ package getter import ( "context" - "errors" "fmt" "time" + + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/retrieval" ) const ( - DefaultStrategy = NONE // default prefetching strategy - DefaultStrict = true // default fallback modes - DefaultFetchTimeout = 30 * time.Second // timeout for each chunk retrieval - DefaultStrategyTimeout = 300 * time.Millisecond // timeout for each strategy + DefaultStrategy = DATA // default prefetching strategy + DefaultStrict = false // default fallback modes + DefaultFetchTimeout = retrieval.RetrieveChunkTimeout // timeout for each chunk retrieval ) type ( - strategyKey struct{} - modeKey struct{} - fetchTimeoutKey struct{} - strategyTimeoutKey struct{} - Strategy = int + strategyKey struct{} + modeKey struct{} + fetchTimeoutKey struct{} + loggerKey struct{} + Strategy = int ) // Config is the configuration for the getter - public type Config struct { - Strategy Strategy - Strict bool - FetchTimeout time.Duration - StrategyTimeout time.Duration + Strategy Strategy + Strict bool + FetchTimeout time.Duration + Logger log.Logger } const ( @@ -44,20 +45,17 @@ const ( // DefaultConfig is the default configuration for the getter var DefaultConfig = Config{ - Strategy: DefaultStrategy, - Strict: DefaultStrict, - FetchTimeout: DefaultFetchTimeout, - StrategyTimeout: DefaultStrategyTimeout, + Strategy: DefaultStrategy, + Strict: DefaultStrict, + FetchTimeout: DefaultFetchTimeout, + Logger: log.Noop, } // NewConfigFromContext returns a new Config based on the context func NewConfigFromContext(ctx context.Context, def Config) (conf Config, err error) { var ok bool conf = def - e := func(s string, errs ...error) error { - if len(errs) > 0 { - return fmt.Errorf("error setting %s from context: %w", s, errors.Join(errs...)) - } + e := func(s string) error { return fmt.Errorf("error setting %s from context", s) } if val := ctx.Value(strategyKey{}); val != nil { @@ -73,25 +71,18 @@ func NewConfigFromContext(ctx context.Context, def Config) (conf Config, err err } } if val := ctx.Value(fetchTimeoutKey{}); val != nil { - fetchTimeoutVal, ok := val.(string) + conf.FetchTimeout, ok = val.(time.Duration) if !ok { return conf, e("fetcher timeout") } - conf.FetchTimeout, err = time.ParseDuration(fetchTimeoutVal) - if err != nil { - return conf, e("fetcher timeout", err) - } } - if val := ctx.Value(strategyTimeoutKey{}); val != nil { - strategyTimeoutVal, ok := val.(string) + if val := ctx.Value(loggerKey{}); val != nil { + conf.Logger, ok = val.(log.Logger) if !ok { - return conf, e("fetcher timeout") - } - conf.StrategyTimeout, err = time.ParseDuration(strategyTimeoutVal) - if err != nil { - return conf, e("fetcher timeout", err) + return conf, e("strategy timeout") } } + return conf, nil } @@ -106,100 +97,35 @@ func SetStrict(ctx context.Context, strict bool) context.Context { } // SetFetchTimeout sets the timeout for each fetch -func SetFetchTimeout(ctx context.Context, timeout string) context.Context { +func SetFetchTimeout(ctx context.Context, timeout time.Duration) context.Context { return context.WithValue(ctx, fetchTimeoutKey{}, timeout) } -// SetStrategyTimeout sets the timeout for each strategy -func SetStrategyTimeout(ctx context.Context, timeout string) context.Context { - return context.WithValue(ctx, fetchTimeoutKey{}, timeout) +func SetLogger(ctx context.Context, l log.Logger) context.Context { + return context.WithValue(ctx, loggerKey{}, l) } // SetConfigInContext sets the config params in the context -func SetConfigInContext(ctx context.Context, s Strategy, fallbackmode bool, fetchTimeout, strategyTimeout string) context.Context { - ctx = SetStrategy(ctx, s) - ctx = SetStrict(ctx, !fallbackmode) - ctx = SetFetchTimeout(ctx, fetchTimeout) - ctx = SetStrategyTimeout(ctx, strategyTimeout) - return ctx -} - -func (g *decoder) prefetch(ctx context.Context) error { - if g.config.Strict && g.config.Strategy == NONE { - return nil +func SetConfigInContext(ctx context.Context, s *Strategy, fallbackmode *bool, fetchTimeout *string, logger log.Logger) (context.Context, error) { + if s != nil { + ctx = SetStrategy(ctx, *s) } - defer g.remove() - var cancels []func() - cancelAll := func() { - for _, cancel := range cancels { - cancel() - } - } - defer cancelAll() - run := func(s Strategy) error { - if s == PROX { // NOT IMPLEMENTED - return errors.New("strategy not implemented") - } - var stop <-chan time.Time - if s < RACE { - timer := time.NewTimer(g.config.StrategyTimeout) - defer timer.Stop() - stop = timer.C - } - lctx, cancel := context.WithCancel(ctx) - cancels = append(cancels, cancel) - prefetch(lctx, g, s) - - select { - // successfully retrieved shardCnt number of chunks - case <-g.ready: - cancelAll() - case <-stop: - return fmt.Errorf("prefetching with strategy %d timed out", s) - case <-ctx.Done(): - return nil - } - // call the erasure decoder - // if decoding is successful terminate the prefetch loop - return g.recover(ctx) // context to cancel when shardCnt chunks are retrieved - } - var err error - for s := g.config.Strategy; s < strategyCnt; s++ { - err = run(s) - if g.config.Strict || err == nil { - break - } + if fallbackmode != nil { + ctx = SetStrict(ctx, !(*fallbackmode)) } - return err -} - -// prefetch launches the retrieval of chunks based on the strategy -func prefetch(ctx context.Context, g *decoder, s Strategy) { - var m []int - switch s { - case NONE: - return - case DATA: - // only retrieve data shards - m = g.missing() - case PROX: - // proximity driven selective fetching - // NOT IMPLEMENTED - case RACE: - // retrieve all chunks at once enabling race among chunks - m = g.missing() - for i := g.shardCnt; i < len(g.addrs); i++ { - m = append(m, i) + if fetchTimeout != nil { + dur, err := time.ParseDuration(*fetchTimeout) + if err != nil { + return nil, err } + ctx = SetFetchTimeout(ctx, dur) } - for _, i := range m { - i := i - g.wg.Add(1) - go func() { - g.fetch(ctx, i) - g.wg.Done() - }() + + if logger != nil { + ctx = SetLogger(ctx, logger) } + + return ctx, nil } diff --git a/pkg/file/redundancy/level.go b/pkg/file/redundancy/level.go index f7b4f5c19f1..45b091da98b 100644 --- a/pkg/file/redundancy/level.go +++ b/pkg/file/redundancy/level.go @@ -9,7 +9,7 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Level is the redundancy level diff --git a/pkg/file/redundancy/redundancy.go b/pkg/file/redundancy/redundancy.go index 443dc0637b3..20ee7552d39 100644 --- a/pkg/file/redundancy/redundancy.go +++ b/pkg/file/redundancy/redundancy.go @@ -7,8 +7,8 @@ package redundancy import ( "fmt" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/klauspost/reedsolomon" ) diff --git a/pkg/file/redundancy/redundancy_test.go b/pkg/file/redundancy/redundancy_test.go index bb7aa35ba75..e6ad81a16a7 100644 --- a/pkg/file/redundancy/redundancy_test.go +++ b/pkg/file/redundancy/redundancy_test.go @@ -11,10 +11,10 @@ import ( "sync" "testing" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/bmt" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/bmt" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type mockEncoder struct { diff --git a/pkg/file/redundancy/span.go b/pkg/file/redundancy/span.go index eb71286fa43..9817729d3ae 100644 --- a/pkg/file/redundancy/span.go +++ b/pkg/file/redundancy/span.go @@ -5,7 +5,7 @@ package redundancy import ( - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // EncodeLevel encodes used redundancy level for uploading into span keeping the real byte count for the chunk. diff --git a/pkg/file/span.go b/pkg/file/span.go index 33c1ad66dc4..b8366233bd2 100644 --- a/pkg/file/span.go +++ b/pkg/file/span.go @@ -7,7 +7,7 @@ package file import ( "math" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var Spans []int64 diff --git a/pkg/file/splitter/internal/job.go b/pkg/file/splitter/internal/job.go index 90599defbf7..db34e5764c1 100644 --- a/pkg/file/splitter/internal/job.go +++ b/pkg/file/splitter/internal/job.go @@ -10,12 +10,11 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/encryption" - "github.com/ethersphere/bee/pkg/file" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "golang.org/x/crypto/sha3" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/file" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // maximum amount of file tree levels this file hasher component can handle @@ -256,21 +255,13 @@ func (s *SimpleSplitterJob) encryptChunkData(chunkData []byte) ([]byte, encrypti func (s *SimpleSplitterJob) encrypt(chunkData []byte) (encryption.Key, []byte, []byte, error) { key := encryption.GenerateRandomKey(encryption.KeyLength) - encryptedSpan, err := s.newSpanEncryption(key).Encrypt(chunkData[:8]) + encryptedSpan, err := encryption.NewSpanEncryption(key).Encrypt(chunkData[:8]) if err != nil { return nil, nil, nil, err } - encryptedData, err := s.newDataEncryption(key).Encrypt(chunkData[8:]) + encryptedData, err := encryption.NewDataEncryption(key).Encrypt(chunkData[8:]) if err != nil { return nil, nil, nil, err } return key, encryptedSpan, encryptedData, nil } - -func (s *SimpleSplitterJob) newSpanEncryption(key encryption.Key) encryption.Interface { - return encryption.New(key, 0, uint32(swarm.ChunkSize/s.refSize), sha3.NewLegacyKeccak256) -} - -func (s *SimpleSplitterJob) newDataEncryption(key encryption.Key) encryption.Interface { - return encryption.New(key, int(swarm.ChunkSize), 0, sha3.NewLegacyKeccak256) -} diff --git a/pkg/file/splitter/internal/job_test.go b/pkg/file/splitter/internal/job_test.go index 757fb2fc028..bc7945c4b42 100644 --- a/pkg/file/splitter/internal/job_test.go +++ b/pkg/file/splitter/internal/job_test.go @@ -10,10 +10,10 @@ import ( "strings" "testing" - "github.com/ethersphere/bee/pkg/file/splitter/internal" - test "github.com/ethersphere/bee/pkg/file/testing" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/splitter/internal" + test "github.com/ethersphere/bee/v2/pkg/file/testing" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/file/splitter/splitter.go b/pkg/file/splitter/splitter.go index 8e74713b130..62015e5e666 100644 --- a/pkg/file/splitter/splitter.go +++ b/pkg/file/splitter/splitter.go @@ -11,10 +11,10 @@ import ( "fmt" "io" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/file/splitter/internal" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/file/splitter/internal" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // simpleSplitter wraps a non-optimized implementation of file.Splitter diff --git a/pkg/file/splitter/splitter_test.go b/pkg/file/splitter/splitter_test.go index 45bf804f542..c37d6d1f496 100644 --- a/pkg/file/splitter/splitter_test.go +++ b/pkg/file/splitter/splitter_test.go @@ -11,11 +11,11 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/file/splitter" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/file/splitter" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" mockbytes "gitlab.com/nolash/go-mockbytes" ) diff --git a/pkg/file/testing/chunk.go b/pkg/file/testing/chunk.go index f178dd99063..2f19164b0db 100644 --- a/pkg/file/testing/chunk.go +++ b/pkg/file/testing/chunk.go @@ -8,7 +8,7 @@ import ( "crypto/rand" "encoding/binary" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // GenerateTestRandomFileChunk generates one single chunk with arbitrary content and address diff --git a/pkg/file/testing/vector.go b/pkg/file/testing/vector.go index 076e064fafc..028f7eff2ce 100644 --- a/pkg/file/testing/vector.go +++ b/pkg/file/testing/vector.go @@ -7,7 +7,7 @@ package testing import ( "testing" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" mockbytes "gitlab.com/nolash/go-mockbytes" ) diff --git a/pkg/file/utils.go b/pkg/file/utils.go index 35f21414b82..ce1f94d372a 100644 --- a/pkg/file/utils.go +++ b/pkg/file/utils.go @@ -8,8 +8,8 @@ import ( "bytes" "errors" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/hive/hive.go b/pkg/hive/hive.go index 7d129446754..a84c841f89e 100644 --- a/pkg/hive/hive.go +++ b/pkg/hive/hive.go @@ -20,14 +20,14 @@ import ( "golang.org/x/sync/semaphore" - "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/hive/pb" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/ratelimit" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/hive/pb" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/ratelimit" + "github.com/ethersphere/bee/v2/pkg/swarm" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" ) diff --git a/pkg/hive/hive_test.go b/pkg/hive/hive_test.go index b3b0d55305d..324bac45895 100644 --- a/pkg/hive/hive_test.go +++ b/pkg/hive/hive_test.go @@ -16,18 +16,18 @@ import ( "github.com/ethereum/go-ethereum/common" ma "github.com/multiformats/go-multiaddr" - ab "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/hive" - "github.com/ethersphere/bee/pkg/hive/pb" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + ab "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/hive" + "github.com/ethersphere/bee/v2/pkg/hive/pb" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) var ( diff --git a/pkg/hive/metrics.go b/pkg/hive/metrics.go index c9a256f87b0..a09bcc09ffd 100644 --- a/pkg/hive/metrics.go +++ b/pkg/hive/metrics.go @@ -5,7 +5,7 @@ package hive import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/jsonhttp/handlers_test.go b/pkg/jsonhttp/handlers_test.go index 424d6ebfb29..7ede319580c 100644 --- a/pkg/jsonhttp/handlers_test.go +++ b/pkg/jsonhttp/handlers_test.go @@ -13,7 +13,7 @@ import ( "strings" "testing" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" ) func TestMethodHandler(t *testing.T) { diff --git a/pkg/jsonhttp/jsonhttp_test.go b/pkg/jsonhttp/jsonhttp_test.go index 6b107ffe8ee..cd6a378d5c5 100644 --- a/pkg/jsonhttp/jsonhttp_test.go +++ b/pkg/jsonhttp/jsonhttp_test.go @@ -13,7 +13,7 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" ) func TestRespond_defaults(t *testing.T) { diff --git a/pkg/jsonhttp/jsonhttptest/jsonhttptest.go b/pkg/jsonhttp/jsonhttptest/jsonhttptest.go index 7f5cabf35d2..1c436ec9373 100644 --- a/pkg/jsonhttp/jsonhttptest/jsonhttptest.go +++ b/pkg/jsonhttp/jsonhttptest/jsonhttptest.go @@ -18,7 +18,7 @@ import ( "strconv" "testing" - "github.com/ethersphere/bee/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" ) // Request is a testing helper function that makes an HTTP request using diff --git a/pkg/jsonhttp/jsonhttptest/jsonhttptest_test.go b/pkg/jsonhttp/jsonhttptest/jsonhttptest_test.go index 9f3a77a3f39..63b48556f37 100644 --- a/pkg/jsonhttp/jsonhttptest/jsonhttptest_test.go +++ b/pkg/jsonhttp/jsonhttptest/jsonhttptest_test.go @@ -19,8 +19,8 @@ import ( "strings" "testing" - "github.com/ethersphere/bee/pkg/jsonhttp" - "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" + "github.com/ethersphere/bee/v2/pkg/jsonhttp" + "github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest" ) func TestRequest_statusCode(t *testing.T) { diff --git a/pkg/keystore/file/key.go b/pkg/keystore/file/key.go index fbec230f942..68e6a2e2edf 100644 --- a/pkg/keystore/file/key.go +++ b/pkg/keystore/file/key.go @@ -17,8 +17,8 @@ import ( "io" "github.com/btcsuite/btcd/btcec/v2" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/keystore" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/keystore" "github.com/google/uuid" "golang.org/x/crypto/scrypt" "golang.org/x/crypto/sha3" diff --git a/pkg/keystore/file/service.go b/pkg/keystore/file/service.go index 199de659406..01a5db72aeb 100644 --- a/pkg/keystore/file/service.go +++ b/pkg/keystore/file/service.go @@ -10,7 +10,7 @@ import ( "os" "path/filepath" - "github.com/ethersphere/bee/pkg/keystore" + "github.com/ethersphere/bee/v2/pkg/keystore" ) // Service is the file-based keystore.Service implementation. diff --git a/pkg/keystore/file/service_test.go b/pkg/keystore/file/service_test.go index 70205afbaa9..4c115c7f79e 100644 --- a/pkg/keystore/file/service_test.go +++ b/pkg/keystore/file/service_test.go @@ -7,8 +7,8 @@ package file_test import ( "testing" - "github.com/ethersphere/bee/pkg/keystore/file" - "github.com/ethersphere/bee/pkg/keystore/test" + "github.com/ethersphere/bee/v2/pkg/keystore/file" + "github.com/ethersphere/bee/v2/pkg/keystore/test" ) func TestService(t *testing.T) { diff --git a/pkg/keystore/mem/service.go b/pkg/keystore/mem/service.go index 5d8d5ab0a7f..46868957d1e 100644 --- a/pkg/keystore/mem/service.go +++ b/pkg/keystore/mem/service.go @@ -9,7 +9,7 @@ import ( "fmt" "sync" - "github.com/ethersphere/bee/pkg/keystore" + "github.com/ethersphere/bee/v2/pkg/keystore" ) var _ keystore.Service = (*Service)(nil) diff --git a/pkg/keystore/mem/service_test.go b/pkg/keystore/mem/service_test.go index fcf5ec88381..ae3d4640cc0 100644 --- a/pkg/keystore/mem/service_test.go +++ b/pkg/keystore/mem/service_test.go @@ -7,8 +7,8 @@ package mem_test import ( "testing" - "github.com/ethersphere/bee/pkg/keystore/mem" - "github.com/ethersphere/bee/pkg/keystore/test" + "github.com/ethersphere/bee/v2/pkg/keystore/mem" + "github.com/ethersphere/bee/v2/pkg/keystore/test" ) func TestService(t *testing.T) { diff --git a/pkg/keystore/test/test.go b/pkg/keystore/test/test.go index c9cf9a4245d..5eb4a4c1b26 100644 --- a/pkg/keystore/test/test.go +++ b/pkg/keystore/test/test.go @@ -9,8 +9,8 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/keystore" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/keystore" ) // Service is a utility testing function that can be used to test diff --git a/pkg/log/example_test.go b/pkg/log/example_test.go index 8cbc3e8b920..bae4790b966 100644 --- a/pkg/log/example_test.go +++ b/pkg/log/example_test.go @@ -9,7 +9,7 @@ import ( "fmt" "os" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/log" ) func Example() { diff --git a/pkg/log/formatter_test.go b/pkg/log/formatter_test.go index 4ba6d920242..1db5697ce98 100644 --- a/pkg/log/formatter_test.go +++ b/pkg/log/formatter_test.go @@ -383,7 +383,7 @@ func TestPretty(t *testing.T) { exp: `{"Inner":"I am a log.Marshaler"}`, }, { val: (*marshalerTest)(nil), - exp: `""`, + exp: `""`, }, { val: marshalerPanicTest{"foobar"}, exp: `""`, @@ -395,7 +395,7 @@ func TestPretty(t *testing.T) { exp: `"I am a fmt.Stringer"`, }, { val: (*stringerTest)(nil), - exp: `""`, + exp: `""`, }, { val: stringerPanicTest{"foobar"}, exp: `""`, @@ -407,7 +407,7 @@ func TestPretty(t *testing.T) { exp: `"I am an error"`, }, { val: (*errorTest)(nil), - exp: `""`, + exp: `""`, }, { val: errorPanicTest{"foobar"}, exp: `""`, diff --git a/pkg/log/httpaccess/http_access.go b/pkg/log/httpaccess/http_access.go index 4b240534716..ab57f9d3b14 100644 --- a/pkg/log/httpaccess/http_access.go +++ b/pkg/log/httpaccess/http_access.go @@ -10,8 +10,8 @@ import ( "net/http" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/tracing" ) // NewHTTPAccessSuppressLogHandler creates a diff --git a/pkg/log/logger.go b/pkg/log/logger.go index 98b554bc2a4..f40ffd59916 100644 --- a/pkg/log/logger.go +++ b/pkg/log/logger.go @@ -13,7 +13,7 @@ import ( "strings" "time" - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/hashicorp/go-multierror" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/log/logger_test.go b/pkg/log/logger_test.go index 6a92f92ef00..f7c23308808 100644 --- a/pkg/log/logger_test.go +++ b/pkg/log/logger_test.go @@ -381,7 +381,7 @@ func TestLoggerWithCaller(t *testing.T) { } }) t.Run("caller=CategoryAll, logCallerFunc=true", func(t *testing.T) { - const thisFunc = "github.com/ethersphere/bee/pkg/log.TestLoggerWithCaller.func3" + const thisFunc = "github.com/ethersphere/bee/v2/pkg/log.TestLoggerWithCaller.func3" logger, bb := newLogger(WithCaller(CategoryAll), WithCallerFunc()) diff --git a/pkg/log/metrics.go b/pkg/log/metrics.go index 85a12fa1bf6..2691868921a 100644 --- a/pkg/log/metrics.go +++ b/pkg/log/metrics.go @@ -5,7 +5,7 @@ package log import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/manifest/manifest.go b/pkg/manifest/manifest.go index 6ebee2eacdb..70d8c76db51 100644 --- a/pkg/manifest/manifest.go +++ b/pkg/manifest/manifest.go @@ -10,8 +10,8 @@ import ( "context" "errors" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const DefaultManifestType = ManifestMantarayContentType diff --git a/pkg/manifest/mantaray.go b/pkg/manifest/mantaray.go index 908d7b4ad6d..f3b86e06b66 100644 --- a/pkg/manifest/mantaray.go +++ b/pkg/manifest/mantaray.go @@ -9,9 +9,9 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/manifest/mantaray" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/manifest/mantaray" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ( diff --git a/pkg/manifest/mantaray/node_test.go b/pkg/manifest/mantaray/node_test.go index a0647d085d0..aa2e2f5c355 100644 --- a/pkg/manifest/mantaray/node_test.go +++ b/pkg/manifest/mantaray/node_test.go @@ -11,7 +11,7 @@ import ( "strconv" "testing" - "github.com/ethersphere/bee/pkg/manifest/mantaray" + "github.com/ethersphere/bee/v2/pkg/manifest/mantaray" ) func TestNilPath(t *testing.T) { diff --git a/pkg/manifest/mantaray/persist_test.go b/pkg/manifest/mantaray/persist_test.go index e6feaee79aa..b6a6c47e699 100644 --- a/pkg/manifest/mantaray/persist_test.go +++ b/pkg/manifest/mantaray/persist_test.go @@ -11,7 +11,7 @@ import ( "sync" "testing" - "github.com/ethersphere/bee/pkg/manifest/mantaray" + "github.com/ethersphere/bee/v2/pkg/manifest/mantaray" ) func TestPersistIdempotence(t *testing.T) { diff --git a/pkg/manifest/mantaray/walker_test.go b/pkg/manifest/mantaray/walker_test.go index ad6553eef6c..67ab9c7d18c 100644 --- a/pkg/manifest/mantaray/walker_test.go +++ b/pkg/manifest/mantaray/walker_test.go @@ -10,7 +10,7 @@ import ( "fmt" "testing" - "github.com/ethersphere/bee/pkg/manifest/mantaray" + "github.com/ethersphere/bee/v2/pkg/manifest/mantaray" ) func TestWalkNode(t *testing.T) { diff --git a/pkg/manifest/simple.go b/pkg/manifest/simple.go index d6ae3828212..5bc9927bc1d 100644 --- a/pkg/manifest/simple.go +++ b/pkg/manifest/simple.go @@ -9,9 +9,9 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/manifest/simple" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/manifest/simple" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ( diff --git a/pkg/manifest/simple/manifest_test.go b/pkg/manifest/simple/manifest_test.go index a8693b5ca8a..aa1345acd3d 100644 --- a/pkg/manifest/simple/manifest_test.go +++ b/pkg/manifest/simple/manifest_test.go @@ -9,8 +9,8 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/manifest/simple" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/manifest/simple" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestNilPath(t *testing.T) { diff --git a/pkg/manifest/simple/walker_test.go b/pkg/manifest/simple/walker_test.go index d6f2bac8170..c3877ce664e 100644 --- a/pkg/manifest/simple/walker_test.go +++ b/pkg/manifest/simple/walker_test.go @@ -8,7 +8,7 @@ import ( "fmt" "testing" - "github.com/ethersphere/bee/pkg/manifest/simple" + "github.com/ethersphere/bee/v2/pkg/manifest/simple" ) func TestWalkEntry(t *testing.T) { diff --git a/pkg/metrics/metrics_test.go b/pkg/metrics/metrics_test.go index 42522cd40db..65029836e69 100644 --- a/pkg/metrics/metrics_test.go +++ b/pkg/metrics/metrics_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/ethersphere/bee/pkg/metrics" + "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/node/bootstrap.go b/pkg/node/bootstrap.go index a1e48228da7..a0aa07bcd72 100644 --- a/pkg/node/bootstrap.go +++ b/pkg/node/bootstrap.go @@ -16,33 +16,33 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds" - "github.com/ethersphere/bee/pkg/feeds/factory" - "github.com/ethersphere/bee/pkg/file" - "github.com/ethersphere/bee/pkg/file/joiner" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/hive" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/manifest" - "github.com/ethersphere/bee/pkg/p2p/libp2p" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/pricer" - "github.com/ethersphere/bee/pkg/pricing" - "github.com/ethersphere/bee/pkg/retrieval" - "github.com/ethersphere/bee/pkg/settlement/pseudosettle" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/topology/kademlia" - "github.com/ethersphere/bee/pkg/topology/lightnode" - "github.com/ethersphere/bee/pkg/tracing" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds" + "github.com/ethersphere/bee/v2/pkg/feeds/factory" + "github.com/ethersphere/bee/v2/pkg/file" + "github.com/ethersphere/bee/v2/pkg/file/joiner" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/hive" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/manifest" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/pricer" + "github.com/ethersphere/bee/v2/pkg/pricing" + "github.com/ethersphere/bee/v2/pkg/retrieval" + "github.com/ethersphere/bee/v2/pkg/settlement/pseudosettle" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/topology/kademlia" + "github.com/ethersphere/bee/v2/pkg/topology/lightnode" + "github.com/ethersphere/bee/v2/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/transaction" "github.com/hashicorp/go-multierror" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/node/chain.go b/pkg/node/chain.go index c4cab943207..463c3d5c649 100644 --- a/pkg/node/chain.go +++ b/pkg/node/chain.go @@ -18,21 +18,21 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" - "github.com/ethersphere/bee/pkg/config" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p/libp2p" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/settlement" - "github.com/ethersphere/bee/pkg/settlement/swap" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" - "github.com/ethersphere/bee/pkg/settlement/swap/priceoracle" - "github.com/ethersphere/bee/pkg/settlement/swap/swapprotocol" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/transaction/wrapped" + "github.com/ethersphere/bee/v2/pkg/config" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/settlement" + "github.com/ethersphere/bee/v2/pkg/settlement/swap" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/priceoracle" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/swapprotocol" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction/wrapped" "github.com/ethersphere/go-sw3-abi/sw3abi" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/node/devnode.go b/pkg/node/devnode.go index 76b055b531f..b45715bd152 100644 --- a/pkg/node/devnode.go +++ b/pkg/node/devnode.go @@ -17,44 +17,44 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - mockAccounting "github.com/ethersphere/bee/pkg/accounting/mock" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/auth" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds/factory" - "github.com/ethersphere/bee/pkg/log" - mockP2P "github.com/ethersphere/bee/pkg/p2p/mock" - mockPingPong "github.com/ethersphere/bee/pkg/pingpong/mock" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/batchstore" - mockPost "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - mockPostContract "github.com/ethersphere/bee/pkg/postage/postagecontract/mock" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/pss" - "github.com/ethersphere/bee/pkg/pushsync" - mockPushsync "github.com/ethersphere/bee/pkg/pushsync/mock" - resolverMock "github.com/ethersphere/bee/pkg/resolver/mock" - "github.com/ethersphere/bee/pkg/settlement/pseudosettle" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - mockchequebook "github.com/ethersphere/bee/pkg/settlement/swap/chequebook/mock" - erc20mock "github.com/ethersphere/bee/pkg/settlement/swap/erc20/mock" - swapmock "github.com/ethersphere/bee/pkg/settlement/swap/mock" - "github.com/ethersphere/bee/pkg/statestore/leveldb" - mockSteward "github.com/ethersphere/bee/pkg/steward/mock" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storageincentives/staking" - stakingContractMock "github.com/ethersphere/bee/pkg/storageincentives/staking/mock" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology/lightnode" - mockTopology "github.com/ethersphere/bee/pkg/topology/mock" - "github.com/ethersphere/bee/pkg/tracing" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/transaction/backendmock" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/ioutil" + mockAccounting "github.com/ethersphere/bee/v2/pkg/accounting/mock" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/auth" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds/factory" + "github.com/ethersphere/bee/v2/pkg/log" + mockP2P "github.com/ethersphere/bee/v2/pkg/p2p/mock" + mockPingPong "github.com/ethersphere/bee/v2/pkg/pingpong/mock" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/batchstore" + mockPost "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + mockPostContract "github.com/ethersphere/bee/v2/pkg/postage/postagecontract/mock" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/pushsync" + mockPushsync "github.com/ethersphere/bee/v2/pkg/pushsync/mock" + resolverMock "github.com/ethersphere/bee/v2/pkg/resolver/mock" + "github.com/ethersphere/bee/v2/pkg/settlement/pseudosettle" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + mockchequebook "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook/mock" + erc20mock "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20/mock" + swapmock "github.com/ethersphere/bee/v2/pkg/settlement/swap/mock" + "github.com/ethersphere/bee/v2/pkg/statestore/leveldb" + mockSteward "github.com/ethersphere/bee/v2/pkg/steward/mock" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking" + stakingContractMock "github.com/ethersphere/bee/v2/pkg/storageincentives/staking/mock" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology/lightnode" + mockTopology "github.com/ethersphere/bee/v2/pkg/topology/mock" + "github.com/ethersphere/bee/v2/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction/backendmock" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/ioutil" "github.com/hashicorp/go-multierror" "github.com/multiformats/go-multiaddr" "golang.org/x/sync/errgroup" @@ -202,7 +202,7 @@ func NewDevBee(logger log.Logger, o *DevOptions) (b *DevBee, err error) { return nil, fmt.Errorf("debug api listener: %w", err) } - debugApiService = api.New(mockKey.PublicKey, mockKey.PublicKey, overlayEthAddress, logger, mockTransaction, batchStore, api.DevMode, true, true, chainBackend, o.CORSAllowedOrigins, inmemstore.New()) + debugApiService = api.New(mockKey.PublicKey, mockKey.PublicKey, overlayEthAddress, nil, logger, mockTransaction, batchStore, api.DevMode, true, true, chainBackend, o.CORSAllowedOrigins, inmemstore.New()) debugAPIServer := &http.Server{ IdleTimeout: 30 * time.Second, ReadHeaderTimeout: 3 * time.Second, @@ -398,7 +398,7 @@ func NewDevBee(logger log.Logger, o *DevOptions) (b *DevBee, err error) { }), ) - apiService := api.New(mockKey.PublicKey, mockKey.PublicKey, overlayEthAddress, logger, mockTransaction, batchStore, api.DevMode, true, true, chainBackend, o.CORSAllowedOrigins, inmemstore.New()) + apiService := api.New(mockKey.PublicKey, mockKey.PublicKey, overlayEthAddress, nil, logger, mockTransaction, batchStore, api.DevMode, true, true, chainBackend, o.CORSAllowedOrigins, inmemstore.New()) apiService.Configure(signer, authenticator, tracer, api.Options{ CORSAllowedOrigins: o.CORSAllowedOrigins, diff --git a/pkg/node/node.go b/pkg/node/node.go index 214cad27d4f..2996b8d77d5 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -24,55 +24,55 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/auth" - "github.com/ethersphere/bee/pkg/config" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/feeds/factory" - "github.com/ethersphere/bee/pkg/hive" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/metrics" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p" - "github.com/ethersphere/bee/pkg/pingpong" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/batchservice" - "github.com/ethersphere/bee/pkg/postage/batchstore" - "github.com/ethersphere/bee/pkg/postage/listener" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - "github.com/ethersphere/bee/pkg/pricer" - "github.com/ethersphere/bee/pkg/pricing" - "github.com/ethersphere/bee/pkg/pss" - "github.com/ethersphere/bee/pkg/puller" - "github.com/ethersphere/bee/pkg/pullsync" - "github.com/ethersphere/bee/pkg/pusher" - "github.com/ethersphere/bee/pkg/pushsync" - "github.com/ethersphere/bee/pkg/resolver/multiresolver" - "github.com/ethersphere/bee/pkg/retrieval" - "github.com/ethersphere/bee/pkg/salud" - "github.com/ethersphere/bee/pkg/settlement/pseudosettle" - "github.com/ethersphere/bee/pkg/settlement/swap" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" - "github.com/ethersphere/bee/pkg/settlement/swap/priceoracle" - "github.com/ethersphere/bee/pkg/status" - "github.com/ethersphere/bee/pkg/steward" - "github.com/ethersphere/bee/pkg/storageincentives" - "github.com/ethersphere/bee/pkg/storageincentives/redistribution" - "github.com/ethersphere/bee/pkg/storageincentives/staking" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/topology/kademlia" - "github.com/ethersphere/bee/pkg/topology/lightnode" - "github.com/ethersphere/bee/pkg/tracing" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/util/abiutil" - "github.com/ethersphere/bee/pkg/util/ioutil" - "github.com/ethersphere/bee/pkg/util/nbhdutil" - "github.com/ethersphere/bee/pkg/util/syncutil" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/auth" + "github.com/ethersphere/bee/v2/pkg/config" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/feeds/factory" + "github.com/ethersphere/bee/v2/pkg/hive" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/metrics" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/pingpong" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/batchservice" + "github.com/ethersphere/bee/v2/pkg/postage/batchstore" + "github.com/ethersphere/bee/v2/pkg/postage/listener" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + "github.com/ethersphere/bee/v2/pkg/pricer" + "github.com/ethersphere/bee/v2/pkg/pricing" + "github.com/ethersphere/bee/v2/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/puller" + "github.com/ethersphere/bee/v2/pkg/pullsync" + "github.com/ethersphere/bee/v2/pkg/pusher" + "github.com/ethersphere/bee/v2/pkg/pushsync" + "github.com/ethersphere/bee/v2/pkg/resolver/multiresolver" + "github.com/ethersphere/bee/v2/pkg/retrieval" + "github.com/ethersphere/bee/v2/pkg/salud" + "github.com/ethersphere/bee/v2/pkg/settlement/pseudosettle" + "github.com/ethersphere/bee/v2/pkg/settlement/swap" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/priceoracle" + "github.com/ethersphere/bee/v2/pkg/status" + "github.com/ethersphere/bee/v2/pkg/steward" + "github.com/ethersphere/bee/v2/pkg/storageincentives" + "github.com/ethersphere/bee/v2/pkg/storageincentives/redistribution" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/topology/kademlia" + "github.com/ethersphere/bee/v2/pkg/topology/lightnode" + "github.com/ethersphere/bee/v2/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/util/ioutil" + "github.com/ethersphere/bee/v2/pkg/util/nbhdutil" + "github.com/ethersphere/bee/v2/pkg/util/syncutil" "github.com/hashicorp/go-multierror" ma "github.com/multiformats/go-multiaddr" promc "github.com/prometheus/client_golang/prometheus" @@ -171,6 +171,8 @@ type Options struct { EnableStorageIncentives bool StatestoreCacheCapacity uint64 TargetNeighborhood string + NeighborhoodSuggester string + WhitelistedWithdrawalAddress []string } const ( @@ -252,7 +254,7 @@ func NewBee( } b.stateStoreCloser = stateStore - // Check if the the batchstore exists. If not, we can assume it's missing + // Check if the batchstore exists. If not, we can assume it's missing // due to a migration or it's a fresh install. batchStoreExists, err := batchStoreExists(stateStore) if err != nil { @@ -282,9 +284,18 @@ func NewBee( if !nonceExists { // mine the overlay - if o.TargetNeighborhood != "" { - logger.Info("mining an overlay address for the fresh node to target the selected neighborhood", "target", o.TargetNeighborhood) - swarmAddress, nonce, err = nbhdutil.MineOverlay(ctx, *pubKey, networkID, o.TargetNeighborhood) + targetNeighborhood := o.TargetNeighborhood + if o.TargetNeighborhood == "" && o.NeighborhoodSuggester != "" { + logger.Info("fetching target neighborhood from suggester", "url", o.NeighborhoodSuggester) + targetNeighborhood, err = nbhdutil.FetchNeighborhood(&http.Client{}, o.NeighborhoodSuggester) + if err != nil { + return nil, fmt.Errorf("neighborhood suggestion: %w", err) + } + } + + if targetNeighborhood != "" { + logger.Info("mining an overlay address for the fresh node to target the selected neighborhood", "target", targetNeighborhood) + swarmAddress, nonce, err = nbhdutil.MineOverlay(ctx, *pubKey, networkID, targetNeighborhood) if err != nil { return nil, fmt.Errorf("mine overlay address: %w", err) } @@ -411,6 +422,7 @@ func NewBee( *publicKey, pssPrivateKey.PublicKey, overlayEthAddress, + o.WhitelistedWithdrawalAddress, logger, transactionService, batchStore, @@ -450,6 +462,7 @@ func NewBee( *publicKey, pssPrivateKey.PublicKey, overlayEthAddress, + o.WhitelistedWithdrawalAddress, logger, transactionService, batchStore, @@ -1079,11 +1092,12 @@ func NewBee( Steward: steward, SyncStatus: syncStatusFn, NodeStatus: nodeStatus, + PinIntegrity: localStore.PinIntegrity(), } if o.APIAddr != "" { if apiService == nil { - apiService = api.New(*publicKey, pssPrivateKey.PublicKey, overlayEthAddress, logger, transactionService, batchStore, beeNodeMode, o.ChequebookEnable, o.SwapEnable, chainBackend, o.CORSAllowedOrigins, stamperStore) + apiService = api.New(*publicKey, pssPrivateKey.PublicKey, overlayEthAddress, o.WhitelistedWithdrawalAddress, logger, transactionService, batchStore, beeNodeMode, o.ChequebookEnable, o.SwapEnable, chainBackend, o.CORSAllowedOrigins, stamperStore) apiService.SetProbe(probe) apiService.SetRedistributionAgent(agent) } diff --git a/pkg/node/statestore.go b/pkg/node/statestore.go index 9579e1487ef..958ce5f01e1 100644 --- a/pkg/node/statestore.go +++ b/pkg/node/statestore.go @@ -9,13 +9,13 @@ import ( "fmt" "path/filepath" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/metrics" - "github.com/ethersphere/bee/pkg/statestore/storeadapter" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/cache" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/metrics" + "github.com/ethersphere/bee/v2/pkg/statestore/storeadapter" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/cache" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // InitStateStore will initialize the stateStore with the given path to the diff --git a/pkg/p2p/libp2p/connections_test.go b/pkg/p2p/libp2p/connections_test.go index 6f560e3ed7d..ae81ad481d0 100644 --- a/pkg/p2p/libp2p/connections_test.go +++ b/pkg/p2p/libp2p/connections_test.go @@ -16,15 +16,15 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology/lightnode" + "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/handshake" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology/lightnode" "github.com/libp2p/go-libp2p/p2p/host/eventbus" libp2pm "github.com/libp2p/go-libp2p" diff --git a/pkg/p2p/libp2p/export_test.go b/pkg/p2p/libp2p/export_test.go index 468d5bdbef8..f78b9f21275 100644 --- a/pkg/p2p/libp2p/export_test.go +++ b/pkg/p2p/libp2p/export_test.go @@ -7,7 +7,7 @@ package libp2p import ( "context" - handshake "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake" + handshake "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/handshake" libp2pm "github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/network" diff --git a/pkg/p2p/libp2p/headers.go b/pkg/p2p/libp2p/headers.go index 10d81d094e0..af658073d82 100644 --- a/pkg/p2p/libp2p/headers.go +++ b/pkg/p2p/libp2p/headers.go @@ -8,10 +8,10 @@ import ( "context" "fmt" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/headers/pb" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/headers/pb" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func sendHeaders(ctx context.Context, headers p2p.Headers, stream *stream) error { diff --git a/pkg/p2p/libp2p/headers_test.go b/pkg/p2p/libp2p/headers_test.go index 62b9b62925e..5805dafa0d4 100644 --- a/pkg/p2p/libp2p/headers_test.go +++ b/pkg/p2p/libp2p/headers_test.go @@ -10,9 +10,9 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestHeaders(t *testing.T) { diff --git a/pkg/p2p/libp2p/internal/blocklist/blocklist.go b/pkg/p2p/libp2p/internal/blocklist/blocklist.go index 683d43bbeae..d5ecee4d24d 100644 --- a/pkg/p2p/libp2p/internal/blocklist/blocklist.go +++ b/pkg/p2p/libp2p/internal/blocklist/blocklist.go @@ -9,9 +9,9 @@ import ( "strings" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var keyPrefix = "blocklist-" diff --git a/pkg/p2p/libp2p/internal/blocklist/blocklist_test.go b/pkg/p2p/libp2p/internal/blocklist/blocklist_test.go index d0bc3e4108f..dd932fc6acf 100644 --- a/pkg/p2p/libp2p/internal/blocklist/blocklist_test.go +++ b/pkg/p2p/libp2p/internal/blocklist/blocklist_test.go @@ -8,10 +8,10 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/blocklist" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/blocklist" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestExist(t *testing.T) { diff --git a/pkg/p2p/libp2p/internal/blocklist/export_test.go b/pkg/p2p/libp2p/internal/blocklist/export_test.go index bf70482c379..76c7599ffa4 100644 --- a/pkg/p2p/libp2p/internal/blocklist/export_test.go +++ b/pkg/p2p/libp2p/internal/blocklist/export_test.go @@ -5,7 +5,7 @@ package blocklist import ( - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" ) func NewBlocklistWithCurrentTimeFn(store storage.StateStorer, currentTimeFn currentTimeFn) *Blocklist { diff --git a/pkg/p2p/libp2p/internal/breaker/breaker_test.go b/pkg/p2p/libp2p/internal/breaker/breaker_test.go index df02ab647de..2693037abbf 100644 --- a/pkg/p2p/libp2p/internal/breaker/breaker_test.go +++ b/pkg/p2p/libp2p/internal/breaker/breaker_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/breaker" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/breaker" ) func TestExecute(t *testing.T) { diff --git a/pkg/p2p/libp2p/internal/handshake/handshake.go b/pkg/p2p/libp2p/internal/handshake/handshake.go index 102fd00b68a..fb605073253 100644 --- a/pkg/p2p/libp2p/internal/handshake/handshake.go +++ b/pkg/p2p/libp2p/internal/handshake/handshake.go @@ -11,13 +11,13 @@ import ( "sync/atomic" "time" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake/pb" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/handshake/pb" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/swarm" libp2ppeer "github.com/libp2p/go-libp2p/core/peer" ma "github.com/multiformats/go-multiaddr" @@ -326,7 +326,7 @@ func (s *Service) SetWelcomeMessage(msg string) (err error) { return nil } -// GetWelcomeMessage returns the the current handshake welcome message. +// GetWelcomeMessage returns the current handshake welcome message. func (s *Service) GetWelcomeMessage() string { return s.welcomeMessage.Load().(string) } diff --git a/pkg/p2p/libp2p/internal/handshake/handshake_test.go b/pkg/p2p/libp2p/internal/handshake/handshake_test.go index 5dc37116028..e0afcc56d70 100644 --- a/pkg/p2p/libp2p/internal/handshake/handshake_test.go +++ b/pkg/p2p/libp2p/internal/handshake/handshake_test.go @@ -12,14 +12,14 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake/mock" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake/pb" - "github.com/ethersphere/bee/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/handshake" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/handshake/mock" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/handshake/pb" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" libp2ppeer "github.com/libp2p/go-libp2p/core/peer" ma "github.com/multiformats/go-multiaddr" diff --git a/pkg/p2p/libp2p/internal/handshake/metrics.go b/pkg/p2p/libp2p/internal/handshake/metrics.go index e0313dd17cd..c8177d3f93e 100644 --- a/pkg/p2p/libp2p/internal/handshake/metrics.go +++ b/pkg/p2p/libp2p/internal/handshake/metrics.go @@ -5,7 +5,7 @@ package handshake import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/p2p/libp2p/internal/handshake/mock/stream.go b/pkg/p2p/libp2p/internal/handshake/mock/stream.go index 69ffcb7ce59..bebe17fe30a 100644 --- a/pkg/p2p/libp2p/internal/handshake/mock/stream.go +++ b/pkg/p2p/libp2p/internal/handshake/mock/stream.go @@ -7,7 +7,7 @@ package mock import ( "bytes" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p" ) type Stream struct { diff --git a/pkg/p2p/libp2p/internal/reacher/metrics.go b/pkg/p2p/libp2p/internal/reacher/metrics.go index ab745943b2c..d3d90837a6f 100644 --- a/pkg/p2p/libp2p/internal/reacher/metrics.go +++ b/pkg/p2p/libp2p/internal/reacher/metrics.go @@ -5,7 +5,7 @@ package reacher import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/p2p/libp2p/internal/reacher/reacher.go b/pkg/p2p/libp2p/internal/reacher/reacher.go index da87d6049b1..ad888df4d0f 100644 --- a/pkg/p2p/libp2p/internal/reacher/reacher.go +++ b/pkg/p2p/libp2p/internal/reacher/reacher.go @@ -11,8 +11,8 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/p2p/libp2p/internal/reacher/reacher_test.go b/pkg/p2p/libp2p/internal/reacher/reacher_test.go index a842103115a..d60bb2cc9cc 100644 --- a/pkg/p2p/libp2p/internal/reacher/reacher_test.go +++ b/pkg/p2p/libp2p/internal/reacher/reacher_test.go @@ -10,10 +10,10 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/reacher" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/reacher" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ma "github.com/multiformats/go-multiaddr" "go.uber.org/atomic" ) diff --git a/pkg/p2p/libp2p/libp2p.go b/pkg/p2p/libp2p/libp2p.go index d7250a517fb..4671f4cde36 100644 --- a/pkg/p2p/libp2p/libp2p.go +++ b/pkg/p2p/libp2p/libp2p.go @@ -17,21 +17,21 @@ import ( "sync" "time" - "github.com/ethersphere/bee" - "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/bzz" - beecrypto "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/blocklist" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/breaker" - handshake "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/reacher" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/topology/lightnode" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2" + "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/bzz" + beecrypto "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/blocklist" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/breaker" + handshake "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/handshake" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/reacher" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/topology/lightnode" + "github.com/ethersphere/bee/v2/pkg/tracing" libp2p "github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/event" @@ -54,7 +54,7 @@ import ( "go.uber.org/atomic" ocprom "contrib.go.opencensus.io/exporter/prometheus" - m2 "github.com/ethersphere/bee/pkg/metrics" + m2 "github.com/ethersphere/bee/v2/pkg/metrics" rcmgrObs "github.com/libp2p/go-libp2p/p2p/host/resource-manager" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/p2p/libp2p/libp2p_test.go b/pkg/p2p/libp2p/libp2p_test.go index 378d4dbc9d3..c467247547e 100644 --- a/pkg/p2p/libp2p/libp2p_test.go +++ b/pkg/p2p/libp2p/libp2p_test.go @@ -13,16 +13,16 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology/lightnode" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology/lightnode" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/p2p/libp2p/metrics.go b/pkg/p2p/libp2p/metrics.go index b7f6e79a665..003970856d2 100644 --- a/pkg/p2p/libp2p/metrics.go +++ b/pkg/p2p/libp2p/metrics.go @@ -5,7 +5,7 @@ package libp2p import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/p2p/libp2p/peer.go b/pkg/p2p/libp2p/peer.go index c8eeb1578c2..5aa0f75713a 100644 --- a/pkg/p2p/libp2p/peer.go +++ b/pkg/p2p/libp2p/peer.go @@ -10,8 +10,8 @@ import ( "sort" "sync" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/libp2p/go-libp2p/core/network" libp2ppeer "github.com/libp2p/go-libp2p/core/peer" ma "github.com/multiformats/go-multiaddr" diff --git a/pkg/p2p/libp2p/protocols_test.go b/pkg/p2p/libp2p/protocols_test.go index b4f2fab91f8..ef2acf0d82b 100644 --- a/pkg/p2p/libp2p/protocols_test.go +++ b/pkg/p2p/libp2p/protocols_test.go @@ -12,9 +12,9 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p" - "github.com/ethersphere/bee/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/spinlock" libp2pm "github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p/core/host" protocol "github.com/libp2p/go-libp2p/core/protocol" diff --git a/pkg/p2p/libp2p/static_resolver_test.go b/pkg/p2p/libp2p/static_resolver_test.go index 992d7500004..4aff2ca41c6 100644 --- a/pkg/p2p/libp2p/static_resolver_test.go +++ b/pkg/p2p/libp2p/static_resolver_test.go @@ -8,7 +8,7 @@ import ( "net" "testing" - "github.com/ethersphere/bee/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/p2p/libp2p/stream.go b/pkg/p2p/libp2p/stream.go index 8535da7e82e..93e7ce6181a 100644 --- a/pkg/p2p/libp2p/stream.go +++ b/pkg/p2p/libp2p/stream.go @@ -9,7 +9,7 @@ import ( "io" "time" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p" "github.com/libp2p/go-libp2p/core/network" ) diff --git a/pkg/p2p/libp2p/tracing_test.go b/pkg/p2p/libp2p/tracing_test.go index 5b54911ec3e..7e02f8e2d7c 100644 --- a/pkg/p2p/libp2p/tracing_test.go +++ b/pkg/p2p/libp2p/tracing_test.go @@ -10,9 +10,9 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/tracing" ) func TestTracing(t *testing.T) { diff --git a/pkg/p2p/libp2p/welcome_message_test.go b/pkg/p2p/libp2p/welcome_message_test.go index 839a8fb3f30..5e6ac7a2f2d 100644 --- a/pkg/p2p/libp2p/welcome_message_test.go +++ b/pkg/p2p/libp2p/welcome_message_test.go @@ -7,8 +7,8 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/p2p/libp2p" - "github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p" + "github.com/ethersphere/bee/v2/pkg/p2p/libp2p/internal/handshake" ) func TestDynamicWelcomeMessage(t *testing.T) { diff --git a/pkg/p2p/mock/mock.go b/pkg/p2p/mock/mock.go index 092824da555..eacefd6846b 100644 --- a/pkg/p2p/mock/mock.go +++ b/pkg/p2p/mock/mock.go @@ -9,9 +9,9 @@ import ( "errors" "time" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/p2p/p2p.go b/pkg/p2p/p2p.go index 4f7897be592..a85b3d9d04b 100644 --- a/pkg/p2p/p2p.go +++ b/pkg/p2p/p2p.go @@ -13,8 +13,8 @@ import ( "io" "time" - "github.com/ethersphere/bee/pkg/bzz" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bzz" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/libp2p/go-libp2p/core/network" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/p2p/p2p_test.go b/pkg/p2p/p2p_test.go index ce01cac2b0a..3c6ce22ca22 100644 --- a/pkg/p2p/p2p_test.go +++ b/pkg/p2p/p2p_test.go @@ -7,7 +7,7 @@ package p2p_test import ( "testing" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p" "github.com/libp2p/go-libp2p/core/network" ) diff --git a/pkg/p2p/protobuf/main_test.go b/pkg/p2p/protobuf/main_test.go index 82148f77600..68f9fc720bb 100644 --- a/pkg/p2p/protobuf/main_test.go +++ b/pkg/p2p/protobuf/main_test.go @@ -16,6 +16,6 @@ func TestMain(m *testing.M) { goleak.IgnoreTopFunction("time.Sleep"), goleak.IgnoreTopFunction("io.(*pipe).read"), goleak.IgnoreTopFunction("io.(*pipe).write"), - goleak.IgnoreTopFunction("github.com/ethersphere/bee/pkg/p2p/protobuf_test.newMessageWriter.func1"), + goleak.IgnoreTopFunction("github.com/ethersphere/bee/v2/pkg/p2p/protobuf_test.newMessageWriter.func1"), ) } diff --git a/pkg/p2p/protobuf/protobuf.go b/pkg/p2p/protobuf/protobuf.go index 7cd02832fc1..3153a6e0302 100644 --- a/pkg/p2p/protobuf/protobuf.go +++ b/pkg/p2p/protobuf/protobuf.go @@ -9,7 +9,7 @@ import ( "errors" "io" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p" ggio "github.com/gogo/protobuf/io" "github.com/gogo/protobuf/proto" ) diff --git a/pkg/p2p/protobuf/protobuf_test.go b/pkg/p2p/protobuf/protobuf_test.go index f161852ab10..5dd675b0687 100644 --- a/pkg/p2p/protobuf/protobuf_test.go +++ b/pkg/p2p/protobuf/protobuf_test.go @@ -12,9 +12,9 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/p2p/protobuf/internal/pb" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf/internal/pb" ) func TestReader_ReadMsg(t *testing.T) { diff --git a/pkg/p2p/specwrapper_test.go b/pkg/p2p/specwrapper_test.go index 36f5951849e..2275d2004e5 100644 --- a/pkg/p2p/specwrapper_test.go +++ b/pkg/p2p/specwrapper_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p" ) func newTestProtocol(h p2p.HandlerFunc) p2p.ProtocolSpec { diff --git a/pkg/p2p/streamtest/streamtest.go b/pkg/p2p/streamtest/streamtest.go index 4acab84db25..a9892687240 100644 --- a/pkg/p2p/streamtest/streamtest.go +++ b/pkg/p2p/streamtest/streamtest.go @@ -12,9 +12,9 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/swarm" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/p2p/streamtest/streamtest_test.go b/pkg/p2p/streamtest/streamtest_test.go index 924cdfcc0e9..0b26d2da7ce 100644 --- a/pkg/p2p/streamtest/streamtest_test.go +++ b/pkg/p2p/streamtest/streamtest_test.go @@ -14,9 +14,9 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + "github.com/ethersphere/bee/v2/pkg/swarm" ma "github.com/multiformats/go-multiaddr" ) diff --git a/pkg/pingpong/metrics.go b/pkg/pingpong/metrics.go index 9b177c0461d..155b3abdb8e 100644 --- a/pkg/pingpong/metrics.go +++ b/pkg/pingpong/metrics.go @@ -5,7 +5,7 @@ package pingpong import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/pingpong/mock/mock.go b/pkg/pingpong/mock/mock.go index 033e75a6943..66d5be1a521 100644 --- a/pkg/pingpong/mock/mock.go +++ b/pkg/pingpong/mock/mock.go @@ -8,7 +8,7 @@ import ( "context" "time" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type Service struct { diff --git a/pkg/pingpong/pingpong.go b/pkg/pingpong/pingpong.go index 252d84dc6eb..ba09d7eaab1 100644 --- a/pkg/pingpong/pingpong.go +++ b/pkg/pingpong/pingpong.go @@ -13,12 +13,12 @@ import ( "io" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/pingpong/pb" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/pingpong/pb" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/tracing" ) // loggerName is the tree path name of the logger for this package. diff --git a/pkg/pingpong/pingpong_test.go b/pkg/pingpong/pingpong_test.go index 662b6684ddd..6e0298b7cb9 100644 --- a/pkg/pingpong/pingpong_test.go +++ b/pkg/pingpong/pingpong_test.go @@ -12,14 +12,14 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - "github.com/ethersphere/bee/pkg/pingpong" - "github.com/ethersphere/bee/pkg/pingpong/pb" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + "github.com/ethersphere/bee/v2/pkg/pingpong" + "github.com/ethersphere/bee/v2/pkg/pingpong/pb" ) func TestPing(t *testing.T) { diff --git a/pkg/postage/batch_test.go b/pkg/postage/batch_test.go index e735639449e..e7b419d6e02 100644 --- a/pkg/postage/batch_test.go +++ b/pkg/postage/batch_test.go @@ -8,8 +8,8 @@ import ( "bytes" "testing" - "github.com/ethersphere/bee/pkg/postage" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/postage" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" ) // TestBatchMarshalling tests the idempotence of binary marshal/unmarshal for a diff --git a/pkg/postage/batchservice/batchservice.go b/pkg/postage/batchservice/batchservice.go index ad7b26a6e93..4ec2611aa26 100644 --- a/pkg/postage/batchservice/batchservice.go +++ b/pkg/postage/batchservice/batchservice.go @@ -14,9 +14,9 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/storage" "golang.org/x/crypto/sha3" ) diff --git a/pkg/postage/batchservice/batchservice_test.go b/pkg/postage/batchservice/batchservice_test.go index 9be023ff726..0fd2bfe4c14 100644 --- a/pkg/postage/batchservice/batchservice_test.go +++ b/pkg/postage/batchservice/batchservice_test.go @@ -13,14 +13,14 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/batchservice" - "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - mocks "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/batchservice" + "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + mocks "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) var ( diff --git a/pkg/postage/batchstore/metrics.go b/pkg/postage/batchstore/metrics.go index 30aca0fcd1f..518b18ae79b 100644 --- a/pkg/postage/batchstore/metrics.go +++ b/pkg/postage/batchstore/metrics.go @@ -5,7 +5,7 @@ package batchstore import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/postage/batchstore/mock/store.go b/pkg/postage/batchstore/mock/store.go index f3c10bf236d..f7d2d5aa847 100644 --- a/pkg/postage/batchstore/mock/store.go +++ b/pkg/postage/batchstore/mock/store.go @@ -10,9 +10,9 @@ import ( "math/big" "sync" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/batchstore" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/batchstore" + "github.com/ethersphere/bee/v2/pkg/storage" ) var _ postage.Storer = (*BatchStore)(nil) diff --git a/pkg/postage/batchstore/mock/store_test.go b/pkg/postage/batchstore/mock/store_test.go index 9ba544fafbd..824988f38f0 100644 --- a/pkg/postage/batchstore/mock/store_test.go +++ b/pkg/postage/batchstore/mock/store_test.go @@ -9,8 +9,8 @@ import ( "math/big" "testing" - "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" ) func TestBatchStore(t *testing.T) { diff --git a/pkg/postage/batchstore/store.go b/pkg/postage/batchstore/store.go index a3cac65d5be..abad6987ac6 100644 --- a/pkg/postage/batchstore/store.go +++ b/pkg/postage/batchstore/store.go @@ -13,9 +13,9 @@ import ( "math/big" "sync/atomic" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/storage" ) // loggerName is the tree path name of the logger for this package. diff --git a/pkg/postage/batchstore/store_test.go b/pkg/postage/batchstore/store_test.go index 43e24014d33..090c77c3287 100644 --- a/pkg/postage/batchstore/store_test.go +++ b/pkg/postage/batchstore/store_test.go @@ -10,16 +10,16 @@ import ( "math/rand" "testing" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/batchstore" - mockpost "github.com/ethersphere/bee/pkg/postage/mock" - postagetest "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/statestore/leveldb" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/batchstore" + mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock" + postagetest "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/statestore/leveldb" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) var noopEvictFn = func([]byte) error { return nil } @@ -328,7 +328,7 @@ func TestBatchUpdate(t *testing.T) { // state after the batch is saved/updated. Unlike depth updates, value updates // that are above cumulative amount should NOT result in any radius changes. // Value updates that are less than or equal to the cumulative amount trigger - // the eviction for the the batch, as such, radius may be altered. + // the eviction for the batch, as such, radius may be altered. tcs := []testCase{ { diff --git a/pkg/postage/export_test.go b/pkg/postage/export_test.go index f453d8eadb8..b26f6415010 100644 --- a/pkg/postage/export_test.go +++ b/pkg/postage/export_test.go @@ -5,7 +5,7 @@ package postage import ( - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/postage/listener/listener.go b/pkg/postage/listener/listener.go index a7764fcd077..30b3b2ad81d 100644 --- a/pkg/postage/listener/listener.go +++ b/pkg/postage/listener/listener.go @@ -16,11 +16,11 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/batchservice" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/util/syncutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/batchservice" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/util/syncutil" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/postage/listener/listener_test.go b/pkg/postage/listener/listener_test.go index 7080d33cbdb..43c8675883d 100644 --- a/pkg/postage/listener/listener_test.go +++ b/pkg/postage/listener/listener_test.go @@ -16,13 +16,13 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - chaincfg "github.com/ethersphere/bee/pkg/config" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/listener" - "github.com/ethersphere/bee/pkg/util/abiutil" - "github.com/ethersphere/bee/pkg/util/syncutil" - "github.com/ethersphere/bee/pkg/util/testutil" + chaincfg "github.com/ethersphere/bee/v2/pkg/config" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/listener" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/util/syncutil" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) var ( diff --git a/pkg/postage/listener/metrics.go b/pkg/postage/listener/metrics.go index 99c22aeea16..8fb7b639884 100644 --- a/pkg/postage/listener/metrics.go +++ b/pkg/postage/listener/metrics.go @@ -5,7 +5,7 @@ package listener import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/postage/mock/service.go b/pkg/postage/mock/service.go index 84b2358dd27..b4fffd07761 100644 --- a/pkg/postage/mock/service.go +++ b/pkg/postage/mock/service.go @@ -9,7 +9,7 @@ import ( "math/big" "sync" - "github.com/ethersphere/bee/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage" ) type optionFunc func(*mockPostage) diff --git a/pkg/postage/mock/stamper.go b/pkg/postage/mock/stamper.go index 2c5b0a543f7..f95700eb5e5 100644 --- a/pkg/postage/mock/stamper.go +++ b/pkg/postage/mock/stamper.go @@ -5,8 +5,8 @@ package mock import ( - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type mockStamper struct{} diff --git a/pkg/postage/noop.go b/pkg/postage/noop.go index ea8387deee8..bf58dab9940 100644 --- a/pkg/postage/noop.go +++ b/pkg/postage/noop.go @@ -8,7 +8,7 @@ import ( "errors" "math/big" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var _ Storer = (*NoOpBatchStore)(nil) diff --git a/pkg/postage/postagecontract/contract.go b/pkg/postage/postagecontract/contract.go index 035d7a18f75..d66939b3d42 100644 --- a/pkg/postage/postagecontract/contract.go +++ b/pkg/postage/postagecontract/contract.go @@ -14,10 +14,10 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-sw3-abi/sw3abi" ) diff --git a/pkg/postage/postagecontract/contract_test.go b/pkg/postage/postagecontract/contract_test.go index cd95342fcb2..dd47d44affe 100644 --- a/pkg/postage/postagecontract/contract_test.go +++ b/pkg/postage/postagecontract/contract_test.go @@ -14,15 +14,15 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - chaincfg "github.com/ethersphere/bee/pkg/config" - "github.com/ethersphere/bee/pkg/postage" - postagestoreMock "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - postageMock "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/transaction" - transactionMock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/abiutil" + chaincfg "github.com/ethersphere/bee/v2/pkg/config" + "github.com/ethersphere/bee/v2/pkg/postage" + postagestoreMock "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + postageMock "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/transaction" + transactionMock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" ) var postageStampContractABI = abiutil.MustParseABI(chaincfg.Testnet.PostageStampABI) diff --git a/pkg/postage/postagecontract/mock/contract.go b/pkg/postage/postagecontract/mock/contract.go index ff5b3a8220a..e9547622dae 100644 --- a/pkg/postage/postagecontract/mock/contract.go +++ b/pkg/postage/postagecontract/mock/contract.go @@ -9,7 +9,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/postage/postagecontract" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" ) type contractMock struct { diff --git a/pkg/postage/service.go b/pkg/postage/service.go index 7621e00d281..f14e506370a 100644 --- a/pkg/postage/service.go +++ b/pkg/postage/service.go @@ -14,8 +14,8 @@ import ( "math/big" "sync" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/storage" ) // loggerName is the tree path name of the logger for this package. @@ -174,8 +174,8 @@ func (ps *service) GetStampIssuer(batchID []byte) (*StampIssuer, func() error, e // save persists the specified stamp issuer to the stamperstore. func (ps *service) save(st *StampIssuer) error { - st.bucketMtx.Lock() - defer st.bucketMtx.Unlock() + st.mtx.Lock() + defer st.mtx.Unlock() if err := ps.store.Put(&StampIssuerItem{ Issuer: st, diff --git a/pkg/postage/service_test.go b/pkg/postage/service_test.go index c637b8e2630..f432565fb4a 100644 --- a/pkg/postage/service_test.go +++ b/pkg/postage/service_test.go @@ -13,14 +13,14 @@ import ( "math/big" "testing" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - pstoremock "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + pstoremock "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) // TestSaveLoad tests the idempotence of saving and loading the postage.Service diff --git a/pkg/postage/stamp.go b/pkg/postage/stamp.go index 4fff65797ad..dbe6fd5b2d7 100644 --- a/pkg/postage/stamp.go +++ b/pkg/postage/stamp.go @@ -10,9 +10,9 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // StampSize is the number of bytes in the serialisation of a stamp diff --git a/pkg/postage/stamp_test.go b/pkg/postage/stamp_test.go index ab98a197349..4fb9412f724 100644 --- a/pkg/postage/stamp_test.go +++ b/pkg/postage/stamp_test.go @@ -10,12 +10,12 @@ import ( "math/big" "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - chunktesting "github.com/ethersphere/bee/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + chunktesting "github.com/ethersphere/bee/v2/pkg/storage/testing" ) // TestStampMarshalling tests the idempotence of binary marshal/unmarshals for Stamps. diff --git a/pkg/postage/stamper.go b/pkg/postage/stamper.go index 1ee16a8a133..ca063196546 100644 --- a/pkg/postage/stamper.go +++ b/pkg/postage/stamper.go @@ -8,10 +8,9 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "resenje.org/multex" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( @@ -30,19 +29,18 @@ type stamper struct { store storage.Store issuer *StampIssuer signer crypto.Signer - mu *multex.Multex } // NewStamper constructs a Stamper. func NewStamper(store storage.Store, issuer *StampIssuer, signer crypto.Signer) Stamper { - return &stamper{store, issuer, signer, multex.New()} + return &stamper{store, issuer, signer} } // Stamp takes chunk, see if the chunk can be included in the batch and // signs it with the owner of the batch of this Stamp issuer. func (st *stamper) Stamp(addr swarm.Address) (*Stamp, error) { - st.mu.Lock(addr.ByteString()) - defer st.mu.Unlock(addr.ByteString()) + st.issuer.mtx.Lock() + defer st.issuer.mtx.Unlock() item := &StampItem{ BatchID: st.issuer.data.BatchID, diff --git a/pkg/postage/stamper_test.go b/pkg/postage/stamper_test.go index 520d6da0faf..a1c589b145c 100644 --- a/pkg/postage/stamper_test.go +++ b/pkg/postage/stamper_test.go @@ -10,11 +10,11 @@ import ( "math/big" "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // TestStamperStamping tests if the stamp created by the stamper is valid. diff --git a/pkg/postage/stampissuer.go b/pkg/postage/stampissuer.go index 84b5292528a..77b632cf0f4 100644 --- a/pkg/postage/stampissuer.go +++ b/pkg/postage/stampissuer.go @@ -13,8 +13,8 @@ import ( "sync" "time" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/vmihailenco/msgpack/v5" ) @@ -151,8 +151,8 @@ func (s stampIssuerData) Clone() stampIssuerData { // A StampIssuer instance extends a batch with bucket collision tracking // embedded in multiple Stampers, can be used concurrently. type StampIssuer struct { - data stampIssuerData - bucketMtx sync.Mutex + data stampIssuerData + mtx sync.Mutex } // NewStampIssuer constructs a StampIssuer as an extension of a batch for local @@ -177,10 +177,8 @@ func NewStampIssuer(label, keyID string, batchID []byte, batchAmount *big.Int, b // increment increments the count in the correct collision // bucket for a newly stamped chunk with given addr address. +// Must be mutex locked before usage. func (si *StampIssuer) increment(addr swarm.Address) (batchIndex []byte, batchTimestamp []byte, err error) { - si.bucketMtx.Lock() - defer si.bucketMtx.Unlock() - bIdx := toBucket(si.BucketDepth(), addr) bCnt := si.data.Buckets[bIdx] @@ -263,8 +261,8 @@ func (si *StampIssuer) ImmutableFlag() bool { } func (si *StampIssuer) Buckets() []uint32 { - si.bucketMtx.Lock() - defer si.bucketMtx.Unlock() + si.mtx.Lock() + defer si.mtx.Unlock() b := make([]uint32, len(si.data.Buckets)) copy(b, si.data.Buckets) return b diff --git a/pkg/postage/stampissuer_test.go b/pkg/postage/stampissuer_test.go index 9d99b7087ca..3a72b57f3d6 100644 --- a/pkg/postage/stampissuer_test.go +++ b/pkg/postage/stampissuer_test.go @@ -16,10 +16,10 @@ import ( "sync/atomic" "testing" - "github.com/ethersphere/bee/pkg/postage" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storagetest" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/postage" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "golang.org/x/sync/errgroup" diff --git a/pkg/postage/testing/batch.go b/pkg/postage/testing/batch.go index a9c21c355ec..2e8349da220 100644 --- a/pkg/postage/testing/batch.go +++ b/pkg/postage/testing/batch.go @@ -12,7 +12,7 @@ import ( "math/rand" "testing" - "github.com/ethersphere/bee/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage" ) const ( diff --git a/pkg/postage/testing/chainstate.go b/pkg/postage/testing/chainstate.go index dff5e07d490..edd1dc554b8 100644 --- a/pkg/postage/testing/chainstate.go +++ b/pkg/postage/testing/chainstate.go @@ -8,7 +8,7 @@ import ( "math/rand" "testing" - "github.com/ethersphere/bee/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage" ) // NewChainState will create a new ChainState with random values. diff --git a/pkg/postage/testing/stamp.go b/pkg/postage/testing/stamp.go index def77bf582b..80ba4317e2a 100644 --- a/pkg/postage/testing/stamp.go +++ b/pkg/postage/testing/stamp.go @@ -9,9 +9,9 @@ import ( "encoding/binary" "io" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const signatureSize = 65 diff --git a/pkg/pricer/headerutils/utilities.go b/pkg/pricer/headerutils/utilities.go index f67b71b6de5..a85e56990b4 100644 --- a/pkg/pricer/headerutils/utilities.go +++ b/pkg/pricer/headerutils/utilities.go @@ -7,8 +7,8 @@ package headerutils import ( "encoding/binary" "errors" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ( diff --git a/pkg/pricer/headerutils/utilities_test.go b/pkg/pricer/headerutils/utilities_test.go index 55ec77e500e..b2c62ee68d1 100644 --- a/pkg/pricer/headerutils/utilities_test.go +++ b/pkg/pricer/headerutils/utilities_test.go @@ -8,9 +8,9 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/pricer/headerutils" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/pricer/headerutils" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestMakePricingHeaders(t *testing.T) { diff --git a/pkg/pricer/mock/pricer.go b/pkg/pricer/mock/pricer.go index 49bc87b6923..5daf93debc7 100644 --- a/pkg/pricer/mock/pricer.go +++ b/pkg/pricer/mock/pricer.go @@ -5,7 +5,7 @@ package mock import ( - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type MockPricer struct { diff --git a/pkg/pricer/pricer.go b/pkg/pricer/pricer.go index a060c4a5a21..21cbde9a4b3 100644 --- a/pkg/pricer/pricer.go +++ b/pkg/pricer/pricer.go @@ -5,7 +5,7 @@ package pricer import ( - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Pricer returns pricing information for chunk hashes. diff --git a/pkg/pricing/export_test.go b/pkg/pricing/export_test.go index 30b2ad2b2b8..90d8a7e6ed4 100644 --- a/pkg/pricing/export_test.go +++ b/pkg/pricing/export_test.go @@ -7,7 +7,7 @@ package pricing import ( "context" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p" ) func (s *Service) Init(ctx context.Context, p p2p.Peer) error { diff --git a/pkg/pricing/pricing.go b/pkg/pricing/pricing.go index bb105e87e68..32ec1515936 100644 --- a/pkg/pricing/pricing.go +++ b/pkg/pricing/pricing.go @@ -11,11 +11,11 @@ import ( "math/big" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/pricing/pb" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/pricing/pb" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // loggerName is the tree path name of the logger for this package. diff --git a/pkg/pricing/pricing_test.go b/pkg/pricing/pricing_test.go index 1a721216562..70f758353d1 100644 --- a/pkg/pricing/pricing_test.go +++ b/pkg/pricing/pricing_test.go @@ -11,13 +11,13 @@ import ( "math/big" "testing" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - "github.com/ethersphere/bee/pkg/pricing" - "github.com/ethersphere/bee/pkg/pricing/pb" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + "github.com/ethersphere/bee/v2/pkg/pricing" + "github.com/ethersphere/bee/v2/pkg/pricing/pb" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type testThresholdObserver struct { diff --git a/pkg/pss/metrics.go b/pkg/pss/metrics.go index ebf6ccbb14a..108f516215f 100644 --- a/pkg/pss/metrics.go +++ b/pkg/pss/metrics.go @@ -5,7 +5,7 @@ package pss import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/pss/mining_test.go b/pkg/pss/mining_test.go index 6c205a8c9df..4dd94e45bb2 100644 --- a/pkg/pss/mining_test.go +++ b/pkg/pss/mining_test.go @@ -10,8 +10,8 @@ import ( "fmt" "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/pss" ) func newTargets(length, depth int) pss.Targets { diff --git a/pkg/pss/pss.go b/pkg/pss/pss.go index b8758f82a5e..3a09db0b633 100644 --- a/pkg/pss/pss.go +++ b/pkg/pss/pss.go @@ -17,11 +17,11 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/pushsync" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/pushsync" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" ) // loggerName is the tree path name of the logger for this package. diff --git a/pkg/pss/pss_test.go b/pkg/pss/pss_test.go index d211b763117..1d04237bbaa 100644 --- a/pkg/pss/pss_test.go +++ b/pkg/pss/pss_test.go @@ -10,14 +10,14 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/pss" - "github.com/ethersphere/bee/pkg/pushsync" - pushsyncmock "github.com/ethersphere/bee/pkg/pushsync/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/pushsync" + pushsyncmock "github.com/ethersphere/bee/v2/pkg/pushsync/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // TestSend creates a trojan chunk and sends it using push sync diff --git a/pkg/pss/trojan.go b/pkg/pss/trojan.go index 4e742875333..b6b404f2389 100644 --- a/pkg/pss/trojan.go +++ b/pkg/pss/trojan.go @@ -16,11 +16,11 @@ import ( "io" "github.com/btcsuite/btcd/btcec/v2" - "github.com/ethersphere/bee/pkg/bmtpool" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/encryption" - "github.com/ethersphere/bee/pkg/encryption/elgamal" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmtpool" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/encryption" + "github.com/ethersphere/bee/v2/pkg/encryption/elgamal" + "github.com/ethersphere/bee/v2/pkg/swarm" "golang.org/x/sync/errgroup" ) diff --git a/pkg/pss/trojan_test.go b/pkg/pss/trojan_test.go index 134ff2837b6..1d78b56c3aa 100644 --- a/pkg/pss/trojan_test.go +++ b/pkg/pss/trojan_test.go @@ -9,9 +9,9 @@ import ( "context" "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/pss" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/pss" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestWrap(t *testing.T) { diff --git a/pkg/puller/export_test.go b/pkg/puller/export_test.go index 7d7b7b5b47a..b57ae396b3f 100644 --- a/pkg/puller/export_test.go +++ b/pkg/puller/export_test.go @@ -4,7 +4,7 @@ package puller -import "github.com/ethersphere/bee/pkg/swarm" +import "github.com/ethersphere/bee/v2/pkg/swarm" var PeerIntervalKey = peerIntervalKey diff --git a/pkg/puller/intervalstore/store_test.go b/pkg/puller/intervalstore/store_test.go index 5e1a5e0ef23..b4e2be192db 100644 --- a/pkg/puller/intervalstore/store_test.go +++ b/pkg/puller/intervalstore/store_test.go @@ -20,11 +20,11 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/statestore/leveldb" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/statestore/leveldb" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) // TestInmemoryStore tests basic functionality of InmemoryStore. diff --git a/pkg/puller/metrics.go b/pkg/puller/metrics.go index 715a285be63..2b77ad5e016 100644 --- a/pkg/puller/metrics.go +++ b/pkg/puller/metrics.go @@ -5,7 +5,7 @@ package puller import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/puller/puller.go b/pkg/puller/puller.go index f2cfd15eee0..0523f9c8141 100644 --- a/pkg/puller/puller.go +++ b/pkg/puller/puller.go @@ -15,15 +15,15 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/puller/intervalstore" - "github.com/ethersphere/bee/pkg/pullsync" - "github.com/ethersphere/bee/pkg/rate" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/puller/intervalstore" + "github.com/ethersphere/bee/v2/pkg/pullsync" + "github.com/ethersphere/bee/v2/pkg/rate" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" ratelimit "golang.org/x/time/rate" ) diff --git a/pkg/puller/puller_test.go b/pkg/puller/puller_test.go index f76fe292432..2be411f370f 100644 --- a/pkg/puller/puller_test.go +++ b/pkg/puller/puller_test.go @@ -11,17 +11,17 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/puller" - "github.com/ethersphere/bee/pkg/puller/intervalstore" - mockps "github.com/ethersphere/bee/pkg/pullsync/mock" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/storage" - resMock "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" - kadMock "github.com/ethersphere/bee/pkg/topology/kademlia/mock" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/puller" + "github.com/ethersphere/bee/v2/pkg/puller/intervalstore" + mockps "github.com/ethersphere/bee/v2/pkg/pullsync/mock" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/storage" + resMock "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + kadMock "github.com/ethersphere/bee/v2/pkg/topology/kademlia/mock" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/pullsync/metrics.go b/pkg/pullsync/metrics.go index 24d11cf892f..340732f2114 100644 --- a/pkg/pullsync/metrics.go +++ b/pkg/pullsync/metrics.go @@ -5,7 +5,7 @@ package pullsync import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/pullsync/mock/pullsync.go b/pkg/pullsync/mock/pullsync.go index acd54b51ebf..bb77934924f 100644 --- a/pkg/pullsync/mock/pullsync.go +++ b/pkg/pullsync/mock/pullsync.go @@ -9,8 +9,8 @@ import ( "fmt" "sync" - "github.com/ethersphere/bee/pkg/pullsync" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/pullsync" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var _ pullsync.Interface = (*PullSyncMock)(nil) diff --git a/pkg/pullsync/pullsync.go b/pkg/pullsync/pullsync.go index 42691cbbe0c..5caa6e050a6 100644 --- a/pkg/pullsync/pullsync.go +++ b/pkg/pullsync/pullsync.go @@ -16,17 +16,17 @@ import ( "sync/atomic" "time" - "github.com/ethersphere/bee/pkg/bitvector" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/pullsync/pb" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bitvector" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/pullsync/pb" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" "resenje.org/multex" "resenje.org/singleflight" ) diff --git a/pkg/pullsync/pullsync_test.go b/pkg/pullsync/pullsync_test.go index 70f958e63dd..bf25216519e 100644 --- a/pkg/pullsync/pullsync_test.go +++ b/pkg/pullsync/pullsync_test.go @@ -11,17 +11,17 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - "github.com/ethersphere/bee/pkg/postage" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/pullsync" - "github.com/ethersphere/bee/pkg/storage" - testingc "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer" - mock "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + "github.com/ethersphere/bee/v2/pkg/postage" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/pullsync" + "github.com/ethersphere/bee/v2/pkg/storage" + testingc "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer" + mock "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/pusher/inflight.go b/pkg/pusher/inflight.go index 075dfe7e2fa..788872d2652 100644 --- a/pkg/pusher/inflight.go +++ b/pkg/pusher/inflight.go @@ -7,7 +7,7 @@ package pusher import ( "sync" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type inflight struct { diff --git a/pkg/pusher/metrics.go b/pkg/pusher/metrics.go index 093c6ca036e..03e55bad2b8 100644 --- a/pkg/pusher/metrics.go +++ b/pkg/pusher/metrics.go @@ -5,7 +5,7 @@ package pusher import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/pusher/pusher.go b/pkg/pusher/pusher.go index 457af2f58a3..c570d5ca1c6 100644 --- a/pkg/pusher/pusher.go +++ b/pkg/pusher/pusher.go @@ -17,14 +17,14 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/pushsync" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/pushsync" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/tracing" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" olog "github.com/opentracing/opentracing-go/log" diff --git a/pkg/pusher/pusher_test.go b/pkg/pusher/pusher_test.go index 6f361b93e6b..39132c624bf 100644 --- a/pkg/pusher/pusher_test.go +++ b/pkg/pusher/pusher_test.go @@ -14,18 +14,18 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/pusher" - "github.com/ethersphere/bee/pkg/pushsync" - pushsyncmock "github.com/ethersphere/bee/pkg/pushsync/mock" - "github.com/ethersphere/bee/pkg/spinlock" - storage "github.com/ethersphere/bee/pkg/storage" - testingc "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/pusher" + "github.com/ethersphere/bee/v2/pkg/pushsync" + pushsyncmock "github.com/ethersphere/bee/v2/pkg/pushsync/mock" + "github.com/ethersphere/bee/v2/pkg/spinlock" + storage "github.com/ethersphere/bee/v2/pkg/storage" + testingc "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) // time to wait for received response from pushsync diff --git a/pkg/pushsync/metrics.go b/pkg/pushsync/metrics.go index 96161162df2..d182cbffc20 100644 --- a/pkg/pushsync/metrics.go +++ b/pkg/pushsync/metrics.go @@ -5,7 +5,7 @@ package pushsync import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/pushsync/mock/mock.go b/pkg/pushsync/mock/mock.go index 3d74f7f62c5..6afac9f493f 100644 --- a/pkg/pushsync/mock/mock.go +++ b/pkg/pushsync/mock/mock.go @@ -7,8 +7,8 @@ package mock import ( "context" - "github.com/ethersphere/bee/pkg/pushsync" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/pushsync" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type mock struct { diff --git a/pkg/pushsync/pushsync.go b/pkg/pushsync/pushsync.go index 8f1597384a6..6a74b159e0d 100644 --- a/pkg/pushsync/pushsync.go +++ b/pkg/pushsync/pushsync.go @@ -12,21 +12,21 @@ import ( "fmt" "time" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/pricer" - "github.com/ethersphere/bee/pkg/pushsync/pb" - "github.com/ethersphere/bee/pkg/skippeers" - "github.com/ethersphere/bee/pkg/soc" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/pricer" + "github.com/ethersphere/bee/v2/pkg/pushsync/pb" + "github.com/ethersphere/bee/v2/pkg/skippeers" + "github.com/ethersphere/bee/v2/pkg/soc" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/tracing" opentracing "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" olog "github.com/opentracing/opentracing-go/log" @@ -367,7 +367,7 @@ func (ps *PushSync) pushToClosest(ctx context.Context, ch swarm.Chunk, origin bo if errors.Is(err, topology.ErrNotFound) { if ps.skipList.PruneExpiresAfter(ch.Address(), overDraftRefresh) == 0 { //no overdraft peers, we have depleted ALL peers if inflight == 0 { - if ps.fullNode && ps.topologyDriver.IsReachable() { + if ps.fullNode { if cac.Valid(ch) { go ps.unwrap(ch) } diff --git a/pkg/pushsync/pushsync_test.go b/pkg/pushsync/pushsync_test.go index 7b6c958ef7b..24e9fb45c9b 100644 --- a/pkg/pushsync/pushsync_test.go +++ b/pkg/pushsync/pushsync_test.go @@ -14,22 +14,22 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/accounting" - accountingmock "github.com/ethersphere/bee/pkg/accounting/mock" - "github.com/ethersphere/bee/pkg/crypto" - cryptomock "github.com/ethersphere/bee/pkg/crypto/mock" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - pricermock "github.com/ethersphere/bee/pkg/pricer/mock" - "github.com/ethersphere/bee/pkg/pushsync" - "github.com/ethersphere/bee/pkg/pushsync/pb" - storage "github.com/ethersphere/bee/pkg/storage" - testingc "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/topology/mock" + "github.com/ethersphere/bee/v2/pkg/accounting" + accountingmock "github.com/ethersphere/bee/v2/pkg/accounting/mock" + "github.com/ethersphere/bee/v2/pkg/crypto" + cryptomock "github.com/ethersphere/bee/v2/pkg/crypto/mock" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + pricermock "github.com/ethersphere/bee/v2/pkg/pricer/mock" + "github.com/ethersphere/bee/v2/pkg/pushsync" + "github.com/ethersphere/bee/v2/pkg/pushsync/pb" + storage "github.com/ethersphere/bee/v2/pkg/storage" + testingc "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/topology/mock" ) const ( diff --git a/pkg/rate/rate_test.go b/pkg/rate/rate_test.go index 6c9ac2b28c7..55df75daff1 100644 --- a/pkg/rate/rate_test.go +++ b/pkg/rate/rate_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/rate" + "github.com/ethersphere/bee/v2/pkg/rate" ) func TestRateFirstBucket(t *testing.T) { diff --git a/pkg/ratelimit/ratelimit_test.go b/pkg/ratelimit/ratelimit_test.go index 8f87bfd8fc5..e31fe5722bc 100644 --- a/pkg/ratelimit/ratelimit_test.go +++ b/pkg/ratelimit/ratelimit_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/ratelimit" + "github.com/ethersphere/bee/v2/pkg/ratelimit" ) func TestRateLimit(t *testing.T) { diff --git a/pkg/replicas/export_test.go b/pkg/replicas/export_test.go index 6e029f302c6..271ad71ed0b 100644 --- a/pkg/replicas/export_test.go +++ b/pkg/replicas/export_test.go @@ -4,7 +4,7 @@ package replicas -import "github.com/ethersphere/bee/pkg/storage" +import "github.com/ethersphere/bee/v2/pkg/storage" var ( Signer = signer diff --git a/pkg/replicas/getter.go b/pkg/replicas/getter.go index 26345919958..5dc42cb7c82 100644 --- a/pkg/replicas/getter.go +++ b/pkg/replicas/getter.go @@ -12,10 +12,10 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // ErrSwarmageddon is returned in case of a vis mayor called Swarmageddon. diff --git a/pkg/replicas/getter_test.go b/pkg/replicas/getter_test.go index 7435b0574fd..057daa8e300 100644 --- a/pkg/replicas/getter_test.go +++ b/pkg/replicas/getter_test.go @@ -14,12 +14,12 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/replicas" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/replicas" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type testGetter struct { diff --git a/pkg/replicas/putter.go b/pkg/replicas/putter.go index 4aa55b638f0..e62478119a3 100644 --- a/pkg/replicas/putter.go +++ b/pkg/replicas/putter.go @@ -11,10 +11,10 @@ import ( "errors" "sync" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // putter is the private implementation of the public storage.Putter interface diff --git a/pkg/replicas/putter_test.go b/pkg/replicas/putter_test.go index 7d05624ebca..b4e379352bb 100644 --- a/pkg/replicas/putter_test.go +++ b/pkg/replicas/putter_test.go @@ -14,12 +14,12 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/replicas" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/replicas" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/replicas/replica_test.go b/pkg/replicas/replica_test.go index ce56401d987..3a253f24f5b 100644 --- a/pkg/replicas/replica_test.go +++ b/pkg/replicas/replica_test.go @@ -10,10 +10,10 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // dispersed verifies that a set of addresses are maximally dispersed without repetition diff --git a/pkg/replicas/replicas.go b/pkg/replicas/replicas.go index fd45b28a3b1..01b326b76c8 100644 --- a/pkg/replicas/replicas.go +++ b/pkg/replicas/replicas.go @@ -13,9 +13,9 @@ package replicas import ( "time" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/file/redundancy" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/resolver/cidv1/cidv1.go b/pkg/resolver/cidv1/cidv1.go index ded3b701ffe..097f06d28aa 100644 --- a/pkg/resolver/cidv1/cidv1.go +++ b/pkg/resolver/cidv1/cidv1.go @@ -7,8 +7,8 @@ package cidv1 import ( "fmt" - "github.com/ethersphere/bee/pkg/resolver" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/resolver" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/ipfs/go-cid" "github.com/multiformats/go-multihash" ) diff --git a/pkg/resolver/cidv1/cidv1_test.go b/pkg/resolver/cidv1/cidv1_test.go index 92100f73903..a0bcc675bc0 100644 --- a/pkg/resolver/cidv1/cidv1_test.go +++ b/pkg/resolver/cidv1/cidv1_test.go @@ -8,9 +8,9 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/resolver" - "github.com/ethersphere/bee/pkg/resolver/cidv1" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/resolver" + "github.com/ethersphere/bee/v2/pkg/resolver/cidv1" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) func TestCIDResolver(t *testing.T) { diff --git a/pkg/resolver/client/client.go b/pkg/resolver/client/client.go index 988606135d8..71d301fa74b 100644 --- a/pkg/resolver/client/client.go +++ b/pkg/resolver/client/client.go @@ -5,7 +5,7 @@ package client import ( - "github.com/ethersphere/bee/pkg/resolver" + "github.com/ethersphere/bee/v2/pkg/resolver" ) // Interface is a resolver client that can connect/disconnect to an external diff --git a/pkg/resolver/client/ens/ens.go b/pkg/resolver/client/ens/ens.go index bd190fba7fb..38c7432e979 100644 --- a/pkg/resolver/client/ens/ens.go +++ b/pkg/resolver/client/ens/ens.go @@ -14,9 +14,9 @@ import ( "github.com/ethereum/go-ethereum/ethclient" goens "github.com/wealdtech/go-ens/v3" - "github.com/ethersphere/bee/pkg/resolver" - "github.com/ethersphere/bee/pkg/resolver/client" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/resolver" + "github.com/ethersphere/bee/v2/pkg/resolver/client" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ( diff --git a/pkg/resolver/client/ens/ens_integration_test.go b/pkg/resolver/client/ens/ens_integration_test.go index 139347c2db8..f5aa9b1d9d7 100644 --- a/pkg/resolver/client/ens/ens_integration_test.go +++ b/pkg/resolver/client/ens/ens_integration_test.go @@ -10,8 +10,8 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/resolver/client/ens" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/resolver/client/ens" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestENSIntegration(t *testing.T) { diff --git a/pkg/resolver/client/ens/ens_test.go b/pkg/resolver/client/ens/ens_test.go index 3ecd67be4ae..aa0d0c0cb64 100644 --- a/pkg/resolver/client/ens/ens_test.go +++ b/pkg/resolver/client/ens/ens_test.go @@ -13,9 +13,9 @@ import ( "github.com/ethereum/go-ethereum/rpc" goens "github.com/wealdtech/go-ens/v3" - "github.com/ethersphere/bee/pkg/resolver" - "github.com/ethersphere/bee/pkg/resolver/client/ens" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/resolver" + "github.com/ethersphere/bee/v2/pkg/resolver/client/ens" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestNewENSClient(t *testing.T) { diff --git a/pkg/resolver/client/mock/mock.go b/pkg/resolver/client/mock/mock.go index d3b24fd8559..01bbdf0cf99 100644 --- a/pkg/resolver/client/mock/mock.go +++ b/pkg/resolver/client/mock/mock.go @@ -5,8 +5,8 @@ package mock import ( - "github.com/ethersphere/bee/pkg/resolver/client" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/resolver/client" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Ensure mock Client implements the Client interface. diff --git a/pkg/resolver/mock/resolver.go b/pkg/resolver/mock/resolver.go index 547abd6270b..bbae8ff2702 100644 --- a/pkg/resolver/mock/resolver.go +++ b/pkg/resolver/mock/resolver.go @@ -7,8 +7,8 @@ package mock import ( "fmt" - "github.com/ethersphere/bee/pkg/resolver" - "github.com/ethersphere/bee/pkg/resolver/client/ens" + "github.com/ethersphere/bee/v2/pkg/resolver" + "github.com/ethersphere/bee/v2/pkg/resolver/client/ens" ) // Assure mock Resolver implements the Resolver interface. diff --git a/pkg/resolver/multiresolver/config_test.go b/pkg/resolver/multiresolver/config_test.go index 9ee417f6d3d..9b4c2d502c2 100644 --- a/pkg/resolver/multiresolver/config_test.go +++ b/pkg/resolver/multiresolver/config_test.go @@ -8,7 +8,7 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/resolver/multiresolver" + "github.com/ethersphere/bee/v2/pkg/resolver/multiresolver" ) func TestParseConnectionStrings(t *testing.T) { diff --git a/pkg/resolver/multiresolver/export_test.go b/pkg/resolver/multiresolver/export_test.go index 5e2624774c8..e3d260f74f9 100644 --- a/pkg/resolver/multiresolver/export_test.go +++ b/pkg/resolver/multiresolver/export_test.go @@ -4,7 +4,7 @@ package multiresolver -import "github.com/ethersphere/bee/pkg/log" +import "github.com/ethersphere/bee/v2/pkg/log" func GetLogger(mr *MultiResolver) log.Logger { return mr.logger diff --git a/pkg/resolver/multiresolver/multiresolver.go b/pkg/resolver/multiresolver/multiresolver.go index 97472d47807..31111931bb2 100644 --- a/pkg/resolver/multiresolver/multiresolver.go +++ b/pkg/resolver/multiresolver/multiresolver.go @@ -10,10 +10,10 @@ import ( "path" "strings" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/resolver" - "github.com/ethersphere/bee/pkg/resolver/cidv1" - "github.com/ethersphere/bee/pkg/resolver/client/ens" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/resolver" + "github.com/ethersphere/bee/v2/pkg/resolver/cidv1" + "github.com/ethersphere/bee/v2/pkg/resolver/client/ens" "github.com/hashicorp/go-multierror" ) diff --git a/pkg/resolver/multiresolver/multiresolver_test.go b/pkg/resolver/multiresolver/multiresolver_test.go index a6d31f796e7..326cbb69a04 100644 --- a/pkg/resolver/multiresolver/multiresolver_test.go +++ b/pkg/resolver/multiresolver/multiresolver_test.go @@ -10,11 +10,11 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/resolver" - "github.com/ethersphere/bee/pkg/resolver/mock" - "github.com/ethersphere/bee/pkg/resolver/multiresolver" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/resolver" + "github.com/ethersphere/bee/v2/pkg/resolver/mock" + "github.com/ethersphere/bee/v2/pkg/resolver/multiresolver" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type Address = swarm.Address diff --git a/pkg/resolver/resolver.go b/pkg/resolver/resolver.go index 1d38e987165..043dcaf87e0 100644 --- a/pkg/resolver/resolver.go +++ b/pkg/resolver/resolver.go @@ -8,7 +8,7 @@ import ( "errors" "io" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Address is the swarm bzz address. diff --git a/pkg/retrieval/export_test.go b/pkg/retrieval/export_test.go index 4ba5bc1fdac..cc53399f636 100644 --- a/pkg/retrieval/export_test.go +++ b/pkg/retrieval/export_test.go @@ -7,8 +7,8 @@ package retrieval import ( "context" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func (s *Service) Handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) error { diff --git a/pkg/retrieval/main_test.go b/pkg/retrieval/main_test.go index eec426389d0..8be3983b65d 100644 --- a/pkg/retrieval/main_test.go +++ b/pkg/retrieval/main_test.go @@ -14,7 +14,7 @@ func TestMain(m *testing.M) { goleak.VerifyTestMain( m, // pkg/p2p package has some leak issues, we ignore them here as they are not in current scope - goleak.IgnoreTopFunction("github.com/ethersphere/bee/pkg/p2p/protobuf.Reader.ReadMsgWithContext"), - goleak.IgnoreTopFunction("github.com/ethersphere/bee/pkg/p2p/streamtest.(*record).Read"), + goleak.IgnoreTopFunction("github.com/ethersphere/bee/v2/pkg/p2p/protobuf.Reader.ReadMsgWithContext"), + goleak.IgnoreTopFunction("github.com/ethersphere/bee/v2/pkg/p2p/streamtest.(*record).Read"), ) } diff --git a/pkg/retrieval/metrics.go b/pkg/retrieval/metrics.go index 30881b77361..f88f11d6c06 100644 --- a/pkg/retrieval/metrics.go +++ b/pkg/retrieval/metrics.go @@ -7,7 +7,7 @@ package retrieval import ( "github.com/prometheus/client_golang/prometheus" - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" ) type metrics struct { diff --git a/pkg/retrieval/retrieval.go b/pkg/retrieval/retrieval.go index cae78558df9..fc3a0092c69 100644 --- a/pkg/retrieval/retrieval.go +++ b/pkg/retrieval/retrieval.go @@ -14,19 +14,19 @@ import ( "fmt" "time" - "github.com/ethersphere/bee/pkg/accounting" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/pricer" - pb "github.com/ethersphere/bee/pkg/retrieval/pb" - "github.com/ethersphere/bee/pkg/skippeers" - "github.com/ethersphere/bee/pkg/soc" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/accounting" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/pricer" + pb "github.com/ethersphere/bee/v2/pkg/retrieval/pb" + "github.com/ethersphere/bee/v2/pkg/skippeers" + "github.com/ethersphere/bee/v2/pkg/soc" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/tracing" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" olog "github.com/opentracing/opentracing-go/log" @@ -122,7 +122,7 @@ func (s *Service) Protocol() p2p.ProtocolSpec { } const ( - retrieveChunkTimeout = time.Second * 30 + RetrieveChunkTimeout = time.Second * 30 preemptiveInterval = time.Second overDraftRefresh = time.Millisecond * 600 skiplistDur = time.Minute @@ -320,7 +320,7 @@ func (s *Service) retrieveChunk(ctx context.Context, quit chan struct{}, chunkAd } }() - ctx, cancel := context.WithTimeout(ctx, retrieveChunkTimeout) + ctx, cancel := context.WithTimeout(ctx, RetrieveChunkTimeout) defer cancel() stream, err := s.streamer.NewStream(ctx, peer, nil, protocolName, protocolVersion, streamName) @@ -425,7 +425,7 @@ func (s *Service) closestPeer(addr swarm.Address, skipPeers []swarm.Address, all } func (s *Service) handler(p2pctx context.Context, p p2p.Peer, stream p2p.Stream) (err error) { - ctx, cancel := context.WithTimeout(p2pctx, retrieveChunkTimeout) + ctx, cancel := context.WithTimeout(p2pctx, RetrieveChunkTimeout) defer cancel() w, r := protobuf.NewWriterAndReader(stream) diff --git a/pkg/retrieval/retrieval_test.go b/pkg/retrieval/retrieval_test.go index c4156583cb2..05f44abeef8 100644 --- a/pkg/retrieval/retrieval_test.go +++ b/pkg/retrieval/retrieval_test.go @@ -15,26 +15,26 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/accounting" - accountingmock "github.com/ethersphere/bee/pkg/accounting/mock" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - "github.com/ethersphere/bee/pkg/pricer" - pricermock "github.com/ethersphere/bee/pkg/pricer/mock" - "github.com/ethersphere/bee/pkg/retrieval" - pb "github.com/ethersphere/bee/pkg/retrieval/pb" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - testingc "github.com/ethersphere/bee/pkg/storage/testing" - storemock "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/tracing" - - topologymock "github.com/ethersphere/bee/pkg/topology/mock" + "github.com/ethersphere/bee/v2/pkg/accounting" + accountingmock "github.com/ethersphere/bee/v2/pkg/accounting/mock" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + "github.com/ethersphere/bee/v2/pkg/pricer" + pricermock "github.com/ethersphere/bee/v2/pkg/pricer/mock" + "github.com/ethersphere/bee/v2/pkg/retrieval" + pb "github.com/ethersphere/bee/v2/pkg/retrieval/pb" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + testingc "github.com/ethersphere/bee/v2/pkg/storage/testing" + storemock "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/tracing" + + topologymock "github.com/ethersphere/bee/v2/pkg/topology/mock" ) var ( diff --git a/pkg/salud/metrics.go b/pkg/salud/metrics.go index db5309b9dad..c9a3b68a17f 100644 --- a/pkg/salud/metrics.go +++ b/pkg/salud/metrics.go @@ -5,7 +5,7 @@ package salud import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/salud/salud.go b/pkg/salud/salud.go index d9a661c40af..c6a46500cb0 100644 --- a/pkg/salud/salud.go +++ b/pkg/salud/salud.go @@ -12,11 +12,11 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/status" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/status" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" "go.uber.org/atomic" ) diff --git a/pkg/salud/salud_test.go b/pkg/salud/salud_test.go index 58a5ae38bb6..b408f06b95c 100644 --- a/pkg/salud/salud_test.go +++ b/pkg/salud/salud_test.go @@ -10,13 +10,13 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/salud" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/status" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" - topMock "github.com/ethersphere/bee/pkg/topology/mock" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/salud" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/status" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + topMock "github.com/ethersphere/bee/v2/pkg/topology/mock" ) type peer struct { diff --git a/pkg/settlement/interface.go b/pkg/settlement/interface.go index 85daae6c212..f24ec60ce69 100644 --- a/pkg/settlement/interface.go +++ b/pkg/settlement/interface.go @@ -8,7 +8,7 @@ import ( "errors" "math/big" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/settlement/pseudosettle/export_test.go b/pkg/settlement/pseudosettle/export_test.go index 24cac963405..3748cbf03f6 100644 --- a/pkg/settlement/pseudosettle/export_test.go +++ b/pkg/settlement/pseudosettle/export_test.go @@ -8,7 +8,7 @@ import ( "context" "time" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p" ) func (s *Service) SetTimeNow(f func() time.Time) { diff --git a/pkg/settlement/pseudosettle/metrics.go b/pkg/settlement/pseudosettle/metrics.go index b3530500be0..971795cb6a8 100644 --- a/pkg/settlement/pseudosettle/metrics.go +++ b/pkg/settlement/pseudosettle/metrics.go @@ -5,7 +5,7 @@ package pseudosettle import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/settlement/pseudosettle/pseudosettle.go b/pkg/settlement/pseudosettle/pseudosettle.go index 75fe647968f..24531b84641 100644 --- a/pkg/settlement/pseudosettle/pseudosettle.go +++ b/pkg/settlement/pseudosettle/pseudosettle.go @@ -13,13 +13,13 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/settlement" - pb "github.com/ethersphere/bee/pkg/settlement/pseudosettle/pb" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/settlement" + pb "github.com/ethersphere/bee/v2/pkg/settlement/pseudosettle/pb" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // loggerName is the tree path name of the logger for this package. diff --git a/pkg/settlement/pseudosettle/pseudosettle_test.go b/pkg/settlement/pseudosettle/pseudosettle_test.go index c12144623e3..397592e9d96 100644 --- a/pkg/settlement/pseudosettle/pseudosettle_test.go +++ b/pkg/settlement/pseudosettle/pseudosettle_test.go @@ -13,17 +13,17 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - mockp2p "github.com/ethersphere/bee/pkg/p2p/mock" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - "github.com/ethersphere/bee/pkg/settlement/pseudosettle" - "github.com/ethersphere/bee/pkg/settlement/pseudosettle/pb" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + mockp2p "github.com/ethersphere/bee/v2/pkg/p2p/mock" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + "github.com/ethersphere/bee/v2/pkg/settlement/pseudosettle" + "github.com/ethersphere/bee/v2/pkg/settlement/pseudosettle/pb" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) type testObserver struct { diff --git a/pkg/settlement/swap/addressbook.go b/pkg/settlement/swap/addressbook.go index 08d6c4ed778..5cf0aad45f8 100644 --- a/pkg/settlement/swap/addressbook.go +++ b/pkg/settlement/swap/addressbook.go @@ -9,8 +9,8 @@ import ( "fmt" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/settlement/swap/chequebook/cashout.go b/pkg/settlement/swap/chequebook/cashout.go index 157af01ad56..245b16ca6aa 100644 --- a/pkg/settlement/swap/chequebook/cashout.go +++ b/pkg/settlement/swap/chequebook/cashout.go @@ -14,9 +14,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/transaction" ) var ( diff --git a/pkg/settlement/swap/chequebook/cashout_test.go b/pkg/settlement/swap/chequebook/cashout_test.go index 2aa3dc992c5..dc195e6a465 100644 --- a/pkg/settlement/swap/chequebook/cashout_test.go +++ b/pkg/settlement/swap/chequebook/cashout_test.go @@ -11,12 +11,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - chequestoremock "github.com/ethersphere/bee/pkg/settlement/swap/chequestore/mock" - storemock "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/transaction/backendmock" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + chequestoremock "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequestore/mock" + storemock "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/transaction/backendmock" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-sw3-abi/sw3abi" ) diff --git a/pkg/settlement/swap/chequebook/cheque.go b/pkg/settlement/swap/chequebook/cheque.go index 01e282d5e1c..4ff118c22ec 100644 --- a/pkg/settlement/swap/chequebook/cheque.go +++ b/pkg/settlement/swap/chequebook/cheque.go @@ -11,8 +11,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/crypto/eip712" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto/eip712" ) // Cheque represents a cheque for a SimpleSwap chequebook diff --git a/pkg/settlement/swap/chequebook/cheque_test.go b/pkg/settlement/swap/chequebook/cheque_test.go index dedcd055d14..f0aac83a43c 100644 --- a/pkg/settlement/swap/chequebook/cheque_test.go +++ b/pkg/settlement/swap/chequebook/cheque_test.go @@ -12,10 +12,10 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/crypto/eip712" - signermock "github.com/ethersphere/bee/pkg/crypto/mock" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto/eip712" + signermock "github.com/ethersphere/bee/v2/pkg/crypto/mock" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" ) func TestSignCheque(t *testing.T) { diff --git a/pkg/settlement/swap/chequebook/chequebook.go b/pkg/settlement/swap/chequebook/chequebook.go index 75d8e7876ca..ee04a818f93 100644 --- a/pkg/settlement/swap/chequebook/chequebook.go +++ b/pkg/settlement/swap/chequebook/chequebook.go @@ -13,11 +13,11 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-sw3-abi/sw3abi" ) diff --git a/pkg/settlement/swap/chequebook/chequebook_test.go b/pkg/settlement/swap/chequebook/chequebook_test.go index ca3f705e80e..f9e656cd323 100644 --- a/pkg/settlement/swap/chequebook/chequebook_test.go +++ b/pkg/settlement/swap/chequebook/chequebook_test.go @@ -13,11 +13,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - erc20mock "github.com/ethersphere/bee/pkg/settlement/swap/erc20/mock" - storemock "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/transaction" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + erc20mock "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20/mock" + storemock "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/transaction" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" ) func TestChequebookAddress(t *testing.T) { diff --git a/pkg/settlement/swap/chequebook/chequestore.go b/pkg/settlement/swap/chequebook/chequestore.go index 100e60774fb..8db2e6e3a28 100644 --- a/pkg/settlement/swap/chequebook/chequestore.go +++ b/pkg/settlement/swap/chequebook/chequestore.go @@ -13,9 +13,9 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/transaction" ) const ( diff --git a/pkg/settlement/swap/chequebook/chequestore_test.go b/pkg/settlement/swap/chequebook/chequestore_test.go index be636e67356..57cd138a4f1 100644 --- a/pkg/settlement/swap/chequebook/chequestore_test.go +++ b/pkg/settlement/swap/chequebook/chequestore_test.go @@ -11,9 +11,9 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - storemock "github.com/ethersphere/bee/pkg/statestore/mock" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + storemock "github.com/ethersphere/bee/v2/pkg/statestore/mock" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" ) func TestReceiveCheque(t *testing.T) { diff --git a/pkg/settlement/swap/chequebook/common_test.go b/pkg/settlement/swap/chequebook/common_test.go index ef3b6988c25..717d205819f 100644 --- a/pkg/settlement/swap/chequebook/common_test.go +++ b/pkg/settlement/swap/chequebook/common_test.go @@ -9,7 +9,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" ) type chequeSignerMock struct { diff --git a/pkg/settlement/swap/chequebook/contract.go b/pkg/settlement/swap/chequebook/contract.go index 32ef2eba128..b655c511b84 100644 --- a/pkg/settlement/swap/chequebook/contract.go +++ b/pkg/settlement/swap/chequebook/contract.go @@ -10,7 +10,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction" ) type chequebookContract struct { diff --git a/pkg/settlement/swap/chequebook/factory.go b/pkg/settlement/swap/chequebook/factory.go index 0f8bf3aea2f..27bd38db3b4 100644 --- a/pkg/settlement/swap/chequebook/factory.go +++ b/pkg/settlement/swap/chequebook/factory.go @@ -11,9 +11,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-sw3-abi/sw3abi" "golang.org/x/net/context" ) diff --git a/pkg/settlement/swap/chequebook/factory_test.go b/pkg/settlement/swap/chequebook/factory_test.go index d7223330ea4..16667ec303c 100644 --- a/pkg/settlement/swap/chequebook/factory_test.go +++ b/pkg/settlement/swap/chequebook/factory_test.go @@ -12,11 +12,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/transaction/backendmock" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction/backendmock" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-sw3-abi/sw3abi" ) diff --git a/pkg/settlement/swap/chequebook/init.go b/pkg/settlement/swap/chequebook/init.go index 19bfc3c56b0..de643ecaaf2 100644 --- a/pkg/settlement/swap/chequebook/init.go +++ b/pkg/settlement/swap/chequebook/init.go @@ -13,12 +13,12 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - chaincfg "github.com/ethersphere/bee/pkg/config" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/transaction" + chaincfg "github.com/ethersphere/bee/v2/pkg/config" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/transaction" ) const ( diff --git a/pkg/settlement/swap/chequebook/mock/chequebook.go b/pkg/settlement/swap/chequebook/mock/chequebook.go index 79ce70a9a57..8950046c022 100644 --- a/pkg/settlement/swap/chequebook/mock/chequebook.go +++ b/pkg/settlement/swap/chequebook/mock/chequebook.go @@ -10,7 +10,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" ) // Service is the mock chequebook service. diff --git a/pkg/settlement/swap/chequestore/mock/chequestore.go b/pkg/settlement/swap/chequestore/mock/chequestore.go index 616063053aa..08215cecaf0 100644 --- a/pkg/settlement/swap/chequestore/mock/chequestore.go +++ b/pkg/settlement/swap/chequestore/mock/chequestore.go @@ -9,7 +9,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" ) // Service is the mock chequeStore service. diff --git a/pkg/settlement/swap/erc20/erc20.go b/pkg/settlement/swap/erc20/erc20.go index 510cc43769b..2733fa51887 100644 --- a/pkg/settlement/swap/erc20/erc20.go +++ b/pkg/settlement/swap/erc20/erc20.go @@ -11,9 +11,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-sw3-abi/sw3abi" ) diff --git a/pkg/settlement/swap/erc20/erc20_test.go b/pkg/settlement/swap/erc20/erc20_test.go index a51652ccdd0..e5752aca5df 100644 --- a/pkg/settlement/swap/erc20/erc20_test.go +++ b/pkg/settlement/swap/erc20/erc20_test.go @@ -10,9 +10,9 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-sw3-abi/sw3abi" ) diff --git a/pkg/settlement/swap/erc20/mock/erc20.go b/pkg/settlement/swap/erc20/mock/erc20.go index 8d7652d2fb3..d4f2ac1a5e5 100644 --- a/pkg/settlement/swap/erc20/mock/erc20.go +++ b/pkg/settlement/swap/erc20/mock/erc20.go @@ -10,7 +10,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" ) type Service struct { diff --git a/pkg/settlement/swap/headers/utilities.go b/pkg/settlement/swap/headers/utilities.go index ee9709147a0..a940c45b7c3 100644 --- a/pkg/settlement/swap/headers/utilities.go +++ b/pkg/settlement/swap/headers/utilities.go @@ -8,7 +8,7 @@ import ( "errors" "math/big" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p" ) const ( diff --git a/pkg/settlement/swap/headers/utilities_test.go b/pkg/settlement/swap/headers/utilities_test.go index a16087646e6..0cb074ac00f 100644 --- a/pkg/settlement/swap/headers/utilities_test.go +++ b/pkg/settlement/swap/headers/utilities_test.go @@ -9,8 +9,8 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/p2p" - swap "github.com/ethersphere/bee/pkg/settlement/swap/headers" + "github.com/ethersphere/bee/v2/pkg/p2p" + swap "github.com/ethersphere/bee/v2/pkg/settlement/swap/headers" ) func TestParseSettlementResponseHeaders(t *testing.T) { diff --git a/pkg/settlement/swap/metrics.go b/pkg/settlement/swap/metrics.go index ca1870645d1..d3f50770d54 100644 --- a/pkg/settlement/swap/metrics.go +++ b/pkg/settlement/swap/metrics.go @@ -5,7 +5,7 @@ package swap import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/settlement/swap/mock/swap.go b/pkg/settlement/swap/mock/swap.go index 8007ddd0c3a..2318194f962 100644 --- a/pkg/settlement/swap/mock/swap.go +++ b/pkg/settlement/swap/mock/swap.go @@ -10,10 +10,10 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/settlement/swap" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - "github.com/ethersphere/bee/pkg/settlement/swap/swapprotocol" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/settlement/swap" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/swapprotocol" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type Service struct { diff --git a/pkg/settlement/swap/priceoracle/priceoracle.go b/pkg/settlement/swap/priceoracle/priceoracle.go index 06ab07d5e6c..0ba49e6eff2 100644 --- a/pkg/settlement/swap/priceoracle/priceoracle.go +++ b/pkg/settlement/swap/priceoracle/priceoracle.go @@ -13,9 +13,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-price-oracle-abi/priceoracleabi" ) diff --git a/pkg/settlement/swap/priceoracle/priceoracle_test.go b/pkg/settlement/swap/priceoracle/priceoracle_test.go index 2404d991058..58fa344b675 100644 --- a/pkg/settlement/swap/priceoracle/priceoracle_test.go +++ b/pkg/settlement/swap/priceoracle/priceoracle_test.go @@ -10,10 +10,10 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/settlement/swap/priceoracle" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/priceoracle" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-price-oracle-abi/priceoracleabi" ) diff --git a/pkg/settlement/swap/swap.go b/pkg/settlement/swap/swap.go index a47e70c0bee..4e7f99bd060 100644 --- a/pkg/settlement/swap/swap.go +++ b/pkg/settlement/swap/swap.go @@ -11,13 +11,13 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - "github.com/ethersphere/bee/pkg/settlement" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - "github.com/ethersphere/bee/pkg/settlement/swap/swapprotocol" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + "github.com/ethersphere/bee/v2/pkg/settlement" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/swapprotocol" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // loggerName is the tree path name of the logger for this package. diff --git a/pkg/settlement/swap/swap_test.go b/pkg/settlement/swap/swap_test.go index a7e55198dda..2f4d748740e 100644 --- a/pkg/settlement/swap/swap_test.go +++ b/pkg/settlement/swap/swap_test.go @@ -12,15 +12,15 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/settlement/swap" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - mockchequebook "github.com/ethersphere/bee/pkg/settlement/swap/chequebook/mock" - mockchequestore "github.com/ethersphere/bee/pkg/settlement/swap/chequestore/mock" - "github.com/ethersphere/bee/pkg/settlement/swap/swapprotocol" - mockstore "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/settlement/swap" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + mockchequebook "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook/mock" + mockchequestore "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequestore/mock" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/swapprotocol" + mockstore "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type swapProtocolMock struct { diff --git a/pkg/settlement/swap/swapprotocol/export_test.go b/pkg/settlement/swap/swapprotocol/export_test.go index 46b81c598b9..31fc9e6b79f 100644 --- a/pkg/settlement/swap/swapprotocol/export_test.go +++ b/pkg/settlement/swap/swapprotocol/export_test.go @@ -6,7 +6,7 @@ package swapprotocol import ( "context" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p" ) func (s *Service) Init(ctx context.Context, p p2p.Peer) error { diff --git a/pkg/settlement/swap/swapprotocol/swapprotocol.go b/pkg/settlement/swap/swapprotocol/swapprotocol.go index 58318826d23..45715621208 100644 --- a/pkg/settlement/swap/swapprotocol/swapprotocol.go +++ b/pkg/settlement/swap/swapprotocol/swapprotocol.go @@ -13,14 +13,14 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - swap "github.com/ethersphere/bee/pkg/settlement/swap/headers" - "github.com/ethersphere/bee/pkg/settlement/swap/priceoracle" - "github.com/ethersphere/bee/pkg/settlement/swap/swapprotocol/pb" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + swap "github.com/ethersphere/bee/v2/pkg/settlement/swap/headers" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/priceoracle" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/swapprotocol/pb" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // loggerName is the tree path name of the logger for this package. diff --git a/pkg/settlement/swap/swapprotocol/swapprotocol_test.go b/pkg/settlement/swap/swapprotocol/swapprotocol_test.go index 482de2e0796..45445132466 100644 --- a/pkg/settlement/swap/swapprotocol/swapprotocol_test.go +++ b/pkg/settlement/swap/swapprotocol/swapprotocol_test.go @@ -14,16 +14,16 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - "github.com/ethersphere/bee/pkg/settlement/swap/chequebook" - swapmock "github.com/ethersphere/bee/pkg/settlement/swap/mock" - priceoraclemock "github.com/ethersphere/bee/pkg/settlement/swap/priceoracle/mock" - "github.com/ethersphere/bee/pkg/settlement/swap/swapprotocol" - "github.com/ethersphere/bee/pkg/settlement/swap/swapprotocol/pb" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook" + swapmock "github.com/ethersphere/bee/v2/pkg/settlement/swap/mock" + priceoraclemock "github.com/ethersphere/bee/v2/pkg/settlement/swap/priceoracle/mock" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/swapprotocol" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/swapprotocol/pb" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestEmitCheques(t *testing.T) { diff --git a/pkg/sharky/metrics.go b/pkg/sharky/metrics.go index 8da4ed99163..53db4675b06 100644 --- a/pkg/sharky/metrics.go +++ b/pkg/sharky/metrics.go @@ -5,7 +5,7 @@ package sharky import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/sharky/recovery_test.go b/pkg/sharky/recovery_test.go index 3cd96481231..1cc7ae3d55e 100644 --- a/pkg/sharky/recovery_test.go +++ b/pkg/sharky/recovery_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/sharky" ) func TestMissingShard(t *testing.T) { diff --git a/pkg/sharky/shard_test.go b/pkg/sharky/shard_test.go index cb85607d488..567a0cf9ad3 100644 --- a/pkg/sharky/shard_test.go +++ b/pkg/sharky/shard_test.go @@ -8,7 +8,7 @@ import ( "math" "testing" - "github.com/ethersphere/bee/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/sharky" ) func TestLocationSerialization(t *testing.T) { diff --git a/pkg/sharky/sharky_test.go b/pkg/sharky/sharky_test.go index 8ae75f5b9ca..1e3aadd78b4 100644 --- a/pkg/sharky/sharky_test.go +++ b/pkg/sharky/sharky_test.go @@ -18,7 +18,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/sharky" "golang.org/x/sync/errgroup" ) diff --git a/pkg/shed/db_test.go b/pkg/shed/db_test.go index 754f133a1a7..7bed4610504 100644 --- a/pkg/shed/db_test.go +++ b/pkg/shed/db_test.go @@ -19,7 +19,7 @@ package shed import ( "testing" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) // TestNewDB constructs a new DB diff --git a/pkg/shed/example_store_test.go b/pkg/shed/example_store_test.go index fd8cae0f53a..911fe389d2a 100644 --- a/pkg/shed/example_store_test.go +++ b/pkg/shed/example_store_test.go @@ -25,10 +25,10 @@ import ( "log" "time" - shed2 "github.com/ethersphere/bee/pkg/shed" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/swarm" + shed2 "github.com/ethersphere/bee/v2/pkg/shed" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/syndtr/goleveldb/leveldb" ) diff --git a/pkg/shed/metrics.go b/pkg/shed/metrics.go index e922e39594e..58820407c9d 100644 --- a/pkg/shed/metrics.go +++ b/pkg/shed/metrics.go @@ -5,7 +5,7 @@ package shed import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/skippeers/skippeers.go b/pkg/skippeers/skippeers.go index c512e5e0ae8..f89a49364c4 100644 --- a/pkg/skippeers/skippeers.go +++ b/pkg/skippeers/skippeers.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const MaxDuration time.Duration = math.MaxInt64 diff --git a/pkg/skippeers/skippeers_test.go b/pkg/skippeers/skippeers_test.go index a6201deffc3..1f52636b91c 100644 --- a/pkg/skippeers/skippeers_test.go +++ b/pkg/skippeers/skippeers_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/skippeers" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/skippeers" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestPruneExpiresAfter(t *testing.T) { diff --git a/pkg/soc/soc.go b/pkg/soc/soc.go index 00e069f310e..65b44f2e66e 100644 --- a/pkg/soc/soc.go +++ b/pkg/soc/soc.go @@ -10,9 +10,9 @@ import ( "bytes" "errors" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/soc/soc_test.go b/pkg/soc/soc_test.go index e4f6fb4e199..6346242fa1b 100644 --- a/pkg/soc/soc_test.go +++ b/pkg/soc/soc_test.go @@ -12,10 +12,10 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestNew(t *testing.T) { @@ -47,6 +47,41 @@ func TestNew(t *testing.T) { } } +func TestReplica(t *testing.T) { + sig, err := hex.DecodeString("5acd384febc133b7b245e5ddc62d82d2cded9182d2716126cd8844509af65a053deb418208027f548e3e88343af6f84a8772fb3cebc0a1833a0ea7ec0c1348311b") + if err != nil { + t.Fatal(err) + } + + payload := []byte("foo") + ch, err := cac.New(payload) + if err != nil { + t.Fatal(err) + } + + id := make([]byte, swarm.HashSize) + s, err := soc.NewSigned(id, ch, swarm.ReplicasOwner, sig) + if err != nil { + t.Fatal(err) + } + + ch, err = s.Chunk() + if err != nil { + t.Fatal(err) + } + sch, err := soc.FromChunk(swarm.NewChunk(swarm.EmptyAddress, ch.Data())) + if err != nil { + t.Fatal(err) + } + ch, err = sch.Chunk() + if err != nil { + t.Fatal(err) + } + if !soc.Valid(ch) { + t.Fatal("invalid soc chunk") + } +} + func TestNewSigned(t *testing.T) { t.Parallel() diff --git a/pkg/soc/testing/soc.go b/pkg/soc/testing/soc.go index c8449e820ce..e5325f464b1 100644 --- a/pkg/soc/testing/soc.go +++ b/pkg/soc/testing/soc.go @@ -7,10 +7,10 @@ package testing import ( "testing" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // MockSOC defines a mocked SOC with exported fields for easy testing. diff --git a/pkg/soc/validator.go b/pkg/soc/validator.go index db0c388808e..06f2fb72e0a 100644 --- a/pkg/soc/validator.go +++ b/pkg/soc/validator.go @@ -7,7 +7,7 @@ package soc import ( "bytes" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Valid checks if the chunk is a valid single-owner chunk. diff --git a/pkg/soc/validator_test.go b/pkg/soc/validator_test.go index 695d43cc46f..e6913000149 100644 --- a/pkg/soc/validator_test.go +++ b/pkg/soc/validator_test.go @@ -10,10 +10,10 @@ import ( "strings" "testing" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // TestValid verifies that the validator can detect diff --git a/pkg/spinlock/wait_test.go b/pkg/spinlock/wait_test.go index e38aef2e650..090543723b1 100644 --- a/pkg/spinlock/wait_test.go +++ b/pkg/spinlock/wait_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/spinlock" ) func TestWait(t *testing.T) { diff --git a/pkg/statestore/leveldb/leveldb.go b/pkg/statestore/leveldb/leveldb.go index 65d2cc471ac..08d757ce288 100644 --- a/pkg/statestore/leveldb/leveldb.go +++ b/pkg/statestore/leveldb/leveldb.go @@ -10,8 +10,8 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/storage" ldberr "github.com/syndtr/goleveldb/leveldb/errors" diff --git a/pkg/statestore/leveldb/leveldb_test.go b/pkg/statestore/leveldb/leveldb_test.go index 2e18b9f6b61..fffd43ac5f1 100644 --- a/pkg/statestore/leveldb/leveldb_test.go +++ b/pkg/statestore/leveldb/leveldb_test.go @@ -7,10 +7,10 @@ package leveldb_test import ( "testing" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/statestore/leveldb" - "github.com/ethersphere/bee/pkg/statestore/test" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/statestore/leveldb" + "github.com/ethersphere/bee/v2/pkg/statestore/test" + "github.com/ethersphere/bee/v2/pkg/storage" ) func TestPersistentStateStore(t *testing.T) { diff --git a/pkg/statestore/mock/store.go b/pkg/statestore/mock/store.go index 964c5c4ef61..a3d34542f2c 100644 --- a/pkg/statestore/mock/store.go +++ b/pkg/statestore/mock/store.go @@ -10,7 +10,7 @@ import ( "strings" "sync" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" ) var _ storage.StateStorer = (*store)(nil) diff --git a/pkg/statestore/mock/store_test.go b/pkg/statestore/mock/store_test.go index fc891136376..330261dbba5 100644 --- a/pkg/statestore/mock/store_test.go +++ b/pkg/statestore/mock/store_test.go @@ -7,9 +7,9 @@ package mock_test import ( "testing" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/statestore/test" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/statestore/test" + "github.com/ethersphere/bee/v2/pkg/storage" ) func TestMockStateStore(t *testing.T) { diff --git a/pkg/statestore/storeadapter/migration.go b/pkg/statestore/storeadapter/migration.go index 171f31ccf57..ac5dbd457e2 100644 --- a/pkg/statestore/storeadapter/migration.go +++ b/pkg/statestore/storeadapter/migration.go @@ -7,8 +7,8 @@ package storeadapter import ( "strings" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/migration" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/migration" ) func allSteps() migration.Steps { diff --git a/pkg/statestore/storeadapter/storeadapter.go b/pkg/statestore/storeadapter/storeadapter.go index 03327e83cdd..a923f60a0f8 100644 --- a/pkg/statestore/storeadapter/storeadapter.go +++ b/pkg/statestore/storeadapter/storeadapter.go @@ -10,9 +10,9 @@ import ( "fmt" "strings" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/migration" - "github.com/ethersphere/bee/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/migration" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" ) // stateStoreNamespace is the namespace used for state storage. diff --git a/pkg/statestore/storeadapter/storeadapter_test.go b/pkg/statestore/storeadapter/storeadapter_test.go index 5065a5158da..f90db7b7ce1 100644 --- a/pkg/statestore/storeadapter/storeadapter_test.go +++ b/pkg/statestore/storeadapter/storeadapter_test.go @@ -7,11 +7,11 @@ package storeadapter_test import ( "testing" - "github.com/ethersphere/bee/pkg/statestore/storeadapter" - "github.com/ethersphere/bee/pkg/statestore/test" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" + "github.com/ethersphere/bee/v2/pkg/statestore/storeadapter" + "github.com/ethersphere/bee/v2/pkg/statestore/test" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" ) func TestStateStoreAdapter(t *testing.T) { diff --git a/pkg/statestore/test/store.go b/pkg/statestore/test/store.go index ee5050b8633..10bc9c15c83 100644 --- a/pkg/statestore/test/store.go +++ b/pkg/statestore/test/store.go @@ -10,7 +10,7 @@ import ( "strings" "testing" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" ) const ( diff --git a/pkg/status/internal/pb/status.pb.go b/pkg/status/internal/pb/status.pb.go index a4f6ecf2ba5..868cc0f11e0 100644 --- a/pkg/status/internal/pb/status.pb.go +++ b/pkg/status/internal/pb/status.pb.go @@ -64,14 +64,15 @@ var xxx_messageInfo_Get proto.InternalMessageInfo // the appropriate values that are a snapshot of the current state // of the running node. type Snapshot struct { - ReserveSize uint64 `protobuf:"varint,1,opt,name=ReserveSize,proto3" json:"ReserveSize,omitempty"` - PullsyncRate float64 `protobuf:"fixed64,2,opt,name=PullsyncRate,proto3" json:"PullsyncRate,omitempty"` - StorageRadius uint32 `protobuf:"varint,3,opt,name=StorageRadius,proto3" json:"StorageRadius,omitempty"` - ConnectedPeers uint64 `protobuf:"varint,4,opt,name=ConnectedPeers,proto3" json:"ConnectedPeers,omitempty"` - NeighborhoodSize uint64 `protobuf:"varint,5,opt,name=NeighborhoodSize,proto3" json:"NeighborhoodSize,omitempty"` - BeeMode string `protobuf:"bytes,6,opt,name=BeeMode,proto3" json:"BeeMode,omitempty"` - BatchCommitment uint64 `protobuf:"varint,7,opt,name=BatchCommitment,proto3" json:"BatchCommitment,omitempty"` - IsReachable bool `protobuf:"varint,8,opt,name=IsReachable,proto3" json:"IsReachable,omitempty"` + ReserveSize uint64 `protobuf:"varint,1,opt,name=ReserveSize,proto3" json:"ReserveSize,omitempty"` + PullsyncRate float64 `protobuf:"fixed64,2,opt,name=PullsyncRate,proto3" json:"PullsyncRate,omitempty"` + StorageRadius uint32 `protobuf:"varint,3,opt,name=StorageRadius,proto3" json:"StorageRadius,omitempty"` + ConnectedPeers uint64 `protobuf:"varint,4,opt,name=ConnectedPeers,proto3" json:"ConnectedPeers,omitempty"` + NeighborhoodSize uint64 `protobuf:"varint,5,opt,name=NeighborhoodSize,proto3" json:"NeighborhoodSize,omitempty"` + BeeMode string `protobuf:"bytes,6,opt,name=BeeMode,proto3" json:"BeeMode,omitempty"` + BatchCommitment uint64 `protobuf:"varint,7,opt,name=BatchCommitment,proto3" json:"BatchCommitment,omitempty"` + IsReachable bool `protobuf:"varint,8,opt,name=IsReachable,proto3" json:"IsReachable,omitempty"` + ReserveSizeWithinRadius uint64 `protobuf:"varint,9,opt,name=ReserveSizeWithinRadius,proto3" json:"ReserveSizeWithinRadius,omitempty"` } func (m *Snapshot) Reset() { *m = Snapshot{} } @@ -163,6 +164,13 @@ func (m *Snapshot) GetIsReachable() bool { return false } +func (m *Snapshot) GetReserveSizeWithinRadius() uint64 { + if m != nil { + return m.ReserveSizeWithinRadius + } + return 0 +} + func init() { proto.RegisterType((*Get)(nil), "status.Get") proto.RegisterType((*Snapshot)(nil), "status.Snapshot") @@ -171,25 +179,26 @@ func init() { func init() { proto.RegisterFile("status.proto", fileDescriptor_dfe4fce6682daf5b) } var fileDescriptor_dfe4fce6682daf5b = []byte{ - // 279 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0xd0, 0xc1, 0x4a, 0xf3, 0x40, - 0x10, 0x07, 0xf0, 0x6e, 0xda, 0xa6, 0xf9, 0xf6, 0x6b, 0x55, 0xf6, 0xb4, 0x07, 0x59, 0x96, 0x20, - 0xb2, 0x78, 0xf0, 0xe2, 0x1b, 0xa4, 0x07, 0xf1, 0xa0, 0x94, 0xcd, 0xcd, 0xdb, 0x26, 0x19, 0x9a, - 0x40, 0x92, 0x0d, 0xd9, 0x89, 0xa0, 0x4f, 0xe1, 0xa3, 0xf8, 0x18, 0x1e, 0x7b, 0xf4, 0x28, 0xc9, - 0x8b, 0x88, 0x11, 0xa1, 0xad, 0xc7, 0xff, 0x8f, 0x61, 0x66, 0xf8, 0xd3, 0xa5, 0x43, 0x83, 0x9d, - 0xbb, 0x6e, 0x5a, 0x8b, 0x96, 0xf9, 0x3f, 0x29, 0x9c, 0xd3, 0xe9, 0x2d, 0x60, 0xf8, 0xe6, 0xd1, - 0x20, 0xae, 0x4d, 0xe3, 0x72, 0x8b, 0x4c, 0xd2, 0xff, 0x1a, 0x1c, 0xb4, 0x4f, 0x10, 0x17, 0x2f, - 0xc0, 0x89, 0x24, 0x6a, 0xa6, 0xf7, 0x89, 0x85, 0x74, 0xb9, 0xe9, 0xca, 0xd2, 0x3d, 0xd7, 0xa9, - 0x36, 0x08, 0xdc, 0x93, 0x44, 0x11, 0x7d, 0x60, 0xec, 0x82, 0xae, 0x62, 0xb4, 0xad, 0xd9, 0x82, - 0x36, 0x59, 0xd1, 0x39, 0x3e, 0x95, 0x44, 0xad, 0xf4, 0x21, 0xb2, 0x4b, 0x7a, 0xb2, 0xb6, 0x75, - 0x0d, 0x29, 0x42, 0xb6, 0x01, 0x68, 0x1d, 0x9f, 0x8d, 0xe7, 0x8e, 0x94, 0x5d, 0xd1, 0xb3, 0x07, - 0x28, 0xb6, 0x79, 0x62, 0xdb, 0xdc, 0xda, 0x6c, 0x7c, 0x6c, 0x3e, 0x4e, 0xfe, 0x71, 0xc6, 0xe9, - 0x22, 0x02, 0xb8, 0xb7, 0x19, 0x70, 0x5f, 0x12, 0xf5, 0x4f, 0xff, 0x46, 0xa6, 0xe8, 0x69, 0x64, - 0x30, 0xcd, 0xd7, 0xb6, 0xaa, 0x0a, 0xac, 0xa0, 0x46, 0xbe, 0x18, 0x97, 0x1c, 0xf3, 0x77, 0x07, - 0x77, 0x4e, 0x83, 0x49, 0x73, 0x93, 0x94, 0xc0, 0x03, 0x49, 0x54, 0xa0, 0xf7, 0x29, 0x3a, 0x7f, - 0xef, 0x05, 0xd9, 0xf5, 0x82, 0x7c, 0xf6, 0x82, 0xbc, 0x0e, 0x62, 0xb2, 0x1b, 0xc4, 0xe4, 0x63, - 0x10, 0x93, 0x47, 0xaf, 0x49, 0x12, 0x7f, 0xac, 0xf9, 0xe6, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x64, - 0x9a, 0xeb, 0xde, 0x76, 0x01, 0x00, 0x00, + // 298 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x3f, 0x4b, 0x73, 0x31, + 0x14, 0xc6, 0x9b, 0xfe, 0x6f, 0xde, 0xf6, 0x55, 0xb2, 0x98, 0x41, 0x42, 0x28, 0x22, 0xc1, 0xc1, + 0xc5, 0xc5, 0xb9, 0x1d, 0xc4, 0x41, 0x29, 0xe9, 0x20, 0xb8, 0xe5, 0xde, 0x7b, 0x68, 0x02, 0x6d, + 0x52, 0x6e, 0x4e, 0x05, 0xfd, 0x14, 0x7e, 0x2c, 0xc7, 0x8e, 0x8e, 0xd2, 0x6e, 0x7e, 0x0a, 0x31, + 0x2a, 0xdc, 0x56, 0x1c, 0x9f, 0xdf, 0x39, 0x3c, 0xe7, 0x9c, 0xe7, 0xd0, 0x7e, 0x44, 0x83, 0xab, + 0x78, 0xbe, 0x2c, 0x03, 0x06, 0xd6, 0xfe, 0x52, 0xc3, 0x16, 0x6d, 0x5c, 0x01, 0x0e, 0xdf, 0xeb, + 0xb4, 0x3b, 0xf5, 0x66, 0x19, 0x6d, 0x40, 0x26, 0xe9, 0x3f, 0x0d, 0x11, 0xca, 0x07, 0x98, 0xba, + 0x27, 0xe0, 0x44, 0x12, 0xd5, 0xd4, 0x55, 0xc4, 0x86, 0xb4, 0x3f, 0x59, 0xcd, 0xe7, 0xf1, 0xd1, + 0xe7, 0xda, 0x20, 0xf0, 0xba, 0x24, 0x8a, 0xe8, 0x1d, 0xc6, 0x4e, 0xe8, 0x60, 0x8a, 0xa1, 0x34, + 0x33, 0xd0, 0xa6, 0x70, 0xab, 0xc8, 0x1b, 0x92, 0xa8, 0x81, 0xde, 0x85, 0xec, 0x94, 0xfe, 0x1f, + 0x07, 0xef, 0x21, 0x47, 0x28, 0x26, 0x00, 0x65, 0xe4, 0xcd, 0x34, 0x6e, 0x8f, 0xb2, 0x33, 0x7a, + 0x78, 0x0b, 0x6e, 0x66, 0xb3, 0x50, 0xda, 0x10, 0x8a, 0xb4, 0x58, 0x2b, 0x75, 0xfe, 0xe2, 0x8c, + 0xd3, 0xce, 0x08, 0xe0, 0x26, 0x14, 0xc0, 0xdb, 0x92, 0xa8, 0x9e, 0xfe, 0x91, 0x4c, 0xd1, 0x83, + 0x91, 0xc1, 0xdc, 0x8e, 0xc3, 0x62, 0xe1, 0x70, 0x01, 0x1e, 0x79, 0x27, 0x99, 0xec, 0xe3, 0xcf, + 0x0c, 0xae, 0xa3, 0x06, 0x93, 0x5b, 0x93, 0xcd, 0x81, 0x77, 0x25, 0x51, 0x5d, 0x5d, 0x45, 0xec, + 0x92, 0x1e, 0x55, 0x22, 0xb9, 0x73, 0x68, 0x9d, 0xff, 0xbe, 0xb4, 0x97, 0x3c, 0xff, 0x2a, 0x8f, + 0x8e, 0x5f, 0x36, 0x82, 0xac, 0x37, 0x82, 0xbc, 0x6d, 0x04, 0x79, 0xde, 0x8a, 0xda, 0x7a, 0x2b, + 0x6a, 0xaf, 0x5b, 0x51, 0xbb, 0xaf, 0x2f, 0xb3, 0xac, 0x9d, 0x1e, 0x74, 0xf1, 0x11, 0x00, 0x00, + 0xff, 0xff, 0xb8, 0xde, 0xcb, 0x07, 0xb0, 0x01, 0x00, 0x00, } func (m *Get) Marshal() (dAtA []byte, err error) { @@ -235,6 +244,11 @@ func (m *Snapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ReserveSizeWithinRadius != 0 { + i = encodeVarintStatus(dAtA, i, uint64(m.ReserveSizeWithinRadius)) + i-- + dAtA[i] = 0x48 + } if m.IsReachable { i-- if m.IsReachable { @@ -337,6 +351,9 @@ func (m *Snapshot) Size() (n int) { if m.IsReachable { n += 2 } + if m.ReserveSizeWithinRadius != 0 { + n += 1 + sovStatus(uint64(m.ReserveSizeWithinRadius)) + } return n } @@ -586,6 +603,25 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { } } m.IsReachable = bool(v != 0) + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReserveSizeWithinRadius", wireType) + } + m.ReserveSizeWithinRadius = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStatus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReserveSizeWithinRadius |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipStatus(dAtA[iNdEx:]) diff --git a/pkg/status/internal/pb/status.proto b/pkg/status/internal/pb/status.proto index f4cecd47088..a62eb327433 100644 --- a/pkg/status/internal/pb/status.proto +++ b/pkg/status/internal/pb/status.proto @@ -23,4 +23,5 @@ message Snapshot { string BeeMode = 6; uint64 BatchCommitment = 7; bool IsReachable = 8; + uint64 ReserveSizeWithinRadius = 9; } diff --git a/pkg/status/status.go b/pkg/status/status.go index 93a498bb20a..a8321dc98bc 100644 --- a/pkg/status/status.go +++ b/pkg/status/status.go @@ -8,13 +8,13 @@ import ( "context" "fmt" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/status/internal/pb" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/status/internal/pb" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" ) // loggerName is the tree path name of the logger for this package. @@ -37,6 +37,7 @@ type SyncReporter interface { // Reserve defines the reserve storage related information required. type Reserve interface { ReserveSize() int + ReserveSizeWithinRadius() uint64 StorageRadius() uint8 } @@ -79,16 +80,18 @@ func NewService( // LocalSnapshot returns the current status snapshot of this node. func (s *Service) LocalSnapshot() (*Snapshot, error) { var ( - storageRadius uint8 - syncRate float64 - reserveSize uint64 - connectedPeers uint64 - neighborhoodSize uint64 + storageRadius uint8 + syncRate float64 + reserveSize uint64 + reserveSizeWithinRadius uint64 + connectedPeers uint64 + neighborhoodSize uint64 ) if s.reserve != nil { storageRadius = s.reserve.StorageRadius() reserveSize = uint64(s.reserve.ReserveSize()) + reserveSizeWithinRadius = s.reserve.ReserveSizeWithinRadius() } if s.sync != nil { @@ -115,14 +118,15 @@ func (s *Service) LocalSnapshot() (*Snapshot, error) { } return &Snapshot{ - BeeMode: s.beeMode, - ReserveSize: reserveSize, - PullsyncRate: syncRate, - StorageRadius: uint32(storageRadius), - ConnectedPeers: connectedPeers, - NeighborhoodSize: neighborhoodSize, - BatchCommitment: commitment, - IsReachable: s.topologyDriver.IsReachable(), + BeeMode: s.beeMode, + ReserveSize: reserveSize, + ReserveSizeWithinRadius: reserveSizeWithinRadius, + PullsyncRate: syncRate, + StorageRadius: uint32(storageRadius), + ConnectedPeers: connectedPeers, + NeighborhoodSize: neighborhoodSize, + BatchCommitment: commitment, + IsReachable: s.topologyDriver.IsReachable(), }, nil } diff --git a/pkg/status/status_test.go b/pkg/status/status_test.go index 0bca393ee7d..927ddb09ca5 100644 --- a/pkg/status/status_test.go +++ b/pkg/status/status_test.go @@ -9,14 +9,14 @@ import ( "context" "testing" - "github.com/ethersphere/bee/pkg/api" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p/protobuf" - "github.com/ethersphere/bee/pkg/p2p/streamtest" - "github.com/ethersphere/bee/pkg/status" - "github.com/ethersphere/bee/pkg/status/internal/pb" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/api" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p/protobuf" + "github.com/ethersphere/bee/v2/pkg/p2p/streamtest" + "github.com/ethersphere/bee/v2/pkg/status" + "github.com/ethersphere/bee/v2/pkg/status/internal/pb" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" "github.com/google/go-cmp/cmp" ) @@ -191,3 +191,6 @@ func (m *statusSnapshotMock) SyncRate() float64 { return m.Snapshot.Pu func (m *statusSnapshotMock) ReserveSize() int { return int(m.Snapshot.ReserveSize) } func (m *statusSnapshotMock) StorageRadius() uint8 { return uint8(m.Snapshot.StorageRadius) } func (m *statusSnapshotMock) Commitment() (uint64, error) { return m.Snapshot.BatchCommitment, nil } +func (m *statusSnapshotMock) ReserveSizeWithinRadius() uint64 { + return m.Snapshot.ReserveSizeWithinRadius +} diff --git a/pkg/steward/mock/steward.go b/pkg/steward/mock/steward.go index 4394ca301af..b8cee8b3588 100644 --- a/pkg/steward/mock/steward.go +++ b/pkg/steward/mock/steward.go @@ -7,8 +7,8 @@ package mock import ( "context" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Steward represents steward.Interface mock. diff --git a/pkg/steward/steward.go b/pkg/steward/steward.go index 73b3d17b87f..9c099dd3624 100644 --- a/pkg/steward/steward.go +++ b/pkg/steward/steward.go @@ -11,13 +11,13 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/retrieval" - "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/traversal" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/retrieval" + "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/traversal" ) type Interface interface { diff --git a/pkg/steward/steward_test.go b/pkg/steward/steward_test.go index fe3ccd05ba9..049fa581ae1 100644 --- a/pkg/steward/steward_test.go +++ b/pkg/steward/steward_test.go @@ -14,14 +14,14 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - "github.com/ethersphere/bee/pkg/file/redundancy" - postagetesting "github.com/ethersphere/bee/pkg/postage/mock" - "github.com/ethersphere/bee/pkg/steward" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + "github.com/ethersphere/bee/v2/pkg/file/redundancy" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/mock" + "github.com/ethersphere/bee/v2/pkg/steward" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type counter struct { diff --git a/pkg/storage/cache/cache.go b/pkg/storage/cache/cache.go index 880a408f7aa..1c659146f18 100644 --- a/pkg/storage/cache/cache.go +++ b/pkg/storage/cache/cache.go @@ -7,8 +7,8 @@ package cache import ( "errors" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" lru "github.com/hashicorp/golang-lru/v2" ) diff --git a/pkg/storage/cache/cache_test.go b/pkg/storage/cache/cache_test.go index 9220e93691d..6528f156785 100644 --- a/pkg/storage/cache/cache_test.go +++ b/pkg/storage/cache/cache_test.go @@ -7,9 +7,9 @@ package cache_test import ( "testing" - "github.com/ethersphere/bee/pkg/storage/cache" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" - "github.com/ethersphere/bee/pkg/storage/storagetest" + "github.com/ethersphere/bee/v2/pkg/storage/cache" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" ) func TestCache(t *testing.T) { diff --git a/pkg/storage/cache/metrics.go b/pkg/storage/cache/metrics.go index 9492829ebc3..ec9a6051786 100644 --- a/pkg/storage/cache/metrics.go +++ b/pkg/storage/cache/metrics.go @@ -5,7 +5,7 @@ package cache import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/storage/chunkstore.go b/pkg/storage/chunkstore.go index aec30e6afc9..4d2e5d78d4a 100644 --- a/pkg/storage/chunkstore.go +++ b/pkg/storage/chunkstore.go @@ -9,7 +9,7 @@ import ( "fmt" "io" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Getter is the interface that wraps the basic Get method. diff --git a/pkg/storage/inmemchunkstore/inmemchunkstore.go b/pkg/storage/inmemchunkstore/inmemchunkstore.go index 0f225db0608..f1fd629db41 100644 --- a/pkg/storage/inmemchunkstore/inmemchunkstore.go +++ b/pkg/storage/inmemchunkstore/inmemchunkstore.go @@ -8,8 +8,8 @@ import ( "context" "sync" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type ChunkStore struct { diff --git a/pkg/storage/inmemchunkstore/inmemchunkstore_test.go b/pkg/storage/inmemchunkstore/inmemchunkstore_test.go index 1835fcc02a8..21d48b4687d 100644 --- a/pkg/storage/inmemchunkstore/inmemchunkstore_test.go +++ b/pkg/storage/inmemchunkstore/inmemchunkstore_test.go @@ -7,8 +7,8 @@ package inmemchunkstore_test import ( "testing" - inmem "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/storage/storagetest" + inmem "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" ) func TestChunkStore(t *testing.T) { diff --git a/pkg/storage/inmemchunkstore/transaction.go b/pkg/storage/inmemchunkstore/transaction.go index 5afaeef9386..f4ec18abc7e 100644 --- a/pkg/storage/inmemchunkstore/transaction.go +++ b/pkg/storage/inmemchunkstore/transaction.go @@ -9,8 +9,8 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var _ storage.TxChunkStore = (*TxChunkStore)(nil) diff --git a/pkg/storage/inmemchunkstore/transaction_test.go b/pkg/storage/inmemchunkstore/transaction_test.go index 646298075f7..20919731f51 100644 --- a/pkg/storage/inmemchunkstore/transaction_test.go +++ b/pkg/storage/inmemchunkstore/transaction_test.go @@ -7,8 +7,8 @@ package inmemchunkstore_test import ( "testing" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/storage/storagetest" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" ) func TestTxChunkStore(t *testing.T) { diff --git a/pkg/storage/inmemstore/inmembatch.go b/pkg/storage/inmemstore/inmembatch.go index 309316e3c6f..7188f6d7e71 100644 --- a/pkg/storage/inmemstore/inmembatch.go +++ b/pkg/storage/inmemstore/inmembatch.go @@ -9,7 +9,7 @@ import ( "fmt" "sync" - storage "github.com/ethersphere/bee/pkg/storage" + storage "github.com/ethersphere/bee/v2/pkg/storage" ) // batchOp represents a batch operations. diff --git a/pkg/storage/inmemstore/inmemstore.go b/pkg/storage/inmemstore/inmemstore.go index 38c34af60bd..b0052602aa1 100644 --- a/pkg/storage/inmemstore/inmemstore.go +++ b/pkg/storage/inmemstore/inmemstore.go @@ -11,7 +11,7 @@ import ( "sync" "github.com/armon/go-radix" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" ) const ( diff --git a/pkg/storage/inmemstore/inmemstore_test.go b/pkg/storage/inmemstore/inmemstore_test.go index cf79c9f2c7c..452daec1a55 100644 --- a/pkg/storage/inmemstore/inmemstore_test.go +++ b/pkg/storage/inmemstore/inmemstore_test.go @@ -7,8 +7,8 @@ package inmemstore_test import ( "testing" - inmem "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storage/storagetest" + inmem "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" ) func TestStore(t *testing.T) { diff --git a/pkg/storage/inmemstore/transaction.go b/pkg/storage/inmemstore/transaction.go index b0d600444bc..1415143b41c 100644 --- a/pkg/storage/inmemstore/transaction.go +++ b/pkg/storage/inmemstore/transaction.go @@ -10,7 +10,7 @@ import ( "fmt" "sync" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" ) var ( diff --git a/pkg/storage/inmemstore/transaction_test.go b/pkg/storage/inmemstore/transaction_test.go index 552088fa311..a9eabe36d56 100644 --- a/pkg/storage/inmemstore/transaction_test.go +++ b/pkg/storage/inmemstore/transaction_test.go @@ -7,8 +7,8 @@ package inmemstore_test import ( "testing" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storage/storagetest" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" ) func TestTxStore(t *testing.T) { diff --git a/pkg/storage/leveldbstore/batch.go b/pkg/storage/leveldbstore/batch.go index 96bbf2dbf49..64b72a97816 100644 --- a/pkg/storage/leveldbstore/batch.go +++ b/pkg/storage/leveldbstore/batch.go @@ -9,7 +9,7 @@ import ( "fmt" "sync" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" ldb "github.com/syndtr/goleveldb/leveldb" ) diff --git a/pkg/storage/leveldbstore/recovery.go b/pkg/storage/leveldbstore/recovery.go index f52701275f0..6d3e04ee91d 100644 --- a/pkg/storage/leveldbstore/recovery.go +++ b/pkg/storage/leveldbstore/recovery.go @@ -7,8 +7,8 @@ package leveldbstore import ( "fmt" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/storage" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/opt" ) diff --git a/pkg/storage/leveldbstore/recovery_test.go b/pkg/storage/leveldbstore/recovery_test.go index f3d504f6e62..84bd9075d1a 100644 --- a/pkg/storage/leveldbstore/recovery_test.go +++ b/pkg/storage/leveldbstore/recovery_test.go @@ -11,9 +11,9 @@ import ( "slices" "testing" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" - "github.com/ethersphere/bee/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storage/leveldbstore/store.go b/pkg/storage/leveldbstore/store.go index 30f203d3bfc..bf410d54c00 100644 --- a/pkg/storage/leveldbstore/store.go +++ b/pkg/storage/leveldbstore/store.go @@ -9,7 +9,7 @@ import ( "fmt" "strings" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" "github.com/syndtr/goleveldb/leveldb" ldbErrors "github.com/syndtr/goleveldb/leveldb/errors" "github.com/syndtr/goleveldb/leveldb/iterator" diff --git a/pkg/storage/leveldbstore/store_test.go b/pkg/storage/leveldbstore/store_test.go index 53fffc01a44..7e7bc809213 100644 --- a/pkg/storage/leveldbstore/store_test.go +++ b/pkg/storage/leveldbstore/store_test.go @@ -7,8 +7,8 @@ package leveldbstore_test import ( "testing" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" - "github.com/ethersphere/bee/pkg/storage/storagetest" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" "github.com/syndtr/goleveldb/leveldb/opt" ) diff --git a/pkg/storage/leveldbstore/transaction.go b/pkg/storage/leveldbstore/transaction.go index 9a18b904ff2..c24259640a9 100644 --- a/pkg/storage/leveldbstore/transaction.go +++ b/pkg/storage/leveldbstore/transaction.go @@ -10,8 +10,8 @@ import ( "fmt" "sync" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" "github.com/google/uuid" "github.com/syndtr/goleveldb/leveldb" ) diff --git a/pkg/storage/leveldbstore/transaction_test.go b/pkg/storage/leveldbstore/transaction_test.go index cc18e8f8632..e965ef0dc7a 100644 --- a/pkg/storage/leveldbstore/transaction_test.go +++ b/pkg/storage/leveldbstore/transaction_test.go @@ -7,8 +7,8 @@ package leveldbstore_test import ( "testing" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" - "github.com/ethersphere/bee/pkg/storage/storagetest" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" ) func TestTxStore(t *testing.T) { diff --git a/pkg/storage/metrics.go b/pkg/storage/metrics.go index 00c90e8b361..f1a83b179d7 100644 --- a/pkg/storage/metrics.go +++ b/pkg/storage/metrics.go @@ -9,8 +9,8 @@ import ( "errors" "time" - m "github.com/ethersphere/bee/pkg/metrics" - "github.com/ethersphere/bee/pkg/swarm" + m "github.com/ethersphere/bee/v2/pkg/metrics" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/storage/migration/index.go b/pkg/storage/migration/index.go index bc08d6f2d2d..bb4df67f96f 100644 --- a/pkg/storage/migration/index.go +++ b/pkg/storage/migration/index.go @@ -8,7 +8,7 @@ import ( "errors" "fmt" - storage "github.com/ethersphere/bee/pkg/storage" + storage "github.com/ethersphere/bee/v2/pkg/storage" ) var ErrItemIDShouldntChange = errors.New("item.ID shouldn't be changing after update") diff --git a/pkg/storage/migration/index_test.go b/pkg/storage/migration/index_test.go index cf2e0ab8ded..935a50b9b50 100644 --- a/pkg/storage/migration/index_test.go +++ b/pkg/storage/migration/index_test.go @@ -9,9 +9,9 @@ import ( "reflect" "testing" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storage/migration" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storage/migration" ) func TestNewStepOnIndex(t *testing.T) { diff --git a/pkg/storage/migration/migration.go b/pkg/storage/migration/migration.go index 528831f0da8..fcbd154fb34 100644 --- a/pkg/storage/migration/migration.go +++ b/pkg/storage/migration/migration.go @@ -10,8 +10,8 @@ import ( "fmt" "sort" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" ) type ( diff --git a/pkg/storage/migration/migration_test.go b/pkg/storage/migration/migration_test.go index c1de785f7d3..5daa371fd39 100644 --- a/pkg/storage/migration/migration_test.go +++ b/pkg/storage/migration/migration_test.go @@ -12,11 +12,11 @@ import ( "strconv" "testing" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storage/migration" - "github.com/ethersphere/bee/pkg/storage/storagetest" - "github.com/ethersphere/bee/pkg/storage/storageutil" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storage/migration" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" ) var ( diff --git a/pkg/storage/migration/steps_chain.go b/pkg/storage/migration/steps_chain.go index 96f8835b614..1b3ddc52301 100644 --- a/pkg/storage/migration/steps_chain.go +++ b/pkg/storage/migration/steps_chain.go @@ -4,7 +4,7 @@ package migration -import storage "github.com/ethersphere/bee/pkg/storage" +import storage "github.com/ethersphere/bee/v2/pkg/storage" // NewStepsChain returns new StepFn which combines all supplied StepFn // into single StepFn. diff --git a/pkg/storage/migration/steps_chain_test.go b/pkg/storage/migration/steps_chain_test.go index 4488d6805b0..f591440ac5a 100644 --- a/pkg/storage/migration/steps_chain_test.go +++ b/pkg/storage/migration/steps_chain_test.go @@ -7,9 +7,9 @@ package migration_test import ( "testing" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storage/migration" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storage/migration" ) func TestNewStepsChain(t *testing.T) { diff --git a/pkg/storage/repository.go b/pkg/storage/repository.go index f681ee76d88..c189cc3bfe4 100644 --- a/pkg/storage/repository.go +++ b/pkg/storage/repository.go @@ -9,8 +9,8 @@ import ( "errors" "time" - m "github.com/ethersphere/bee/pkg/metrics" - "github.com/ethersphere/bee/pkg/swarm" + m "github.com/ethersphere/bee/v2/pkg/metrics" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/storage/storagetest/batch.go b/pkg/storage/storagetest/batch.go index b144bc04908..c26986f42b5 100644 --- a/pkg/storage/storagetest/batch.go +++ b/pkg/storage/storagetest/batch.go @@ -9,7 +9,7 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storage/storagetest/benchmark.go b/pkg/storage/storagetest/benchmark.go index 09cd3241ecb..015392ff7c5 100644 --- a/pkg/storage/storagetest/benchmark.go +++ b/pkg/storage/storagetest/benchmark.go @@ -16,9 +16,9 @@ import ( "testing" "time" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/storage/storagetest/chunkstore.go b/pkg/storage/storagetest/chunkstore.go index 767c4a2a0c4..996d7977f06 100644 --- a/pkg/storage/storagetest/chunkstore.go +++ b/pkg/storage/storagetest/chunkstore.go @@ -9,10 +9,10 @@ import ( "errors" "testing" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - storage "github.com/ethersphere/bee/pkg/storage" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/swarm" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + storage "github.com/ethersphere/bee/v2/pkg/storage" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // TestChunkStore runs a correctness test suite on a given ChunkStore. diff --git a/pkg/storage/storagetest/storage.go b/pkg/storage/storagetest/storage.go index 55f21ad156e..d270bbfc357 100644 --- a/pkg/storage/storagetest/storage.go +++ b/pkg/storage/storagetest/storage.go @@ -18,10 +18,10 @@ import ( "sync" "testing" - "github.com/ethersphere/bee/pkg/encryption" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/encryption" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storage/storagetest/transaction.go b/pkg/storage/storagetest/transaction.go index 1275bedb7d9..8c8dde7cad0 100644 --- a/pkg/storage/storagetest/transaction.go +++ b/pkg/storage/storagetest/transaction.go @@ -12,10 +12,10 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storage/testing/chunk.go b/pkg/storage/testing/chunk.go index 51623f0b925..f51c1079974 100644 --- a/pkg/storage/testing/chunk.go +++ b/pkg/storage/testing/chunk.go @@ -21,12 +21,12 @@ import ( "crypto/rand" "testing" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/crypto" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) // GenerateTestRandomChunk generates a valid content addressed chunk. diff --git a/pkg/storage/transaction.go b/pkg/storage/transaction.go index 1268e45da86..ad7d829d3c0 100644 --- a/pkg/storage/transaction.go +++ b/pkg/storage/transaction.go @@ -11,7 +11,7 @@ import ( "sync" "sync/atomic" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // ErrTxDone is returned by any operation that is performed on diff --git a/pkg/storage/transaction_test.go b/pkg/storage/transaction_test.go index a03df20a5dc..265e777bb68 100644 --- a/pkg/storage/transaction_test.go +++ b/pkg/storage/transaction_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" ) func TestTxState(t *testing.T) { diff --git a/pkg/storageincentives/agent.go b/pkg/storageincentives/agent.go index 2bd0bf0ffb4..b71a77c3dff 100644 --- a/pkg/storageincentives/agent.go +++ b/pkg/storageincentives/agent.go @@ -16,17 +16,17 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/postage/postagecontract" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storageincentives/redistribution" - "github.com/ethersphere/bee/pkg/storageincentives/staking" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage/postagecontract" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storageincentives/redistribution" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/transaction" ) const loggerName = "storageincentives" diff --git a/pkg/storageincentives/agent_test.go b/pkg/storageincentives/agent_test.go index fe5bc6a937f..ae078f1a871 100644 --- a/pkg/storageincentives/agent_test.go +++ b/pkg/storageincentives/agent_test.go @@ -14,19 +14,19 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - contractMock "github.com/ethersphere/bee/pkg/postage/postagecontract/mock" - erc20mock "github.com/ethersphere/bee/pkg/settlement/swap/erc20/mock" - statestore "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/storageincentives" - "github.com/ethersphere/bee/pkg/storageincentives/redistribution" - "github.com/ethersphere/bee/pkg/storageincentives/staking/mock" - "github.com/ethersphere/bee/pkg/storer" - resMock "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + contractMock "github.com/ethersphere/bee/v2/pkg/postage/postagecontract/mock" + erc20mock "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20/mock" + statestore "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/storageincentives" + "github.com/ethersphere/bee/v2/pkg/storageincentives/redistribution" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking/mock" + "github.com/ethersphere/bee/v2/pkg/storer" + resMock "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) func TestAgent(t *testing.T) { diff --git a/pkg/storageincentives/events_test.go b/pkg/storageincentives/events_test.go index 6c40fe8fc2e..0ea4547a145 100644 --- a/pkg/storageincentives/events_test.go +++ b/pkg/storageincentives/events_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/storageincentives" + "github.com/ethersphere/bee/v2/pkg/storageincentives" ) func TestClose(t *testing.T) { diff --git a/pkg/storageincentives/metrics.go b/pkg/storageincentives/metrics.go index 28c692cc3af..b376d9d20b2 100644 --- a/pkg/storageincentives/metrics.go +++ b/pkg/storageincentives/metrics.go @@ -5,7 +5,7 @@ package storageincentives import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/storageincentives/proof.go b/pkg/storageincentives/proof.go index ccc04cd935b..86dd115c67e 100644 --- a/pkg/storageincentives/proof.go +++ b/pkg/storageincentives/proof.go @@ -10,13 +10,13 @@ import ( "hash" "math/big" - "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/bmtpool" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storageincentives/redistribution" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/bmtpool" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storageincentives/redistribution" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var errProofCreation = errors.New("reserve commitment hasher: failure in proof creation") diff --git a/pkg/storageincentives/proof_test.go b/pkg/storageincentives/proof_test.go index 1d83309ba24..8b574cadf3d 100644 --- a/pkg/storageincentives/proof_test.go +++ b/pkg/storageincentives/proof_test.go @@ -12,16 +12,16 @@ import ( "math/big" "testing" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/postage" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storageincentives" - "github.com/ethersphere/bee/pkg/storageincentives/redistribution" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/postage" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storageincentives" + "github.com/ethersphere/bee/v2/pkg/storageincentives/redistribution" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storageincentives/redistribution/inclusionproof.go b/pkg/storageincentives/redistribution/inclusionproof.go index b786d1d3001..41e319b9c63 100644 --- a/pkg/storageincentives/redistribution/inclusionproof.go +++ b/pkg/storageincentives/redistribution/inclusionproof.go @@ -8,10 +8,10 @@ import ( "encoding/binary" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type ChunkInclusionProofs struct { diff --git a/pkg/storageincentives/redistribution/redistribution.go b/pkg/storageincentives/redistribution/redistribution.go index 01ddb9195b0..42fa4ee6cf1 100644 --- a/pkg/storageincentives/redistribution/redistribution.go +++ b/pkg/storageincentives/redistribution/redistribution.go @@ -11,10 +11,10 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/transaction" ) const loggerName = "redistributionContract" diff --git a/pkg/storageincentives/redistribution/redistribution_test.go b/pkg/storageincentives/redistribution/redistribution_test.go index 4a8e84b421b..022e88fc3bf 100644 --- a/pkg/storageincentives/redistribution/redistribution_test.go +++ b/pkg/storageincentives/redistribution/redistribution_test.go @@ -15,15 +15,15 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - chaincfg "github.com/ethersphere/bee/pkg/config" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/storageincentives/redistribution" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/transaction" - transactionMock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/abiutil" - "github.com/ethersphere/bee/pkg/util/testutil" + chaincfg "github.com/ethersphere/bee/v2/pkg/config" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/storageincentives/redistribution" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/transaction" + transactionMock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) var redistributionContractABI = abiutil.MustParseABI(chaincfg.Testnet.RedistributionABI) diff --git a/pkg/storageincentives/redistributionstate.go b/pkg/storageincentives/redistributionstate.go index b1f4b60dd03..9929a9e7831 100644 --- a/pkg/storageincentives/redistributionstate.go +++ b/pkg/storageincentives/redistributionstate.go @@ -12,12 +12,12 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/settlement/swap/erc20" - "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20" + "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/transaction" ) const loggerNameNode = "nodestatus" diff --git a/pkg/storageincentives/redistributionstate_test.go b/pkg/storageincentives/redistributionstate_test.go index 9c7f750d64c..063991c31d8 100644 --- a/pkg/storageincentives/redistributionstate_test.go +++ b/pkg/storageincentives/redistributionstate_test.go @@ -11,11 +11,11 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - erc20mock "github.com/ethersphere/bee/pkg/settlement/swap/erc20/mock" - "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/swarm" - transactionmock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/testutil" + erc20mock "github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20/mock" + "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + transactionmock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storageincentives/soc_mine_test.go b/pkg/storageincentives/soc_mine_test.go index d5b93241b21..bdece238f80 100644 --- a/pkg/storageincentives/soc_mine_test.go +++ b/pkg/storageincentives/soc_mine_test.go @@ -15,11 +15,11 @@ import ( "sync" "testing" - "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/swarm" "golang.org/x/sync/errgroup" ) diff --git a/pkg/storageincentives/staking/contract.go b/pkg/storageincentives/staking/contract.go index 128343824a2..f5a340b2b93 100644 --- a/pkg/storageincentives/staking/contract.go +++ b/pkg/storageincentives/staking/contract.go @@ -13,10 +13,10 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-sw3-abi/sw3abi" ) diff --git a/pkg/storageincentives/staking/contract_test.go b/pkg/storageincentives/staking/contract_test.go index 27f9e31ccca..24133631b99 100644 --- a/pkg/storageincentives/staking/contract_test.go +++ b/pkg/storageincentives/staking/contract_test.go @@ -14,12 +14,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - chaincfg "github.com/ethersphere/bee/pkg/config" - "github.com/ethersphere/bee/pkg/storageincentives/staking" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/transaction" - transactionMock "github.com/ethersphere/bee/pkg/transaction/mock" - "github.com/ethersphere/bee/pkg/util/abiutil" + chaincfg "github.com/ethersphere/bee/v2/pkg/config" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/transaction" + transactionMock "github.com/ethersphere/bee/v2/pkg/transaction/mock" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" ) var stakingContractABI = abiutil.MustParseABI(chaincfg.Testnet.StakingABI) diff --git a/pkg/storageincentives/staking/mock/contract.go b/pkg/storageincentives/staking/mock/contract.go index 09d8c03b4c2..e21e51964f9 100644 --- a/pkg/storageincentives/staking/mock/contract.go +++ b/pkg/storageincentives/staking/mock/contract.go @@ -9,7 +9,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethersphere/bee/pkg/storageincentives/staking" + "github.com/ethersphere/bee/v2/pkg/storageincentives/staking" ) type stakingContractMock struct { diff --git a/pkg/storer/cachestore.go b/pkg/storer/cachestore.go index 1e7546c7c23..16c92cb7f25 100644 --- a/pkg/storer/cachestore.go +++ b/pkg/storer/cachestore.go @@ -10,9 +10,9 @@ import ( "fmt" "time" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ( diff --git a/pkg/storer/cachestore_test.go b/pkg/storer/cachestore_test.go index dc2264491e7..2c280dd3920 100644 --- a/pkg/storer/cachestore_test.go +++ b/pkg/storer/cachestore_test.go @@ -10,12 +10,12 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/spinlock" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storagetest" - chunktesting "github.com/ethersphere/bee/pkg/storage/testing" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/spinlock" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + chunktesting "github.com/ethersphere/bee/v2/pkg/storage/testing" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func testCacheStore(t *testing.T, newStorer func() (*storer.DB, error)) { diff --git a/pkg/storer/compact.go b/pkg/storer/compact.go index 3ecc623e98f..a2bea67176a 100644 --- a/pkg/storer/compact.go +++ b/pkg/storer/compact.go @@ -12,9 +12,9 @@ import ( "sort" "time" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Compact minimizes sharky disk usage by, using the current sharky locations from the storer, diff --git a/pkg/storer/compact_test.go b/pkg/storer/compact_test.go index 3606e7c8c9d..d18675ef33b 100644 --- a/pkg/storer/compact_test.go +++ b/pkg/storer/compact_test.go @@ -10,12 +10,12 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/postage" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - pullerMock "github.com/ethersphere/bee/pkg/puller/mock" - chunk "github.com/ethersphere/bee/pkg/storage/testing" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/postage" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + pullerMock "github.com/ethersphere/bee/v2/pkg/puller/mock" + chunk "github.com/ethersphere/bee/v2/pkg/storage/testing" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // TestCompact creates two batches and puts chunks belonging to both batches. diff --git a/pkg/storer/debug.go b/pkg/storer/debug.go index 9128141a430..16f918d1ed6 100644 --- a/pkg/storer/debug.go +++ b/pkg/storer/debug.go @@ -7,11 +7,11 @@ package storer import ( "context" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - pinstore "github.com/ethersphere/bee/pkg/storer/internal/pinning" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" - "github.com/ethersphere/bee/pkg/storer/internal/upload" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + pinstore "github.com/ethersphere/bee/v2/pkg/storer/internal/pinning" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" + "github.com/ethersphere/bee/v2/pkg/storer/internal/upload" + "github.com/ethersphere/bee/v2/pkg/swarm" "golang.org/x/sync/errgroup" ) diff --git a/pkg/storer/debug_test.go b/pkg/storer/debug_test.go index d62a38aeb55..37325ce6cf8 100644 --- a/pkg/storer/debug_test.go +++ b/pkg/storer/debug_test.go @@ -9,9 +9,9 @@ import ( "testing" "time" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storer/export_test.go b/pkg/storer/export_test.go index 0613e467831..47532f0c63d 100644 --- a/pkg/storer/export_test.go +++ b/pkg/storer/export_test.go @@ -7,9 +7,9 @@ package storer import ( "context" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal/events" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal/events" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" ) func (db *DB) Reserve() *reserve.Reserve { diff --git a/pkg/storer/internal/cache/cache.go b/pkg/storer/internal/cache/cache.go index 887f2a27ae9..a3e71f9cc70 100644 --- a/pkg/storer/internal/cache/cache.go +++ b/pkg/storer/internal/cache/cache.go @@ -14,9 +14,9 @@ import ( "sync/atomic" "time" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/swarm" "resenje.org/multex" ) diff --git a/pkg/storer/internal/cache/cache_test.go b/pkg/storer/internal/cache/cache_test.go index c331853d352..337d47641df 100644 --- a/pkg/storer/internal/cache/cache_test.go +++ b/pkg/storer/internal/cache/cache_test.go @@ -14,12 +14,12 @@ import ( "testing" "time" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storagetest" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/cache" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/cache" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storer/internal/cache/export_test.go b/pkg/storer/internal/cache/export_test.go index 9a8eda3afa3..dee5f9e6d09 100644 --- a/pkg/storer/internal/cache/export_test.go +++ b/pkg/storer/internal/cache/export_test.go @@ -9,9 +9,9 @@ import ( "fmt" "time" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type ( diff --git a/pkg/storer/internal/chunkstamp/chunkstamp.go b/pkg/storer/internal/chunkstamp/chunkstamp.go index 4e8e8c91f22..83b6a4c236c 100644 --- a/pkg/storer/internal/chunkstamp/chunkstamp.go +++ b/pkg/storer/internal/chunkstamp/chunkstamp.go @@ -10,10 +10,10 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/postage" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/postage" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/storer/internal/chunkstamp/chunkstamp_test.go b/pkg/storer/internal/chunkstamp/chunkstamp_test.go index a09b1c111ac..44e1f8c3f78 100644 --- a/pkg/storer/internal/chunkstamp/chunkstamp_test.go +++ b/pkg/storer/internal/chunkstamp/chunkstamp_test.go @@ -9,13 +9,13 @@ import ( "fmt" "testing" - "github.com/ethersphere/bee/pkg/postage" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storagetest" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstamp" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/postage" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstamp" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storer/internal/chunkstamp/export_test.go b/pkg/storer/internal/chunkstamp/export_test.go index 5e2640d094b..77e54330e66 100644 --- a/pkg/storer/internal/chunkstamp/export_test.go +++ b/pkg/storer/internal/chunkstamp/export_test.go @@ -4,7 +4,7 @@ package chunkstamp -import "github.com/ethersphere/bee/pkg/swarm" +import "github.com/ethersphere/bee/v2/pkg/swarm" type Item = item diff --git a/pkg/storer/internal/chunkstore/chunkstore.go b/pkg/storer/internal/chunkstore/chunkstore.go index f1af1098944..70279c6e320 100644 --- a/pkg/storer/internal/chunkstore/chunkstore.go +++ b/pkg/storer/internal/chunkstore/chunkstore.go @@ -11,10 +11,10 @@ import ( "fmt" "time" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/swarm" "golang.org/x/exp/slices" ) diff --git a/pkg/storer/internal/chunkstore/chunkstore_test.go b/pkg/storer/internal/chunkstore/chunkstore_test.go index ce135ebaceb..9515a8142e9 100644 --- a/pkg/storer/internal/chunkstore/chunkstore_test.go +++ b/pkg/storer/internal/chunkstore/chunkstore_test.go @@ -13,13 +13,13 @@ import ( "os" "testing" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storage/storagetest" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/spf13/afero" ) diff --git a/pkg/storer/internal/chunkstore/helpers.go b/pkg/storer/internal/chunkstore/helpers.go index 8e0269144eb..782acc5788b 100644 --- a/pkg/storer/internal/chunkstore/helpers.go +++ b/pkg/storer/internal/chunkstore/helpers.go @@ -8,8 +8,8 @@ import ( "context" "fmt" - "github.com/ethersphere/bee/pkg/sharky" - storage "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/sharky" + storage "github.com/ethersphere/bee/v2/pkg/storage" ) type LocationResult struct { diff --git a/pkg/storer/internal/chunkstore/helpers_test.go b/pkg/storer/internal/chunkstore/helpers_test.go index 5add6228f9e..2b5d37f2247 100644 --- a/pkg/storer/internal/chunkstore/helpers_test.go +++ b/pkg/storer/internal/chunkstore/helpers_test.go @@ -10,12 +10,12 @@ import ( "github.com/stretchr/testify/assert" - "github.com/ethersphere/bee/pkg/sharky" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/sharky" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/spf13/afero" ) diff --git a/pkg/storer/internal/chunkstore/recovery.go b/pkg/storer/internal/chunkstore/recovery.go index fad8d47e222..a628d60ff44 100644 --- a/pkg/storer/internal/chunkstore/recovery.go +++ b/pkg/storer/internal/chunkstore/recovery.go @@ -9,10 +9,10 @@ import ( "fmt" "slices" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" "github.com/vmihailenco/msgpack/v5" ) diff --git a/pkg/storer/internal/chunkstore/recovery_test.go b/pkg/storer/internal/chunkstore/recovery_test.go index 99c5b0f8c76..40d033df474 100644 --- a/pkg/storer/internal/chunkstore/recovery_test.go +++ b/pkg/storer/internal/chunkstore/recovery_test.go @@ -10,12 +10,12 @@ import ( "slices" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/spf13/afero" diff --git a/pkg/storer/internal/chunkstore/transaction.go b/pkg/storer/internal/chunkstore/transaction.go index 02927d6423a..82833fecd54 100644 --- a/pkg/storer/internal/chunkstore/transaction.go +++ b/pkg/storer/internal/chunkstore/transaction.go @@ -11,10 +11,10 @@ import ( "fmt" "sync" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" - "github.com/ethersphere/bee/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" "github.com/google/uuid" "github.com/vmihailenco/msgpack/v5" ) diff --git a/pkg/storer/internal/chunkstore/transaction_test.go b/pkg/storer/internal/chunkstore/transaction_test.go index 88dd98851ed..9c1092331f1 100644 --- a/pkg/storer/internal/chunkstore/transaction_test.go +++ b/pkg/storer/internal/chunkstore/transaction_test.go @@ -8,14 +8,14 @@ import ( "context" "testing" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" - "github.com/ethersphere/bee/pkg/storage/storagetest" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - "github.com/ethersphere/bee/pkg/swarm" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/spf13/afero" ) diff --git a/pkg/storer/internal/events/subscribe_test.go b/pkg/storer/internal/events/subscribe_test.go index a2fb3088924..3e99494cd06 100644 --- a/pkg/storer/internal/events/subscribe_test.go +++ b/pkg/storer/internal/events/subscribe_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/storer/internal/events" + "github.com/ethersphere/bee/v2/pkg/storer/internal/events" ) func TestSubscriber(t *testing.T) { diff --git a/pkg/storer/internal/internal.go b/pkg/storer/internal/internal.go index 0433ad7a1c5..104d0a07fdd 100644 --- a/pkg/storer/internal/internal.go +++ b/pkg/storer/internal/internal.go @@ -9,10 +9,10 @@ import ( "context" "errors" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Storage groups the storage.Store and storage.ChunkStore interfaces. diff --git a/pkg/storer/internal/pinning/export_test.go b/pkg/storer/internal/pinning/export_test.go index 79e5864dfba..ecce9d1b597 100644 --- a/pkg/storer/internal/pinning/export_test.go +++ b/pkg/storer/internal/pinning/export_test.go @@ -7,8 +7,8 @@ package pinstore import ( "fmt" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type ( diff --git a/pkg/storer/internal/pinning/pinning.go b/pkg/storer/internal/pinning/pinning.go index 8fb25ba92ad..de33f9ffd93 100644 --- a/pkg/storer/internal/pinning/pinning.go +++ b/pkg/storer/internal/pinning/pinning.go @@ -12,11 +12,11 @@ import ( "fmt" "sync" - "github.com/ethersphere/bee/pkg/encryption" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/encryption" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/uuid" ) diff --git a/pkg/storer/internal/pinning/pinning_test.go b/pkg/storer/internal/pinning/pinning_test.go index 017b135f6f8..431d04097be 100644 --- a/pkg/storer/internal/pinning/pinning_test.go +++ b/pkg/storer/internal/pinning/pinning_test.go @@ -11,12 +11,12 @@ import ( "math" "testing" - storage "github.com/ethersphere/bee/pkg/storage" - storagetest "github.com/ethersphere/bee/pkg/storage/storagetest" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal" - pinstore "github.com/ethersphere/bee/pkg/storer/internal/pinning" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + storagetest "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + pinstore "github.com/ethersphere/bee/v2/pkg/storer/internal/pinning" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type pinningCollection struct { diff --git a/pkg/storer/internal/reserve/items.go b/pkg/storer/internal/reserve/items.go index 0e98dc3bdb9..9380727b6ab 100644 --- a/pkg/storer/internal/reserve/items.go +++ b/pkg/storer/internal/reserve/items.go @@ -9,10 +9,10 @@ import ( "errors" "path" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/soc" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/soc" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/storer/internal/reserve/items_test.go b/pkg/storer/internal/reserve/items_test.go index 5ef0f5424ca..e5750626f9e 100644 --- a/pkg/storer/internal/reserve/items_test.go +++ b/pkg/storer/internal/reserve/items_test.go @@ -8,10 +8,10 @@ import ( "fmt" "testing" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storagetest" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestReserveItems(t *testing.T) { diff --git a/pkg/storer/internal/reserve/reserve.go b/pkg/storer/internal/reserve/reserve.go index 47c843e48b1..c640052609e 100644 --- a/pkg/storer/internal/reserve/reserve.go +++ b/pkg/storer/internal/reserve/reserve.go @@ -14,13 +14,13 @@ import ( "sync/atomic" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstamp" - "github.com/ethersphere/bee/pkg/storer/internal/stampindex" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstamp" + "github.com/ethersphere/bee/v2/pkg/storer/internal/stampindex" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" ) // loggerName is the tree path name of the logger for this package. diff --git a/pkg/storer/internal/reserve/reserve_test.go b/pkg/storer/internal/reserve/reserve_test.go index 596552ad4dc..56a1ba4ee11 100644 --- a/pkg/storer/internal/reserve/reserve_test.go +++ b/pkg/storer/internal/reserve/reserve_test.go @@ -12,17 +12,17 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - storage "github.com/ethersphere/bee/pkg/storage" - chunk "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstamp" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" - "github.com/ethersphere/bee/pkg/storer/internal/stampindex" - "github.com/ethersphere/bee/pkg/swarm" - kademlia "github.com/ethersphere/bee/pkg/topology/mock" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + storage "github.com/ethersphere/bee/v2/pkg/storage" + chunk "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstamp" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" + "github.com/ethersphere/bee/v2/pkg/storer/internal/stampindex" + "github.com/ethersphere/bee/v2/pkg/swarm" + kademlia "github.com/ethersphere/bee/v2/pkg/topology/mock" ) func noopCacher(_ context.Context, _ internal.Storage, _ ...swarm.Address) error { diff --git a/pkg/storer/internal/stampindex/export_test.go b/pkg/storer/internal/stampindex/export_test.go index 50e75134b7c..b247fc06534 100644 --- a/pkg/storer/internal/stampindex/export_test.go +++ b/pkg/storer/internal/stampindex/export_test.go @@ -4,7 +4,7 @@ package stampindex -import "github.com/ethersphere/bee/pkg/swarm" +import "github.com/ethersphere/bee/v2/pkg/swarm" var ( ErrStampItemMarshalNamespaceInvalid = errStampItemMarshalNamespaceInvalid diff --git a/pkg/storer/internal/stampindex/stampindex.go b/pkg/storer/internal/stampindex/stampindex.go index 596c2af6af0..ff9c5e94318 100644 --- a/pkg/storer/internal/stampindex/stampindex.go +++ b/pkg/storer/internal/stampindex/stampindex.go @@ -9,10 +9,10 @@ import ( "errors" "fmt" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/storer/internal/stampindex/stampindex_test.go b/pkg/storer/internal/stampindex/stampindex_test.go index c95cdf0b682..b03aa390efb 100644 --- a/pkg/storer/internal/stampindex/stampindex_test.go +++ b/pkg/storer/internal/stampindex/stampindex_test.go @@ -9,12 +9,12 @@ import ( "fmt" "testing" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storagetest" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/stampindex" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/stampindex" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storer/internal/upload/uploadstore.go b/pkg/storer/internal/upload/uploadstore.go index 81fed2a8bcb..146995ecd7a 100644 --- a/pkg/storer/internal/upload/uploadstore.go +++ b/pkg/storer/internal/upload/uploadstore.go @@ -12,12 +12,12 @@ import ( "strconv" "time" - "github.com/ethersphere/bee/pkg/encryption" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstamp" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/encryption" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstamp" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // now returns the current time.Time; used in testing. diff --git a/pkg/storer/internal/upload/uploadstore_test.go b/pkg/storer/internal/upload/uploadstore_test.go index a2f7f931913..f8e46af258f 100644 --- a/pkg/storer/internal/upload/uploadstore_test.go +++ b/pkg/storer/internal/upload/uploadstore_test.go @@ -15,12 +15,12 @@ import ( "testing" "time" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storagetest" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/upload" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/upload" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" ) diff --git a/pkg/storer/metrics.go b/pkg/storer/metrics.go index e132c4e931e..c416d222783 100644 --- a/pkg/storer/metrics.go +++ b/pkg/storer/metrics.go @@ -9,9 +9,9 @@ import ( "errors" "time" - m "github.com/ethersphere/bee/pkg/metrics" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + m "github.com/ethersphere/bee/v2/pkg/metrics" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/storer/migration/all_steps.go b/pkg/storer/migration/all_steps.go index 69aa419747f..ea222c81181 100644 --- a/pkg/storer/migration/all_steps.go +++ b/pkg/storer/migration/all_steps.go @@ -5,9 +5,9 @@ package migration import ( - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/migration" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/migration" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" ) // AfterInitSteps lists all migration steps for localstore IndexStore after the localstore is intiated. diff --git a/pkg/storer/migration/all_steps_test.go b/pkg/storer/migration/all_steps_test.go index 10a6fbce752..94e70fb251f 100644 --- a/pkg/storer/migration/all_steps_test.go +++ b/pkg/storer/migration/all_steps_test.go @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/assert" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storage/migration" - localmigration "github.com/ethersphere/bee/pkg/storer/migration" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storage/migration" + localmigration "github.com/ethersphere/bee/v2/pkg/storer/migration" ) func TestPreSteps(t *testing.T) { diff --git a/pkg/storer/migration/refCntSize.go b/pkg/storer/migration/refCntSize.go index ccb4552b9a0..d13f5b8c354 100644 --- a/pkg/storer/migration/refCntSize.go +++ b/pkg/storer/migration/refCntSize.go @@ -10,12 +10,12 @@ import ( "errors" "os" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const oldRretrievalIndexItemSize = swarm.HashSize + 8 + sharky.LocationSize + 1 diff --git a/pkg/storer/migration/refCntSize_test.go b/pkg/storer/migration/refCntSize_test.go index a7869d31c31..c3310077ef2 100644 --- a/pkg/storer/migration/refCntSize_test.go +++ b/pkg/storer/migration/refCntSize_test.go @@ -8,11 +8,11 @@ import ( "math/rand" "testing" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - localmigration "github.com/ethersphere/bee/pkg/storer/migration" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + localmigration "github.com/ethersphere/bee/v2/pkg/storer/migration" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/stretchr/testify/assert" ) diff --git a/pkg/storer/migration/step_01.go b/pkg/storer/migration/step_01.go index cc0b4fe8544..beaff83537d 100644 --- a/pkg/storer/migration/step_01.go +++ b/pkg/storer/migration/step_01.go @@ -5,7 +5,7 @@ package migration import ( - storage "github.com/ethersphere/bee/pkg/storage" + storage "github.com/ethersphere/bee/v2/pkg/storage" ) // step_01 serves as example for setting up migration step. diff --git a/pkg/storer/migration/step_01_test.go b/pkg/storer/migration/step_01_test.go index 8b89d556745..7e4e6ee5df1 100644 --- a/pkg/storer/migration/step_01_test.go +++ b/pkg/storer/migration/step_01_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - localmigration "github.com/ethersphere/bee/pkg/storer/migration" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + localmigration "github.com/ethersphere/bee/v2/pkg/storer/migration" ) func Test_Step_01(t *testing.T) { diff --git a/pkg/storer/migration/step_02.go b/pkg/storer/migration/step_02.go index 2da6963a35f..b60ce42cc43 100644 --- a/pkg/storer/migration/step_02.go +++ b/pkg/storer/migration/step_02.go @@ -7,9 +7,9 @@ package migration import ( "time" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal/cache" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal/cache" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // step_02 migrates the cache to the new format. diff --git a/pkg/storer/migration/step_02_test.go b/pkg/storer/migration/step_02_test.go index 85180ce134b..6275790093e 100644 --- a/pkg/storer/migration/step_02_test.go +++ b/pkg/storer/migration/step_02_test.go @@ -10,11 +10,11 @@ import ( "github.com/stretchr/testify/assert" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - "github.com/ethersphere/bee/pkg/storer/internal/cache" - localmigration "github.com/ethersphere/bee/pkg/storer/migration" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + "github.com/ethersphere/bee/v2/pkg/storer/internal/cache" + localmigration "github.com/ethersphere/bee/v2/pkg/storer/migration" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type testEntry struct { diff --git a/pkg/storer/migration/step_03.go b/pkg/storer/migration/step_03.go index 8f52ba11547..317f4290aea 100644 --- a/pkg/storer/migration/step_03.go +++ b/pkg/storer/migration/step_03.go @@ -9,10 +9,10 @@ import ( "errors" "os" - "github.com/ethersphere/bee/pkg/log" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // step_03 is a migration step that removes all BinItem entries and migrates diff --git a/pkg/storer/migration/step_03_test.go b/pkg/storer/migration/step_03_test.go index 180cc16aa10..4df69dec6c7 100644 --- a/pkg/storer/migration/step_03_test.go +++ b/pkg/storer/migration/step_03_test.go @@ -9,13 +9,13 @@ import ( "errors" "testing" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" - localmigration "github.com/ethersphere/bee/pkg/storer/migration" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" + localmigration "github.com/ethersphere/bee/v2/pkg/storer/migration" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/stretchr/testify/assert" ) diff --git a/pkg/storer/migration/step_04.go b/pkg/storer/migration/step_04.go index e621ae3458a..fa316f8393b 100644 --- a/pkg/storer/migration/step_04.go +++ b/pkg/storer/migration/step_04.go @@ -8,11 +8,11 @@ import ( "context" "os" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // step_04 is the fourth step of the migration. It forces a sharky recovery to diff --git a/pkg/storer/migration/step_04_test.go b/pkg/storer/migration/step_04_test.go index 6b70d69d5e7..ec3f4cb87e8 100644 --- a/pkg/storer/migration/step_04_test.go +++ b/pkg/storer/migration/step_04_test.go @@ -11,12 +11,12 @@ import ( "path/filepath" "testing" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage/inmemstore" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - localmigration "github.com/ethersphere/bee/pkg/storer/migration" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage/inmemstore" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + localmigration "github.com/ethersphere/bee/v2/pkg/storer/migration" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/stretchr/testify/assert" ) diff --git a/pkg/storer/migration/step_05.go b/pkg/storer/migration/step_05.go index f9aa75b2b00..0061920fb6c 100644 --- a/pkg/storer/migration/step_05.go +++ b/pkg/storer/migration/step_05.go @@ -8,9 +8,9 @@ import ( "fmt" "os" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal/upload" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal/upload" ) // step_05 is a migration step that removes all upload items from the store. diff --git a/pkg/storer/migration/step_05_test.go b/pkg/storer/migration/step_05_test.go index cc7a88214a8..e363c0b71b2 100644 --- a/pkg/storer/migration/step_05_test.go +++ b/pkg/storer/migration/step_05_test.go @@ -8,17 +8,17 @@ import ( "context" "testing" - "github.com/ethersphere/bee/pkg/node" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/storage" - chunktest "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/upload" - localmigration "github.com/ethersphere/bee/pkg/storer/migration" - "github.com/ethersphere/bee/pkg/swarm" - kademlia "github.com/ethersphere/bee/pkg/topology/mock" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/node" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/storage" + chunktest "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/upload" + localmigration "github.com/ethersphere/bee/v2/pkg/storer/migration" + "github.com/ethersphere/bee/v2/pkg/swarm" + kademlia "github.com/ethersphere/bee/v2/pkg/topology/mock" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) func Test_Step_05(t *testing.T) { diff --git a/pkg/storer/mock/forgetting.go b/pkg/storer/mock/forgetting.go index 5588b5c263e..e91560c60fb 100644 --- a/pkg/storer/mock/forgetting.go +++ b/pkg/storer/mock/forgetting.go @@ -10,8 +10,8 @@ import ( "sync/atomic" "time" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type DelayedStore struct { diff --git a/pkg/storer/mock/mockreserve.go b/pkg/storer/mock/mockreserve.go index d6d70390242..7cd3cb8fd6a 100644 --- a/pkg/storer/mock/mockreserve.go +++ b/pkg/storer/mock/mockreserve.go @@ -9,9 +9,9 @@ import ( "math/big" "sync" - storage "github.com/ethersphere/bee/pkg/storage" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type chunksResponse struct { diff --git a/pkg/storer/mock/mockstorer.go b/pkg/storer/mock/mockstorer.go index fa08445d0ec..083b1c5a95b 100644 --- a/pkg/storer/mock/mockstorer.go +++ b/pkg/storer/mock/mockstorer.go @@ -9,12 +9,12 @@ import ( "sync" "time" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - "github.com/ethersphere/bee/pkg/pusher" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + "github.com/ethersphere/bee/v2/pkg/pusher" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" "go.uber.org/atomic" ) diff --git a/pkg/storer/mock/mockstorer_test.go b/pkg/storer/mock/mockstorer_test.go index 40f08a4d852..6fbee300c24 100644 --- a/pkg/storer/mock/mockstorer_test.go +++ b/pkg/storer/mock/mockstorer_test.go @@ -12,11 +12,11 @@ import ( "testing" "time" - storage "github.com/ethersphere/bee/pkg/storage" - chunktesting "github.com/ethersphere/bee/pkg/storage/testing" - storer "github.com/ethersphere/bee/pkg/storer" - mockstorer "github.com/ethersphere/bee/pkg/storer/mock" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + chunktesting "github.com/ethersphere/bee/v2/pkg/storage/testing" + storer "github.com/ethersphere/bee/v2/pkg/storer" + mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storer/netstore.go b/pkg/storer/netstore.go index 3d5a0c01057..1b13ef5908e 100644 --- a/pkg/storer/netstore.go +++ b/pkg/storer/netstore.go @@ -8,10 +8,10 @@ import ( "context" "errors" - "github.com/ethersphere/bee/pkg/pusher" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/pusher" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" "github.com/opentracing/opentracing-go/ext" olog "github.com/opentracing/opentracing-go/log" "golang.org/x/sync/errgroup" diff --git a/pkg/storer/netstore_test.go b/pkg/storer/netstore_test.go index b15cd2cfed8..3feac383898 100644 --- a/pkg/storer/netstore_test.go +++ b/pkg/storer/netstore_test.go @@ -11,12 +11,12 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/pusher" - "github.com/ethersphere/bee/pkg/retrieval" - storage "github.com/ethersphere/bee/pkg/storage" - chunktesting "github.com/ethersphere/bee/pkg/storage/testing" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/pusher" + "github.com/ethersphere/bee/v2/pkg/retrieval" + storage "github.com/ethersphere/bee/v2/pkg/storage" + chunktesting "github.com/ethersphere/bee/v2/pkg/storage/testing" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type testRetrieval struct { diff --git a/pkg/storer/pinstore.go b/pkg/storer/pinstore.go index 58cc2ef2cc2..dd9cfc3b51d 100644 --- a/pkg/storer/pinstore.go +++ b/pkg/storer/pinstore.go @@ -9,10 +9,10 @@ import ( "fmt" "time" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal" - pinstore "github.com/ethersphere/bee/pkg/storer/internal/pinning" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + pinstore "github.com/ethersphere/bee/v2/pkg/storer/internal/pinning" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // NewCollection is the implementation of the PinStore.NewCollection method. diff --git a/pkg/storer/pinstore_test.go b/pkg/storer/pinstore_test.go index 43676f6ce61..4719f4baaf5 100644 --- a/pkg/storer/pinstore_test.go +++ b/pkg/storer/pinstore_test.go @@ -11,10 +11,10 @@ import ( "testing" "time" - storage "github.com/ethersphere/bee/pkg/storage" - chunktesting "github.com/ethersphere/bee/pkg/storage/testing" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + chunktesting "github.com/ethersphere/bee/v2/pkg/storage/testing" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func testPinStore(t *testing.T, newStorer func() (*storer.DB, error)) { diff --git a/pkg/storer/recover.go b/pkg/storer/recover.go index 7fa48ec2112..a6500ea7828 100644 --- a/pkg/storer/recover.go +++ b/pkg/storer/recover.go @@ -12,10 +12,10 @@ import ( "path/filepath" "time" - "github.com/ethersphere/bee/pkg/sharky" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/sharky" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ( diff --git a/pkg/storer/reserve.go b/pkg/storer/reserve.go index 66a8fd0c464..589a0f853a1 100644 --- a/pkg/storer/reserve.go +++ b/pkg/storer/reserve.go @@ -14,12 +14,12 @@ import ( "sync/atomic" "time" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storageutil" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storageutil" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const ( @@ -35,6 +35,7 @@ func reserveUpdateBatchLockKey(batchID []byte) string { } var errMaxRadius = errors.New("max radius reached") +var reserveSizeWithinRadius atomic.Uint64 type Syncer interface { // Number of active historical syncing jobs. @@ -137,6 +138,7 @@ func (db *DB) reserveSizeWithinRadiusWorker(ctx context.Context) { if err != nil { db.logger.Error(err, "reserve count within radius") } + reserveSizeWithinRadius.Store(uint64(count)) for batch := range evictBatches { db.logger.Debug("reserve size worker, invalid batch id", "batch_id", hex.EncodeToString([]byte(batch))) @@ -474,6 +476,10 @@ func (db *DB) ReserveSize() int { return db.reserve.Size() } +func (db *DB) ReserveSizeWithinRadius() uint64 { + return reserveSizeWithinRadius.Load() +} + func (db *DB) IsWithinStorageRadius(addr swarm.Address) bool { if db.reserve == nil { return false diff --git a/pkg/storer/reserve_test.go b/pkg/storer/reserve_test.go index aa5f79a6737..9537f230c49 100644 --- a/pkg/storer/reserve_test.go +++ b/pkg/storer/reserve_test.go @@ -12,19 +12,19 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/postage" - batchstore "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - pullerMock "github.com/ethersphere/bee/pkg/puller/mock" - "github.com/ethersphere/bee/pkg/spinlock" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/storagetest" - chunk "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstamp" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" - "github.com/ethersphere/bee/pkg/storer/internal/stampindex" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/postage" + batchstore "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + pullerMock "github.com/ethersphere/bee/v2/pkg/puller/mock" + "github.com/ethersphere/bee/v2/pkg/spinlock" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/storagetest" + chunk "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstamp" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" + "github.com/ethersphere/bee/v2/pkg/storer/internal/stampindex" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestIndexCollision(t *testing.T) { diff --git a/pkg/storer/sample.go b/pkg/storer/sample.go index 7fd5cc2ad4a..d3cb1ecec99 100644 --- a/pkg/storer/sample.go +++ b/pkg/storer/sample.go @@ -16,13 +16,13 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/bmt" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/soc" - chunk "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstamp" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/bmt" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/soc" + chunk "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstamp" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" + "github.com/ethersphere/bee/v2/pkg/swarm" "golang.org/x/sync/errgroup" ) @@ -337,7 +337,7 @@ func transformedAddress(hasher *bmt.Hasher, chunk swarm.Chunk, chType swarm.Chun case swarm.ChunkTypeSingleOwner: return transformedAddressSOC(hasher, chunk) default: - return swarm.ZeroAddress, fmt.Errorf("chunk type [%v] is is not valid", chType) + return swarm.ZeroAddress, fmt.Errorf("chunk type [%v] is not valid", chType) } } diff --git a/pkg/storer/sample_test.go b/pkg/storer/sample_test.go index 215b190fc1a..cf10d59894b 100644 --- a/pkg/storer/sample_test.go +++ b/pkg/storer/sample_test.go @@ -6,15 +6,15 @@ package storer_test import ( "context" - "github.com/ethersphere/bee/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/postage" "math/rand" "testing" "time" - postagetesting "github.com/ethersphere/bee/pkg/postage/testing" - chunk "github.com/ethersphere/bee/pkg/storage/testing" - "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + postagetesting "github.com/ethersphere/bee/v2/pkg/postage/testing" + chunk "github.com/ethersphere/bee/v2/pkg/storage/testing" + "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storer/storer.go b/pkg/storer/storer.go index 3ebb3a025d7..c6987a54554 100644 --- a/pkg/storer/storer.go +++ b/pkg/storer/storer.go @@ -18,27 +18,27 @@ import ( "sync/atomic" "time" - "github.com/ethersphere/bee/pkg/log" - m "github.com/ethersphere/bee/pkg/metrics" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/pusher" - "github.com/ethersphere/bee/pkg/retrieval" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/leveldbstore" - "github.com/ethersphere/bee/pkg/storage/migration" - "github.com/ethersphere/bee/pkg/storer/internal" - "github.com/ethersphere/bee/pkg/storer/internal/cache" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - "github.com/ethersphere/bee/pkg/storer/internal/events" - pinstore "github.com/ethersphere/bee/pkg/storer/internal/pinning" - "github.com/ethersphere/bee/pkg/storer/internal/reserve" - "github.com/ethersphere/bee/pkg/storer/internal/upload" - localmigration "github.com/ethersphere/bee/pkg/storer/migration" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/tracing" - "github.com/ethersphere/bee/pkg/util/syncutil" + "github.com/ethersphere/bee/v2/pkg/log" + m "github.com/ethersphere/bee/v2/pkg/metrics" + "github.com/ethersphere/bee/v2/pkg/postage" + "github.com/ethersphere/bee/v2/pkg/pusher" + "github.com/ethersphere/bee/v2/pkg/retrieval" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" + "github.com/ethersphere/bee/v2/pkg/storage/migration" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + "github.com/ethersphere/bee/v2/pkg/storer/internal/cache" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + "github.com/ethersphere/bee/v2/pkg/storer/internal/events" + pinstore "github.com/ethersphere/bee/v2/pkg/storer/internal/pinning" + "github.com/ethersphere/bee/v2/pkg/storer/internal/reserve" + "github.com/ethersphere/bee/v2/pkg/storer/internal/upload" + localmigration "github.com/ethersphere/bee/v2/pkg/storer/migration" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/util/syncutil" "github.com/prometheus/client_golang/prometheus" "github.com/spf13/afero" "github.com/syndtr/goleveldb/leveldb" @@ -278,15 +278,15 @@ func initDiskRepository( basePath string, locker storage.ChunkLocker, opts *Options, -) (storage.Repository, io.Closer, error) { +) (storage.Repository, *PinIntegrity, io.Closer, error) { store, err := initStore(basePath, opts) if err != nil { - return nil, nil, fmt.Errorf("failed creating levelDB index store: %w", err) + return nil, nil, nil, fmt.Errorf("failed creating levelDB index store: %w", err) } err = migration.Migrate(store, "core-migration", localmigration.BeforeIinitSteps()) if err != nil { - return nil, nil, fmt.Errorf("failed core migration: %w", err) + return nil, nil, nil, fmt.Errorf("failed core migration: %w", err) } if opts.LdbStats.Load() != nil { @@ -338,13 +338,13 @@ func initDiskRepository( if _, err := os.Stat(sharkyBasePath); os.IsNotExist(err) { err := os.Mkdir(sharkyBasePath, 0777) if err != nil { - return nil, nil, err + return nil, nil, nil, err } } recoveryCloser, err := sharkyRecovery(ctx, sharkyBasePath, store, opts) if err != nil { - return nil, nil, fmt.Errorf("failed to recover sharky: %w", err) + return nil, nil, nil, fmt.Errorf("failed to recover sharky: %w", err) } sharky, err := sharky.New( @@ -353,20 +353,25 @@ func initDiskRepository( swarm.SocMaxChunkSize, ) if err != nil { - return nil, nil, fmt.Errorf("failed creating sharky instance: %w", err) + return nil, nil, nil, fmt.Errorf("failed creating sharky instance: %w", err) } txStore := leveldbstore.NewTxStore(store) if err := txStore.Recover(); err != nil { - return nil, nil, fmt.Errorf("failed to recover index store: %w", err) + return nil, nil, nil, fmt.Errorf("failed to recover index store: %w", err) } txChunkStore := chunkstore.NewTxChunkStore(txStore, sharky) if err := txChunkStore.Recover(); err != nil { - return nil, nil, fmt.Errorf("failed to recover chunk store: %w", err) + return nil, nil, nil, fmt.Errorf("failed to recover chunk store: %w", err) } - return storage.NewRepository(txStore, txChunkStore, locker), closer(store, sharky, recoveryCloser), nil + pinIntegrity := &PinIntegrity{ + Store: store, + Sharky: sharky, + } + + return storage.NewRepository(txStore, txChunkStore, locker), pinIntegrity, closer(store, sharky, recoveryCloser), nil } func initCache(ctx context.Context, capacity uint64, repo storage.Repository) (*cache.Cache, error) { @@ -457,6 +462,8 @@ type DB struct { setSyncerOnce sync.Once syncer Syncer opts workerOpts + + pinIntegrity *PinIntegrity } type workerOpts struct { @@ -468,9 +475,10 @@ type workerOpts struct { // component stores. func New(ctx context.Context, dirPath string, opts *Options) (*DB, error) { var ( - repo storage.Repository - err error - dbCloser io.Closer + repo storage.Repository + err error + dbCloser io.Closer + pinIntegrity *PinIntegrity ) if opts == nil { opts = defaultOptions() @@ -497,7 +505,7 @@ func New(ctx context.Context, dirPath string, opts *Options) (*DB, error) { return nil, err } } else { - repo, dbCloser, err = initDiskRepository(ctx, dirPath, locker, opts) + repo, pinIntegrity, dbCloser, err = initDiskRepository(ctx, dirPath, locker, opts) if err != nil { return nil, err } @@ -550,6 +558,7 @@ func New(ctx context.Context, dirPath string, opts *Options) (*DB, error) { wakeupDuration: opts.ReserveWakeUpDuration, }, directUploadLimiter: make(chan struct{}, pusher.ConcurrentPushes), + pinIntegrity: pinIntegrity, } if db.validStamp == nil { @@ -665,6 +674,10 @@ func (db *DB) ChunkStore() storage.ReadOnlyChunkStore { return db.repo.ChunkStore() } +func (db *DB) PinIntegrity() *PinIntegrity { + return db.pinIntegrity +} + // Execute implements the internal.TxExecutor interface. func (db *DB) Execute(ctx context.Context, do func(internal.Storage) error) error { tx, commit, rollback := db.repo.NewTx(ctx) diff --git a/pkg/storer/storer_test.go b/pkg/storer/storer_test.go index ce2d7eb72cf..43ea78d889e 100644 --- a/pkg/storer/storer_test.go +++ b/pkg/storer/storer_test.go @@ -11,20 +11,20 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - batchstore "github.com/ethersphere/bee/pkg/postage/batchstore/mock" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/storage/migration" - "github.com/ethersphere/bee/pkg/storer" - cs "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - pinstore "github.com/ethersphere/bee/pkg/storer/internal/pinning" - "github.com/ethersphere/bee/pkg/storer/internal/upload" - localmigration "github.com/ethersphere/bee/pkg/storer/migration" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - kademlia "github.com/ethersphere/bee/pkg/topology/mock" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/postage" + batchstore "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/storage/migration" + "github.com/ethersphere/bee/v2/pkg/storer" + cs "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + pinstore "github.com/ethersphere/bee/v2/pkg/storer/internal/pinning" + "github.com/ethersphere/bee/v2/pkg/storer/internal/upload" + localmigration "github.com/ethersphere/bee/v2/pkg/storer/migration" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + kademlia "github.com/ethersphere/bee/v2/pkg/topology/mock" ) func verifyChunks( diff --git a/pkg/storer/subscribe_push.go b/pkg/storer/subscribe_push.go index d9c37abce28..a82c0db46db 100644 --- a/pkg/storer/subscribe_push.go +++ b/pkg/storer/subscribe_push.go @@ -9,8 +9,8 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/storer/internal/upload" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/storer/internal/upload" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const subscribePushEventKey = "subscribe-push" diff --git a/pkg/storer/subscribe_push_test.go b/pkg/storer/subscribe_push_test.go index 851dd060580..17d7c46e486 100644 --- a/pkg/storer/subscribe_push_test.go +++ b/pkg/storer/subscribe_push_test.go @@ -11,9 +11,9 @@ import ( "testing" "time" - chunktesting "github.com/ethersphere/bee/pkg/storage/testing" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + chunktesting "github.com/ethersphere/bee/v2/pkg/storage/testing" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestPushSubscriber(t *testing.T) { diff --git a/pkg/storer/uploadstore.go b/pkg/storer/uploadstore.go index 9b5aeca4bbc..d3596dbede0 100644 --- a/pkg/storer/uploadstore.go +++ b/pkg/storer/uploadstore.go @@ -10,11 +10,11 @@ import ( "fmt" "sort" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal" - pinstore "github.com/ethersphere/bee/pkg/storer/internal/pinning" - "github.com/ethersphere/bee/pkg/storer/internal/upload" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal" + pinstore "github.com/ethersphere/bee/v2/pkg/storer/internal/pinning" + "github.com/ethersphere/bee/v2/pkg/storer/internal/upload" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const uploadStoreKey = "uploadstore" diff --git a/pkg/storer/uploadstore_test.go b/pkg/storer/uploadstore_test.go index fa267728e6e..04b1016027a 100644 --- a/pkg/storer/uploadstore_test.go +++ b/pkg/storer/uploadstore_test.go @@ -11,10 +11,10 @@ import ( "testing" "time" - storage "github.com/ethersphere/bee/pkg/storage" - chunktesting "github.com/ethersphere/bee/pkg/storage/testing" - storer "github.com/ethersphere/bee/pkg/storer" - "github.com/ethersphere/bee/pkg/swarm" + storage "github.com/ethersphere/bee/v2/pkg/storage" + chunktesting "github.com/ethersphere/bee/v2/pkg/storage/testing" + storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/storer/validate.go b/pkg/storer/validate.go index ccad569455d..894f12a0651 100644 --- a/pkg/storer/validate.go +++ b/pkg/storer/validate.go @@ -14,14 +14,14 @@ import ( "sync/atomic" - "github.com/ethersphere/bee/pkg/cac" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/sharky" - "github.com/ethersphere/bee/pkg/soc" - "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storer/internal/chunkstore" - pinstore "github.com/ethersphere/bee/pkg/storer/internal/pinning" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/sharky" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer/internal/chunkstore" + pinstore "github.com/ethersphere/bee/v2/pkg/storer/internal/pinning" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Validate ensures that all retrievalIndex chunks are correctly stored in sharky. @@ -173,27 +173,81 @@ func ValidatePinCollectionChunks(ctx context.Context, basePath, pin, location st }() logger.Info("performing chunk validation") - validatePins(logger, store, pin, location, sharky.Read) + + pv := PinIntegrity{ + Store: store, + Sharky: sharky, + } + + var ( + fileName = "address.csv" + fileLoc = "." + ) + + if location != "" { + if path.Ext(location) != "" { + fileName = path.Base(location) + } + fileLoc = path.Dir(location) + } + + logger.Info("saving stats", "location", fileLoc, "name", fileName) + + location = path.Join(fileLoc, fileName) + + f, err := os.OpenFile(location, os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + return fmt.Errorf("open output file for writing: %w", err) + } + + if _, err := f.WriteString("invalid\tmissing\ttotal\taddress\n"); err != nil { + return fmt.Errorf("write title: %w", err) + } + + defer f.Close() + + var ch = make(chan PinStat) + go pv.Check(ctx, logger, pin, ch) + + for st := range ch { + report := fmt.Sprintf("%d\t%d\t%d\t%s\n", st.Invalid, st.Missing, st.Total, st.Ref) + + if _, err := f.WriteString(report); err != nil { + logger.Error(err, "write report line") + break + } + } return nil } -func validatePins(logger log.Logger, store storage.Store, pin, location string, readFn func(context.Context, sharky.Location, []byte) error) { +type PinIntegrity struct { + Store storage.Store + Sharky *sharky.Store +} + +type PinStat struct { + Ref swarm.Address + Total, Missing, Invalid int +} + +func (p *PinIntegrity) Check(ctx context.Context, logger log.Logger, pin string, out chan PinStat) { var stats struct { total, read, invalid atomic.Int32 } n := time.Now() defer func() { + close(out) logger.Info("done", "duration", time.Since(n), "read", stats.read.Load(), "invalid", stats.invalid.Load(), "total", stats.total.Load()) }() validChunk := func(item *chunkstore.RetrievalIndexItem, buf []byte) bool { stats.total.Add(1) - if err := readFn(context.Background(), item.Location, buf); err != nil { + if err := p.Sharky.Read(ctx, item.Location, buf); err != nil { stats.read.Add(1) - return true + return false } ch := swarm.NewChunk(item.Address, buf) @@ -221,7 +275,7 @@ func validatePins(logger log.Logger, store storage.Store, pin, location string, pins = append(pins, addr) } else { var err error - pins, err = pinstore.Pins(store) + pins, err = pinstore.Pins(p.Store) if err != nil { logger.Error(err, "get pins") return @@ -230,34 +284,11 @@ func validatePins(logger log.Logger, store storage.Store, pin, location string, logger.Info("got a total number of pins", "size", len(pins)) - var ( - fileName = "address.csv" - fileLoc = "." - ) - - if location != "" { - if path.Ext(location) != "" { - fileName = path.Base(location) - } - fileLoc = path.Dir(location) - } - - logger.Info("saving stats to", "location", fileLoc, "name", fileName) - - location = path.Join(fileLoc, fileName) - - f, err := os.OpenFile(location, os.O_CREATE|os.O_WRONLY, 0644) - if err != nil { - logger.Error(err, "open output file for writing") - return - } - - if _, err := f.WriteString("invalid\tmissing\ttotal\taddress\n"); err != nil { - logger.Error(err, "write title") - return - } - - defer f.Close() + var tcount, tmicrs int64 + defer func() { + dur := float64(tmicrs) / float64(tcount) + logger.Info("done iterating pins", "duration", dur) + }() for _, pin := range pins { var wg sync.WaitGroup @@ -273,6 +304,9 @@ func validatePins(logger log.Logger, store storage.Store, pin, location string, defer wg.Done() buf := make([]byte, swarm.SocMaxChunkSize) for item := range iteratateItemsC { + if ctx.Err() != nil { + break + } if !validChunk(item, buf[:item.Location.Length]) { invalid.Add(1) } @@ -280,28 +314,56 @@ func validatePins(logger log.Logger, store storage.Store, pin, location string, }() } - logger.Info("start iteration", "pin", pin) + var count, micrs int64 + + err := pinstore.IterateCollection(p.Store, pin, func(addr swarm.Address) (bool, error) { + n := time.Now() + + defer func() { + count++ + micrs += time.Since(n).Microseconds() + }() - _ = pinstore.IterateCollection(store, pin, func(addr swarm.Address) (bool, error) { total.Add(1) + rIdx := &chunkstore.RetrievalIndexItem{Address: addr} - if err := store.Get(rIdx); err != nil { + if err := p.Store.Get(rIdx); err != nil { missing.Add(1) } else { - iteratateItemsC <- rIdx + select { + case <-ctx.Done(): + return true, nil + case iteratateItemsC <- rIdx: + } } + return false, nil }) + dur := float64(micrs) / float64(count) + + if err != nil { + logger.Error(err, "new iteration", "pin", pin, "duration", dur) + } else { + logger.Info("new iteration", "pin", pin, "duration", dur) + } + + tcount++ + tmicrs += int64(dur) + close(iteratateItemsC) wg.Wait() - report := fmt.Sprintf("%d\t%d\t%d\t%s\n", invalid.Load(), missing.Load(), total.Load(), pin) - - if _, err := f.WriteString(report); err != nil { - logger.Error(err, "write report line") + select { + case <-ctx.Done(): + logger.Info("context done") return + case out <- PinStat{ + Ref: pin, + Total: int(total.Load()), + Missing: int(missing.Load()), + Invalid: int(invalid.Load())}: } } } diff --git a/pkg/swarm/distance_test.go b/pkg/swarm/distance_test.go index f06641a0ed2..0adf2430919 100644 --- a/pkg/swarm/distance_test.go +++ b/pkg/swarm/distance_test.go @@ -7,7 +7,7 @@ package swarm_test import ( "testing" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type distanceTest struct { diff --git a/pkg/swarm/hasher_test.go b/pkg/swarm/hasher_test.go index 3811e09605a..f08e2f28f42 100644 --- a/pkg/swarm/hasher_test.go +++ b/pkg/swarm/hasher_test.go @@ -8,7 +8,7 @@ import ( "bytes" "testing" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestNewHasher(t *testing.T) { diff --git a/pkg/swarm/swarm_test.go b/pkg/swarm/swarm_test.go index 7555ac5bf4d..fdde62625be 100644 --- a/pkg/swarm/swarm_test.go +++ b/pkg/swarm/swarm_test.go @@ -10,7 +10,7 @@ import ( "errors" "testing" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func TestAddress(t *testing.T) { diff --git a/pkg/swarm/test_helpers.go b/pkg/swarm/test_helpers.go index e3d6cb27ac9..b043e1bb17d 100644 --- a/pkg/swarm/test_helpers.go +++ b/pkg/swarm/test_helpers.go @@ -8,7 +8,7 @@ import ( "math/rand" "testing" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) // RandAddress generates a random address. diff --git a/pkg/swarm/test_helpers_test.go b/pkg/swarm/test_helpers_test.go index e7c21e9e633..a4184dfedc2 100644 --- a/pkg/swarm/test_helpers_test.go +++ b/pkg/swarm/test_helpers_test.go @@ -8,7 +8,7 @@ import ( "encoding/binary" "testing" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func Test_RandAddress(t *testing.T) { diff --git a/pkg/swarm/utilities_test.go b/pkg/swarm/utilities_test.go index 17ade1aaa28..6cd75a89a32 100644 --- a/pkg/swarm/utilities_test.go +++ b/pkg/swarm/utilities_test.go @@ -7,7 +7,7 @@ package swarm_test import ( "testing" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func Test_ContainsAddress(t *testing.T) { diff --git a/pkg/topology/kademlia/binprefix.go b/pkg/topology/kademlia/binprefix.go index f9d92ff429e..94e2550ea2d 100644 --- a/pkg/topology/kademlia/binprefix.go +++ b/pkg/topology/kademlia/binprefix.go @@ -8,7 +8,7 @@ import ( "math" "math/bits" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // generateCommonBinPrefixes generates the common bin prefixes diff --git a/pkg/topology/kademlia/export_test.go b/pkg/topology/kademlia/export_test.go index b005dd92c93..96b8b3191fc 100644 --- a/pkg/topology/kademlia/export_test.go +++ b/pkg/topology/kademlia/export_test.go @@ -5,9 +5,9 @@ package kademlia import ( - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/topology/pslice" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/topology/pslice" ) var ( diff --git a/pkg/topology/kademlia/internal/metrics/metrics.go b/pkg/topology/kademlia/internal/metrics/metrics.go index a161b2ec014..d6ce41e3a73 100644 --- a/pkg/topology/kademlia/internal/metrics/metrics.go +++ b/pkg/topology/kademlia/internal/metrics/metrics.go @@ -13,9 +13,9 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/shed" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/shed" + "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/syndtr/goleveldb/leveldb" ) diff --git a/pkg/topology/kademlia/internal/metrics/metrics_test.go b/pkg/topology/kademlia/internal/metrics/metrics_test.go index 3373dc4b7b8..2aae2a68c4e 100644 --- a/pkg/topology/kademlia/internal/metrics/metrics_test.go +++ b/pkg/topology/kademlia/internal/metrics/metrics_test.go @@ -8,11 +8,11 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/shed" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology/kademlia/internal/metrics" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/shed" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology/kademlia/internal/metrics" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/topology/kademlia/internal/waitnext/waitnext.go b/pkg/topology/kademlia/internal/waitnext/waitnext.go index 744622d93b8..9a93f274eba 100644 --- a/pkg/topology/kademlia/internal/waitnext/waitnext.go +++ b/pkg/topology/kademlia/internal/waitnext/waitnext.go @@ -10,7 +10,7 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) type next struct { diff --git a/pkg/topology/kademlia/internal/waitnext/waitnext_test.go b/pkg/topology/kademlia/internal/waitnext/waitnext_test.go index 35f3062bd38..3b67a785f3e 100644 --- a/pkg/topology/kademlia/internal/waitnext/waitnext_test.go +++ b/pkg/topology/kademlia/internal/waitnext/waitnext_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology/kademlia/internal/waitnext" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology/kademlia/internal/waitnext" ) func TestSet(t *testing.T) { diff --git a/pkg/topology/kademlia/kademlia.go b/pkg/topology/kademlia/kademlia.go index 277eeba331a..5fe6f7f2f4d 100644 --- a/pkg/topology/kademlia/kademlia.go +++ b/pkg/topology/kademlia/kademlia.go @@ -16,16 +16,16 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/discovery" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/shed" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - im "github.com/ethersphere/bee/pkg/topology/kademlia/internal/metrics" - "github.com/ethersphere/bee/pkg/topology/kademlia/internal/waitnext" - "github.com/ethersphere/bee/pkg/topology/pslice" + "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/discovery" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/shed" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + im "github.com/ethersphere/bee/v2/pkg/topology/kademlia/internal/metrics" + "github.com/ethersphere/bee/v2/pkg/topology/kademlia/internal/waitnext" + "github.com/ethersphere/bee/v2/pkg/topology/pslice" ma "github.com/multiformats/go-multiaddr" "golang.org/x/sync/errgroup" ) @@ -913,7 +913,7 @@ func (k *Kad) recalcDepth() { } // connect connects to a peer and gossips its address to our connected peers, -// as well as sends the peers we are connected to to the newly connected peer +// as well as sends the peers we are connected to the newly connected peer func (k *Kad) connect(ctx context.Context, peer swarm.Address, ma ma.Multiaddr) error { k.logger.Debug("attempting connect to peer", "peer_address", peer) diff --git a/pkg/topology/kademlia/kademlia_test.go b/pkg/topology/kademlia/kademlia_test.go index 48e0c20ecb7..e3cd6912ebc 100644 --- a/pkg/topology/kademlia/kademlia_test.go +++ b/pkg/topology/kademlia/kademlia_test.go @@ -18,21 +18,21 @@ import ( ma "github.com/multiformats/go-multiaddr" - "github.com/ethersphere/bee/pkg/addressbook" - "github.com/ethersphere/bee/pkg/bzz" - beeCrypto "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/discovery/mock" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - p2pmock "github.com/ethersphere/bee/pkg/p2p/mock" - "github.com/ethersphere/bee/pkg/spinlock" - mockstate "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/topology/kademlia" - im "github.com/ethersphere/bee/pkg/topology/kademlia/internal/metrics" - "github.com/ethersphere/bee/pkg/topology/pslice" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/addressbook" + "github.com/ethersphere/bee/v2/pkg/bzz" + beeCrypto "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/discovery/mock" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + p2pmock "github.com/ethersphere/bee/v2/pkg/p2p/mock" + "github.com/ethersphere/bee/v2/pkg/spinlock" + mockstate "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/topology/kademlia" + im "github.com/ethersphere/bee/v2/pkg/topology/kademlia/internal/metrics" + "github.com/ethersphere/bee/v2/pkg/topology/pslice" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) const spinLockWaitTime = time.Second * 5 diff --git a/pkg/topology/kademlia/metrics.go b/pkg/topology/kademlia/metrics.go index 3640ca7fd54..42e1d6c294a 100644 --- a/pkg/topology/kademlia/metrics.go +++ b/pkg/topology/kademlia/metrics.go @@ -5,7 +5,7 @@ package kademlia import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/topology/kademlia/mock/kademlia.go b/pkg/topology/kademlia/mock/kademlia.go index 23713a129c6..cd115bf7186 100644 --- a/pkg/topology/kademlia/mock/kademlia.go +++ b/pkg/topology/kademlia/mock/kademlia.go @@ -9,9 +9,9 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" ) type AddrTuple struct { diff --git a/pkg/topology/lightnode/container.go b/pkg/topology/lightnode/container.go index 5f2285a06a4..0e4f6c3967c 100644 --- a/pkg/topology/lightnode/container.go +++ b/pkg/topology/lightnode/container.go @@ -10,10 +10,10 @@ import ( "math/big" "sync" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/topology/pslice" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/topology/pslice" ) type Container struct { diff --git a/pkg/topology/lightnode/container_test.go b/pkg/topology/lightnode/container_test.go index 3533dcc089f..20a7664adc5 100644 --- a/pkg/topology/lightnode/container_test.go +++ b/pkg/topology/lightnode/container_test.go @@ -10,10 +10,10 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" - "github.com/ethersphere/bee/pkg/topology/lightnode" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/topology/lightnode" ) func TestContainer(t *testing.T) { diff --git a/pkg/topology/lightnode/metrics.go b/pkg/topology/lightnode/metrics.go index f6c6ff2bbc1..cea1504f8a9 100644 --- a/pkg/topology/lightnode/metrics.go +++ b/pkg/topology/lightnode/metrics.go @@ -5,7 +5,7 @@ package lightnode import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/topology/mock/mock.go b/pkg/topology/mock/mock.go index f052045920b..f545bfee858 100644 --- a/pkg/topology/mock/mock.go +++ b/pkg/topology/mock/mock.go @@ -10,9 +10,9 @@ import ( "sync" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" ) type mock struct { diff --git a/pkg/topology/pslice/pslice.go b/pkg/topology/pslice/pslice.go index 0337fa0125d..ca1b8e5c4c3 100644 --- a/pkg/topology/pslice/pslice.go +++ b/pkg/topology/pslice/pslice.go @@ -7,8 +7,8 @@ package pslice import ( "sync" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/topology" ) // PSlice maintains a list of addresses, indexing them by their different proximity orders. diff --git a/pkg/topology/pslice/pslice_test.go b/pkg/topology/pslice/pslice_test.go index 37e454871ce..9bcdf1312e2 100644 --- a/pkg/topology/pslice/pslice_test.go +++ b/pkg/topology/pslice/pslice_test.go @@ -9,9 +9,9 @@ import ( "sort" "testing" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" - "github.com/ethersphere/bee/pkg/topology/pslice" + "github.com/ethersphere/bee/v2/pkg/topology/pslice" ) // TestShallowestEmpty tests that ShallowestEmpty functionality works correctly. diff --git a/pkg/topology/topology.go b/pkg/topology/topology.go index ebc7bcf8670..63747a912c6 100644 --- a/pkg/topology/topology.go +++ b/pkg/topology/topology.go @@ -11,8 +11,8 @@ import ( "io" "time" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/swarm" ) var ( diff --git a/pkg/tracing/tracing.go b/pkg/tracing/tracing.go index 14ccdb9ab43..e9c563464fa 100644 --- a/pkg/tracing/tracing.go +++ b/pkg/tracing/tracing.go @@ -13,8 +13,8 @@ import ( "net/http" "time" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" "github.com/opentracing/opentracing-go" "github.com/uber/jaeger-client-go" "github.com/uber/jaeger-client-go/config" diff --git a/pkg/tracing/tracing_test.go b/pkg/tracing/tracing_test.go index 8a2f871dc45..9c0baa2f685 100644 --- a/pkg/tracing/tracing_test.go +++ b/pkg/tracing/tracing_test.go @@ -11,10 +11,10 @@ import ( "fmt" "testing" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/p2p" - "github.com/ethersphere/bee/pkg/tracing" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/p2p" + "github.com/ethersphere/bee/v2/pkg/tracing" + "github.com/ethersphere/bee/v2/pkg/util/testutil" "github.com/uber/jaeger-client-go" ) diff --git a/pkg/transaction/backend.go b/pkg/transaction/backend.go index df479d55829..be1f958b317 100644 --- a/pkg/transaction/backend.go +++ b/pkg/transaction/backend.go @@ -13,7 +13,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/log" ) // Backend is the minimum of blockchain backend functions we need. diff --git a/pkg/transaction/backend_test.go b/pkg/transaction/backend_test.go index 8ca76fec823..d9d09e55b3c 100644 --- a/pkg/transaction/backend_test.go +++ b/pkg/transaction/backend_test.go @@ -12,8 +12,8 @@ import ( "time" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/transaction/backendmock" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction/backendmock" ) func TestIsSynced(t *testing.T) { diff --git a/pkg/transaction/backendmock/backend.go b/pkg/transaction/backendmock/backend.go index 7f787fe3d60..3a78f325c0c 100644 --- a/pkg/transaction/backendmock/backend.go +++ b/pkg/transaction/backendmock/backend.go @@ -12,7 +12,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction" ) type backendMock struct { diff --git a/pkg/transaction/backendsimulation/backend.go b/pkg/transaction/backendsimulation/backend.go index 2b3a3946864..57965abe7ea 100644 --- a/pkg/transaction/backendsimulation/backend.go +++ b/pkg/transaction/backendsimulation/backend.go @@ -12,7 +12,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction" ) type AccountAtKey struct { diff --git a/pkg/transaction/event_test.go b/pkg/transaction/event_test.go index 4d6dd47193e..e286796d248 100644 --- a/pkg/transaction/event_test.go +++ b/pkg/transaction/event_test.go @@ -11,8 +11,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" "github.com/ethersphere/go-sw3-abi/sw3abi" ) diff --git a/pkg/transaction/mock/transaction.go b/pkg/transaction/mock/transaction.go index 7478daa63e6..d987fd52249 100644 --- a/pkg/transaction/mock/transaction.go +++ b/pkg/transaction/mock/transaction.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction" ) type transactionServiceMock struct { diff --git a/pkg/transaction/monitor.go b/pkg/transaction/monitor.go index 64d58be7c5c..f4ebcd3be92 100644 --- a/pkg/transaction/monitor.go +++ b/pkg/transaction/monitor.go @@ -15,7 +15,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/log" + "github.com/ethersphere/bee/v2/pkg/log" ) var ErrTransactionCancelled = errors.New("transaction cancelled") diff --git a/pkg/transaction/monitor_test.go b/pkg/transaction/monitor_test.go index 5887848ac2c..7b88e84629f 100644 --- a/pkg/transaction/monitor_test.go +++ b/pkg/transaction/monitor_test.go @@ -11,9 +11,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/transaction/backendsimulation" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction/backendsimulation" ) func TestMonitorWatchTransaction(t *testing.T) { diff --git a/pkg/transaction/monitormock/monitor.go b/pkg/transaction/monitormock/monitor.go index a0334469873..1662751aa74 100644 --- a/pkg/transaction/monitormock/monitor.go +++ b/pkg/transaction/monitormock/monitor.go @@ -11,7 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction" ) type transactionMonitorMock struct { diff --git a/pkg/transaction/transaction.go b/pkg/transaction/transaction.go index 592af68a566..2774aad95af 100644 --- a/pkg/transaction/transaction.go +++ b/pkg/transaction/transaction.go @@ -19,10 +19,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/sctx" - "github.com/ethersphere/bee/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/sctx" + "github.com/ethersphere/bee/v2/pkg/storage" "golang.org/x/net/context" ) diff --git a/pkg/transaction/transaction_test.go b/pkg/transaction/transaction_test.go index 0bc8be4f361..41cf94f0112 100644 --- a/pkg/transaction/transaction_test.go +++ b/pkg/transaction/transaction_test.go @@ -18,16 +18,16 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" - "github.com/ethersphere/bee/pkg/crypto" - signermock "github.com/ethersphere/bee/pkg/crypto/mock" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/sctx" - storemock "github.com/ethersphere/bee/pkg/statestore/mock" - "github.com/ethersphere/bee/pkg/transaction" - "github.com/ethersphere/bee/pkg/transaction/backendmock" - "github.com/ethersphere/bee/pkg/transaction/monitormock" - "github.com/ethersphere/bee/pkg/util/abiutil" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/crypto" + signermock "github.com/ethersphere/bee/v2/pkg/crypto/mock" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/sctx" + storemock "github.com/ethersphere/bee/v2/pkg/statestore/mock" + "github.com/ethersphere/bee/v2/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction/backendmock" + "github.com/ethersphere/bee/v2/pkg/transaction/monitormock" + "github.com/ethersphere/bee/v2/pkg/util/abiutil" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) func nonceKey(sender common.Address) string { diff --git a/pkg/transaction/wrapped/metrics.go b/pkg/transaction/wrapped/metrics.go index bc555032fdf..eeb255c3d3b 100644 --- a/pkg/transaction/wrapped/metrics.go +++ b/pkg/transaction/wrapped/metrics.go @@ -5,7 +5,7 @@ package wrapped import ( - m "github.com/ethersphere/bee/pkg/metrics" + m "github.com/ethersphere/bee/v2/pkg/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/transaction/wrapped/wrapped.go b/pkg/transaction/wrapped/wrapped.go index 24d8e3d5a0c..f810ee2ebab 100644 --- a/pkg/transaction/wrapped/wrapped.go +++ b/pkg/transaction/wrapped/wrapped.go @@ -12,7 +12,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethersphere/bee/pkg/transaction" + "github.com/ethersphere/bee/v2/pkg/transaction" ) var ( diff --git a/pkg/traversal/traversal.go b/pkg/traversal/traversal.go index dbdb5603e82..98029f925d9 100644 --- a/pkg/traversal/traversal.go +++ b/pkg/traversal/traversal.go @@ -13,13 +13,13 @@ import ( "errors" "fmt" - "github.com/ethersphere/bee/pkg/file/joiner" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/manifest" - "github.com/ethersphere/bee/pkg/manifest/mantaray" - "github.com/ethersphere/bee/pkg/soc" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/file/joiner" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/manifest" + "github.com/ethersphere/bee/v2/pkg/manifest/mantaray" + "github.com/ethersphere/bee/v2/pkg/soc" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/swarm" ) // Traverser represents service which traverse through address dependent chunks. diff --git a/pkg/traversal/traversal_test.go b/pkg/traversal/traversal_test.go index 7d9d473e1e4..04f0068c6de 100644 --- a/pkg/traversal/traversal_test.go +++ b/pkg/traversal/traversal_test.go @@ -14,15 +14,15 @@ import ( "testing" "time" - "github.com/ethersphere/bee/pkg/file/loadsave" - "github.com/ethersphere/bee/pkg/file/pipeline" - "github.com/ethersphere/bee/pkg/file/pipeline/builder" - "github.com/ethersphere/bee/pkg/manifest" - testingsoc "github.com/ethersphere/bee/pkg/soc/testing" - storage "github.com/ethersphere/bee/pkg/storage" - "github.com/ethersphere/bee/pkg/storage/inmemchunkstore" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/traversal" + "github.com/ethersphere/bee/v2/pkg/file/loadsave" + "github.com/ethersphere/bee/v2/pkg/file/pipeline" + "github.com/ethersphere/bee/v2/pkg/file/pipeline/builder" + "github.com/ethersphere/bee/v2/pkg/manifest" + testingsoc "github.com/ethersphere/bee/v2/pkg/soc/testing" + storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage/inmemchunkstore" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/traversal" ) const ( diff --git a/pkg/util/nbhdutil/miner.go b/pkg/util/nbhdutil/miner.go index 4d6f38a6f1d..83a51a8eeb7 100644 --- a/pkg/util/nbhdutil/miner.go +++ b/pkg/util/nbhdutil/miner.go @@ -10,8 +10,8 @@ import ( "encoding/binary" "fmt" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/swarm" ) func MineOverlay(ctx context.Context, p ecdsa.PublicKey, networkID uint64, targetNeighborhood string) (swarm.Address, []byte, error) { diff --git a/pkg/util/nbhdutil/miner_test.go b/pkg/util/nbhdutil/miner_test.go index 2b630af3c19..bcf72128bb9 100644 --- a/pkg/util/nbhdutil/miner_test.go +++ b/pkg/util/nbhdutil/miner_test.go @@ -9,9 +9,9 @@ import ( "math/rand" "testing" - "github.com/ethersphere/bee/pkg/crypto" - "github.com/ethersphere/bee/pkg/swarm" - "github.com/ethersphere/bee/pkg/util/nbhdutil" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/util/nbhdutil" ) func TestMiner(t *testing.T) { diff --git a/pkg/util/nbhdutil/neighborhoodsuggestion.go b/pkg/util/nbhdutil/neighborhoodsuggestion.go new file mode 100644 index 00000000000..699bc37505b --- /dev/null +++ b/pkg/util/nbhdutil/neighborhoodsuggestion.go @@ -0,0 +1,53 @@ +// Copyright 2024 The Swarm Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package nbhdutil + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + + "github.com/ethersphere/bee/v2/pkg/swarm" +) + +type httpClient interface { + Get(url string) (*http.Response, error) +} + +func FetchNeighborhood(client httpClient, suggester string) (string, error) { + if suggester == "" { + return "", nil + } + + _, err := url.ParseRequestURI(suggester) + if err != nil { + return "", err + } + + type suggestionRes struct { + Neighborhood string `json:"neighborhood"` + } + res, err := client.Get(suggester) + if err != nil { + return "", err + } + defer res.Body.Close() + var suggestion suggestionRes + d, err := io.ReadAll(res.Body) + if err != nil { + return "", err + } + err = json.Unmarshal(d, &suggestion) + if err != nil { + return "", err + } + _, err = swarm.ParseBitStrAddress(suggestion.Neighborhood) + if err != nil { + return "", fmt.Errorf("invalid neighborhood. %s", suggestion.Neighborhood) + } + return suggestion.Neighborhood, nil +} diff --git a/pkg/util/nbhdutil/neighborhoodsuggestion_test.go b/pkg/util/nbhdutil/neighborhoodsuggestion_test.go new file mode 100644 index 00000000000..cf477800882 --- /dev/null +++ b/pkg/util/nbhdutil/neighborhoodsuggestion_test.go @@ -0,0 +1,86 @@ +// Copyright 2024 The Swarm Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package nbhdutil_test + +import ( + "io" + "net/http" + "strings" + "testing" + + "github.com/ethersphere/bee/v2/pkg/util/nbhdutil" +) + +type mockHttpClient struct { + res string +} + +func (c *mockHttpClient) Get(_ string) (*http.Response, error) { + return &http.Response{ + Body: io.NopCloser(strings.NewReader(c.res)), + }, nil +} + +func Test_FetchNeighborhood(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + neighborhood string + suggester string + httpRes string + wantNeighborhood string + wantError bool + }{ + { + name: "no suggester", + suggester: "", + wantNeighborhood: "", + wantError: false, + }, + { + name: "inavlid suggester url", + suggester: "abc", + wantNeighborhood: "", + wantError: true, + }, + { + name: "missing neighborhood in res", + suggester: "http://test.com", + wantNeighborhood: "", + wantError: false, + httpRes: `{"abc":"abc"}`, + }, + { + name: "invalid neighborhood", + suggester: "http://test.com", + wantNeighborhood: "", + wantError: true, + httpRes: `{"neighborhood":"abc"}`, + }, + { + name: "valid neighborhood", + suggester: "http://test.com", + wantNeighborhood: "11011101000", + wantError: false, + httpRes: `{"neighborhood":"11011101000"}`, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + neighborhood, err := nbhdutil.FetchNeighborhood(&mockHttpClient{res: test.httpRes}, test.suggester) + if test.wantNeighborhood != neighborhood { + t.Fatalf("invalid neighborhood. want %s, got %s", test.wantNeighborhood, neighborhood) + } + if test.wantError && err == nil { + t.Fatalf("expected error. got no error") + } + if !test.wantError && err != nil { + t.Fatalf("expected no error. got %v", err) + } + }) + } +} diff --git a/pkg/util/testutil/helpers.go b/pkg/util/testutil/helpers.go index da9488e0987..1726e33d020 100644 --- a/pkg/util/testutil/helpers.go +++ b/pkg/util/testutil/helpers.go @@ -11,8 +11,8 @@ import ( "reflect" "testing" - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/util/ioutil" + "github.com/ethersphere/bee/v2/pkg/log" + "github.com/ethersphere/bee/v2/pkg/util/ioutil" ) // RandBytes returns bytes slice of specified size filled with random values. diff --git a/pkg/util/testutil/helpers_test.go b/pkg/util/testutil/helpers_test.go index d74c8ad4bca..7ad37a272f9 100644 --- a/pkg/util/testutil/helpers_test.go +++ b/pkg/util/testutil/helpers_test.go @@ -8,7 +8,7 @@ import ( "bytes" "testing" - "github.com/ethersphere/bee/pkg/util/testutil" + "github.com/ethersphere/bee/v2/pkg/util/testutil" ) func TestRandBytes(t *testing.T) { diff --git a/pkg/util/testutil/pseudorand/reader.go b/pkg/util/testutil/pseudorand/reader.go index d7fcf0c3646..bccb8900d7e 100644 --- a/pkg/util/testutil/pseudorand/reader.go +++ b/pkg/util/testutil/pseudorand/reader.go @@ -16,7 +16,7 @@ import ( "fmt" "io" - "github.com/ethersphere/bee/pkg/swarm" + "github.com/ethersphere/bee/v2/pkg/swarm" ) const bufSize = 4096 diff --git a/pkg/util/testutil/pseudorand/reader_test.go b/pkg/util/testutil/pseudorand/reader_test.go index 4ec85a90d73..2abd6aaf382 100644 --- a/pkg/util/testutil/pseudorand/reader_test.go +++ b/pkg/util/testutil/pseudorand/reader_test.go @@ -12,7 +12,7 @@ import ( "math/rand" "testing" - "github.com/ethersphere/bee/pkg/util/testutil/pseudorand" + "github.com/ethersphere/bee/v2/pkg/util/testutil/pseudorand" ) func TestReader(t *testing.T) {