Commit b9697beb authored by Hector Sanjuan's avatar Hector Sanjuan

Extract from go-ipfs: readme, travis, gx, license etc.

parent d427bf1a
sudo: false
language: go
go:
- 1.9
install:
- go get github.com/whyrusleeping/gx
- go get github.com/whyrusleeping/gx-go
script:
- make test
after_success:
- bash <(curl -s https://codecov.io/bash)
cache:
directories:
- $GOPATH/src/gx
notifications:
email: false
MIT License
Copyright (c) 2018 IPFS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
all: deps
gx:
go get github.com/whyrusleeping/gx
go get github.com/whyrusleeping/gx-go
deps: gx
gx --verbose install --global
gx-go rewrite
test: deps
gx test -v -race -coverprofile=coverage.txt -covermode=atomic .
rw:
gx-go rewrite
rwundo:
gx-go rewrite --undo
publish: rwundo
gx publish
.PHONY: all gx deps test rw rwundo publish
# go-ipfs-blockstore
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![GoDoc](https://godoc.org/github.com/ipfs/go-ipfs-blockstore?status.svg)](https://godoc.org/github.com/ipfs/go-ipfs-blockstore)
[![Build Status](https://travis-ci.org/ipfs/go-ipfs-blockstore.svg?branch=master)](https://travis-ci.org/ipfs/go-ipfs-blockstore)
> go-ipfs-blockstore implements a thin wrapper over a datastore, giving a clean interface for Getting and Putting block objects.
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#license)
## Install
`go-ipfs-blockstore` works like a regular Go module:
```
> go get github.com/ipfs/go-ipfs-blockstore
```
## Usage
```
import "github.com/ipfs/go-ipfs-blockstore"
```
Check the [GoDoc documentation](https://godoc.org/github.com/ipfs/go-ipfs-blockstore)
This module uses [Gx](https://github.com/whyrusleeping/gx) to manage dependencies. You can use `make all` to build it with the `gx` dependencies.
## Contribute
PRs accepted.
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
## License
MIT © Protocol Labs, Inc.
......@@ -3,12 +3,11 @@ package blockstore
import (
"context"
"gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
"gx/ipfs/QmRg1gKTHzc3CZXSKzem8aR4E3TubFhbgXwfVuWnSK5CC5/go-metrics-interface"
lru "gx/ipfs/QmVYxfoJQiZijTgPNHCHgHELvQpbsJNTg6Crmc3dQkj3yy/golang-lru"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
lru "github.com/hashicorp/golang-lru"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
metrics "github.com/ipfs/go-metrics-interface"
)
// arccache wraps a BlockStore with an Adaptive Replacement Cache (ARC) for
......
......@@ -4,11 +4,10 @@ import (
"context"
"testing"
"gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
syncds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
"github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
syncds "github.com/ipfs/go-datastore/sync"
)
var exampleBlock = blocks.NewBlock([]byte("foo"))
......
......@@ -8,13 +8,13 @@ import (
"sync"
"sync/atomic"
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
dsns "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/namespace"
dsq "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/query"
logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
dshelp "gx/ipfs/QmdQTPWduSeyveSxeCAte33M592isSW5Z979g81aJphrgn/go-ipfs-ds-help"
blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
dsns "github.com/ipfs/go-datastore/namespace"
dsq "github.com/ipfs/go-datastore/query"
dshelp "github.com/ipfs/go-ipfs-ds-help"
logging "github.com/ipfs/go-log"
)
var log = logging.Logger("blockstore")
......
......@@ -6,13 +6,13 @@ import (
"fmt"
"testing"
u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
dsq "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/query"
ds_sync "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
dshelp "gx/ipfs/QmdQTPWduSeyveSxeCAte33M592isSW5Z979g81aJphrgn/go-ipfs-ds-help"
blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
dsq "github.com/ipfs/go-datastore/query"
ds_sync "github.com/ipfs/go-datastore/sync"
dshelp "github.com/ipfs/go-ipfs-ds-help"
u "github.com/ipfs/go-ipfs-util"
)
func TestGetWhenKeyNotPresent(t *testing.T) {
......
......@@ -5,11 +5,10 @@ import (
"sync/atomic"
"time"
"gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
"gx/ipfs/QmRg1gKTHzc3CZXSKzem8aR4E3TubFhbgXwfVuWnSK5CC5/go-metrics-interface"
bloom "gx/ipfs/QmXqKGu7QzfRzFC4yd5aL9sThYx22vY163VGwmxfp5qGHk/bbloom"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
bloom "github.com/gxed/bbloom"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
metrics "github.com/ipfs/go-metrics-interface"
)
// bloomCached returns a Blockstore that caches Has requests using a Bloom
......
package blockstore
import (
"context"
"fmt"
"sync"
"testing"
"time"
"gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
context "context"
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
dsq "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/query"
syncds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
blocks "github.com/ipfs/go-block-format"
ds "github.com/ipfs/go-datastore"
dsq "github.com/ipfs/go-datastore/query"
syncds "github.com/ipfs/go-datastore/sync"
)
func testBloomCached(ctx context.Context, bs Blockstore) (*bloomcache, error) {
......
package blockstore
import (
"context"
"errors"
context "context"
"gx/ipfs/QmRg1gKTHzc3CZXSKzem8aR4E3TubFhbgXwfVuWnSK5CC5/go-metrics-interface"
metrics "github.com/ipfs/go-metrics-interface"
)
// CacheOpts wraps options for CachedBlockStore().
......
mode: atomic
github.com/ipfs/go-ipfs-blockstore/caching.go:20.35,26.2 1 15
github.com/ipfs/go-ipfs-blockstore/caching.go:33.46,37.28 2 15
github.com/ipfs/go-ipfs-blockstore/caching.go:41.2,41.68 1 12
github.com/ipfs/go-ipfs-blockstore/caching.go:45.2,47.30 2 11
github.com/ipfs/go-ipfs-blockstore/caching.go:50.2,50.34 1 11
github.com/ipfs/go-ipfs-blockstore/caching.go:55.2,55.17 1 11
github.com/ipfs/go-ipfs-blockstore/caching.go:37.28,39.3 1 3
github.com/ipfs/go-ipfs-blockstore/caching.go:41.68,43.3 1 1
github.com/ipfs/go-ipfs-blockstore/caching.go:47.30,49.3 1 9
github.com/ipfs/go-ipfs-blockstore/caching.go:50.34,53.3 1 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:25.89,27.16 2 10
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:30.2,34.15 4 9
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:27.16,29.3 1 1
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:37.50,38.43 1 3
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:42.2,44.13 3 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:38.43,40.3 1 1
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:45.40,47.13 2 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:48.10,49.13 1 0
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:55.62,57.14 2 25
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:64.2,65.8 2 25
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:69.2,69.21 1 8
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:57.14,62.3 2 0
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:65.8,68.3 2 17
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:72.50,73.35 1 9
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:77.2,78.16 2 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:81.2,81.17 1 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:73.35,75.3 1 7
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:78.16,80.3 1 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:84.58,85.14 1 5
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:90.2,90.43 1 4
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:94.2,95.37 2 3
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:100.2,100.16 1 3
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:85.14,88.3 2 1
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:90.43,92.3 1 1
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:95.37,97.3 1 1
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:97.3,97.22 1 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:97.22,99.3 1 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:103.47,104.49 1 7
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:108.2,109.16 2 6
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:112.2,112.12 1 6
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:104.49,106.3 1 1
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:109.16,111.3 1 6
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:115.53,117.27 2 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:124.2,125.16 2 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:128.2,128.29 1 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:131.2,131.12 1 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:117.27,120.63 1 2
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:120.63,122.4 1 1
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:125.16,127.3 1 0
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:128.29,130.3 1 1
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:134.45,136.2 1 0
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:138.51,140.2 1 14
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:142.78,144.2 1 0
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:146.38,148.2 1 0
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:150.39,152.2 1 0
github.com/ipfs/go-ipfs-blockstore/arc_cache.go:154.39,156.2 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:88.64,90.2 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:99.46,106.2 4 19
github.com/ipfs/go-ipfs-blockstore/blockstore.go:114.48,116.2 1 1
github.com/ipfs/go-ipfs-blockstore/blockstore.go:118.61,119.14 1 10
github.com/ipfs/go-ipfs-blockstore/blockstore.go:124.2,125.27 2 9
github.com/ipfs/go-ipfs-blockstore/blockstore.go:128.2,128.16 1 7
github.com/ipfs/go-ipfs-blockstore/blockstore.go:131.2,132.9 2 7
github.com/ipfs/go-ipfs-blockstore/blockstore.go:136.2,136.15 1 6
github.com/ipfs/go-ipfs-blockstore/blockstore.go:148.2,148.41 1 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:119.14,122.3 2 1
github.com/ipfs/go-ipfs-blockstore/blockstore.go:125.27,127.3 1 2
github.com/ipfs/go-ipfs-blockstore/blockstore.go:128.16,130.3 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:132.9,134.3 1 1
github.com/ipfs/go-ipfs-blockstore/blockstore.go:136.15,138.17 2 2
github.com/ipfs/go-ipfs-blockstore/blockstore.go:142.3,142.23 1 2
github.com/ipfs/go-ipfs-blockstore/blockstore.go:146.3,146.46 1 1
github.com/ipfs/go-ipfs-blockstore/blockstore.go:138.17,140.4 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:142.23,144.4 1 1
github.com/ipfs/go-ipfs-blockstore/blockstore.go:151.53,156.26 3 1212
github.com/ipfs/go-ipfs-blockstore/blockstore.go:159.2,159.45 1 1211
github.com/ipfs/go-ipfs-blockstore/blockstore.go:156.26,158.3 1 1
github.com/ipfs/go-ipfs-blockstore/blockstore.go:162.60,164.16 2 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:167.2,167.27 1 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:179.2,179.19 1 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:164.16,166.3 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:167.27,170.27 3 3
github.com/ipfs/go-ipfs-blockstore/blockstore.go:174.3,175.17 2 3
github.com/ipfs/go-ipfs-blockstore/blockstore.go:170.27,171.12 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:175.17,177.4 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:182.53,184.2 1 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:186.53,188.27 2 2
github.com/ipfs/go-ipfs-blockstore/blockstore.go:191.2,191.12 1 2
github.com/ipfs/go-ipfs-blockstore/blockstore.go:188.27,190.3 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:198.81,203.16 3 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:207.2,208.12 2 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:239.2,239.20 1 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:203.16,205.3 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:208.12,209.16 1 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:214.3,214.7 1 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:209.16,212.4 2 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:214.7,216.11 2 1105
github.com/ipfs/go-ipfs-blockstore/blockstore.go:219.4,219.22 1 1101
github.com/ipfs/go-ipfs-blockstore/blockstore.go:225.4,226.18 2 1101
github.com/ipfs/go-ipfs-blockstore/blockstore.go:231.4,231.11 1 1100
github.com/ipfs/go-ipfs-blockstore/blockstore.go:216.11,218.5 1 4
github.com/ipfs/go-ipfs-blockstore/blockstore.go:219.22,222.5 2 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:226.18,228.13 2 1
github.com/ipfs/go-ipfs-blockstore/blockstore.go:232.22,233.11 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:234.21,234.21 0 1100
github.com/ipfs/go-ipfs-blockstore/blockstore.go:244.29,246.2 1 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:263.29,266.2 2 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:268.39,273.2 4 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:275.40,278.2 2 0
github.com/ipfs/go-ipfs-blockstore/blockstore.go:280.40,282.2 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:18.101,20.16 2 3
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:23.2,31.22 6 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:49.2,49.16 1 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:20.16,22.3 1 1
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:31.22,32.13 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:32.13,38.8 4 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:38.8,39.12 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:40.23,42.12 2 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:43.16,44.36 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:65.35,68.2 2 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:70.41,72.2 1 1004
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:74.51,79.16 4 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:83.2,84.14 2 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:97.2,98.33 2 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:79.16,82.3 2 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:84.14,85.10 1 1002
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:86.24,87.10 1 1002
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:92.21,94.10 2 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:87.10,89.5 1 1000
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:89.5,91.5 1 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:101.52,102.43 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:106.2,106.36 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:102.43,104.3 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:111.64,113.14 2 1004
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:119.2,119.21 1 1004
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:126.2,126.21 1 3
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:113.14,118.3 2 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:119.21,121.11 2 1004
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:121.11,124.4 2 1001
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:129.52,130.35 1 1003
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:134.2,134.28 1 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:130.35,132.3 1 1001
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:137.60,138.43 1 1
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:142.2,142.28 1 1
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:138.43,140.3 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:145.49,148.16 2 1
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:151.2,151.12 1 1
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:148.16,150.3 1 1
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:154.55,160.16 2 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:163.2,163.24 1 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:166.2,166.12 1 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:160.16,162.3 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:163.24,165.3 1 2
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:169.47,171.2 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:173.80,175.2 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:177.40,179.2 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:181.41,183.2 1 0
github.com/ipfs/go-ipfs-blockstore/bloom_cache.go:185.41,187.2 1 0
{
"author": "hsanjuan",
"bugs": {
"url": "https://github.com/ipfs/go-ipfs-blockstore"
},
"gx": {
"dvcsimport": "github.com/ipfs/go-ipfs-blockstore"
},
"gxDependencies": [
{
"author": "stebalien",
"hash": "Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2",
"name": "go-block-format",
"version": "0.1.6"
},
{
"author": "jbenet",
"hash": "QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg",
"name": "go-datastore",
"version": "1.4.1"
},
{
"author": "ipfs",
"hash": "QmRg1gKTHzc3CZXSKzem8aR4E3TubFhbgXwfVuWnSK5CC5",
"name": "go-metrics-interface",
"version": "0.1.2"
},
{
"author": "hashicorp",
"hash": "QmVYxfoJQiZijTgPNHCHgHELvQpbsJNTg6Crmc3dQkj3yy",
"name": "golang-lru",
"version": "0.0.0"
},
{
"author": "whyrusleeping",
"hash": "QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY",
"name": "go-cid",
"version": "0.7.20"
},
{
"author": "hector",
"hash": "QmdQTPWduSeyveSxeCAte33M592isSW5Z979g81aJphrgn",
"name": "go-ipfs-ds-help",
"version": "0.0.1"
},
{
"author": "kubuxu",
"hash": "QmXqKGu7QzfRzFC4yd5aL9sThYx22vY163VGwmxfp5qGHk",
"name": "bbloom",
"version": "0.1.1"
},
{
"hash": "QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8",
"name": "go-log",
"version": "1.4.0"
}
],
"gxVersion": "0.12.1",
"language": "go",
"license": "MIT",
"name": "go-ipfs-blockstore",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "0.0.0"
}
// Package blockstoreutil provides utility functions for Blockstores.
package blockstoreutil
import (
"fmt"
"io"
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
bs "github.com/ipfs/go-ipfs/blocks/blockstore"
"github.com/ipfs/go-ipfs/pin"
)
// RemovedBlock is used to respresent the result of removing a block.
// If a block was removed successfully than the Error string will be
// empty. If a block could not be removed than Error will contain the
// reason the block could not be removed. If the removal was aborted
// due to a fatal error Hash will be be empty, Error will contain the
// reason, and no more results will be sent.
type RemovedBlock struct {
Hash string `json:",omitempty"`
Error string `json:",omitempty"`
}
// RmBlocksOpts is used to wrap options for RmBlocks().
type RmBlocksOpts struct {
Prefix string
Quiet bool
Force bool
}
// RmBlocks removes the blocks provided in the cids slice.
// It returns a channel where objects of type RemovedBlock are placed, when
// not using the Quiet option. Block removal is asynchronous and will
// skip any pinned blocks.
func RmBlocks(blocks bs.GCBlockstore, pins pin.Pinner, cids []*cid.Cid, opts RmBlocksOpts) (<-chan interface{}, error) {
// make the channel large enough to hold any result to avoid
// blocking while holding the GCLock
out := make(chan interface{}, len(cids))
go func() {
defer close(out)
unlocker := blocks.GCLock()
defer unlocker.Unlock()
stillOkay := FilterPinned(pins, out, cids)
for _, c := range stillOkay {
err := blocks.DeleteBlock(c)
if err != nil && opts.Force && (err == bs.ErrNotFound || err == ds.ErrNotFound) {
// ignore non-existent blocks
} else if err != nil {
out <- &RemovedBlock{Hash: c.String(), Error: err.Error()}
} else if !opts.Quiet {
out <- &RemovedBlock{Hash: c.String()}
}
}
}()
return out, nil
}
// FilterPinned takes a slice of Cids and returns it with the pinned Cids
// removed. If a Cid is pinned, it will place RemovedBlock objects in the given
// out channel, with an error which indicates that the Cid is pinned.
// This function is used in RmBlocks to filter out any blocks which are not
// to be removed (because they are pinned).
func FilterPinned(pins pin.Pinner, out chan<- interface{}, cids []*cid.Cid) []*cid.Cid {
stillOkay := make([]*cid.Cid, 0, len(cids))
res, err := pins.CheckIfPinned(cids...)
if err != nil {
out <- &RemovedBlock{Error: fmt.Sprintf("pin check failed: %s", err)}
return nil
}
for _, r := range res {
if !r.Pinned() {
stillOkay = append(stillOkay, r.Key)
} else {
out <- &RemovedBlock{
Hash: r.Key.String(),
Error: r.String(),
}
}
}
return stillOkay
}
// ProcRmOutput takes a function which returns a result from RmBlocks or EOF if there is no input.
// It then writes to stdout/stderr according to the RemovedBlock object returned from the function.
func ProcRmOutput(next func() (interface{}, error), sout io.Writer, serr io.Writer) error {
someFailed := false
for {
res, err := next()
if err == io.EOF {
break
} else if err != nil {
return err
}
r := res.(*RemovedBlock)
if r.Hash == "" && r.Error != "" {
return fmt.Errorf("aborted: %s", r.Error)
} else if r.Error != "" {
someFailed = true
fmt.Fprintf(serr, "cannot remove %s: %s\n", r.Hash, r.Error)
} else {
fmt.Fprintf(sout, "removed %s\n", r.Hash)
}
}
if someFailed {
return fmt.Errorf("some blocks not removed")
}
return nil
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment