Documentation
¶
Overview ¶
Package blockstore and subpackages contain most of the blockstore implementations used by Lotus.
Blockstores not ultimately constructed out of the building blocks in this package may not work properly.
This package re-exports parts of the go-ipfs-blockstore package such that no other package needs to import it directly, for ergonomics and traceability.
Index ¶
- Variables
- func IsHotView(ctx context.Context) bool
- func WithHotView(ctx context.Context) context.Context
- type AutobatchBlockstore
- func (bs *AutobatchBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (bs *AutobatchBlockstore) DeleteBlock(context.Context, cid.Cid) error
- func (bs *AutobatchBlockstore) DeleteMany(ctx context.Context, cids []cid.Cid) error
- func (bs *AutobatchBlockstore) Flush(ctx context.Context) error
- func (bs *AutobatchBlockstore) Get(ctx context.Context, c cid.Cid) (block.Block, error)
- func (bs *AutobatchBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error)
- func (bs *AutobatchBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error)
- func (bs *AutobatchBlockstore) Put(ctx context.Context, blk block.Block) error
- func (bs *AutobatchBlockstore) PutMany(ctx context.Context, blks []block.Block) error
- func (bs *AutobatchBlockstore) Shutdown(ctx context.Context) error
- func (bs *AutobatchBlockstore) View(ctx context.Context, cid cid.Cid, callback func([]byte) error) error
- type BasicBlockstore
- type BatchDeleter
- type Blockstore
- func Adapt(bs blockstore.Blockstore) Blockstore
- func FromDatastore(dstore ds.Batching) Blockstore
- func NewAPIBlockstore(cio ChainIO) Blockstore
- func NewDiscardStore(bs Blockstore) Blockstore
- func NewIDStore(bs Blockstore) Blockstore
- func Union(stores ...Blockstore) Blockstore
- func UnwrapFallbackStore(bs Blockstore) (Blockstore, bool)
- func WrapIDStore(bstore blockstore.Blockstore) Blockstore
- type BlockstoreCache
- type BlockstoreGC
- type BlockstoreGCOnce
- type BlockstoreGCOption
- type BlockstoreGCOptions
- type BlockstoreIterator
- type BlockstoreSize
- type BufferedBlockstore
- func (bs *BufferedBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (bs *BufferedBlockstore) DeleteBlock(ctx context.Context, c cid.Cid) error
- func (bs *BufferedBlockstore) DeleteMany(ctx context.Context, cids []cid.Cid) error
- func (bs *BufferedBlockstore) Flush(ctx context.Context) error
- func (bs *BufferedBlockstore) Get(ctx context.Context, c cid.Cid) (block.Block, error)
- func (bs *BufferedBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error)
- func (bs *BufferedBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error)
- func (bs *BufferedBlockstore) Put(ctx context.Context, blk block.Block) error
- func (bs *BufferedBlockstore) PutMany(ctx context.Context, blks []block.Block) error
- func (bs *BufferedBlockstore) Read() Blockstore
- func (bs *BufferedBlockstore) View(ctx context.Context, c cid.Cid, callback func([]byte) error) error
- type ChainIO
- type FallbackStore
- type Flusher
- type InstrumentedBlockService
- func (ibs *InstrumentedBlockService) AddBlock(ctx context.Context, block blocks.Block) error
- func (ibs *InstrumentedBlockService) AddBlocks(ctx context.Context, blocks []blocks.Block) error
- func (ibs *InstrumentedBlockService) Blockstore() BasicBlockstore
- func (ibs *InstrumentedBlockService) Close() error
- func (ibs *InstrumentedBlockService) DeleteBlock(ctx context.Context, c cid.Cid) error
- func (ibs *InstrumentedBlockService) Exchange() exchange.Interface
- func (ibs *InstrumentedBlockService) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error)
- func (ibs *InstrumentedBlockService) GetBlocks(ctx context.Context, cids []cid.Cid) <-chan blocks.Block
- func (ibs *InstrumentedBlockService) NewSession(ctx context.Context) *InstrumentedSession
- type InstrumentedSession
- type MemBlockstore
- func (m MemBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (m MemBlockstore) DeleteBlock(ctx context.Context, k cid.Cid) error
- func (m MemBlockstore) DeleteMany(ctx context.Context, ks []cid.Cid) error
- func (MemBlockstore) Flush(context.Context) error
- func (m MemBlockstore) Get(ctx context.Context, k cid.Cid) (blocks.Block, error)
- func (m MemBlockstore) GetSize(ctx context.Context, k cid.Cid) (int, error)
- func (m MemBlockstore) Has(ctx context.Context, k cid.Cid) (bool, error)
- func (m MemBlockstore) Put(ctx context.Context, b blocks.Block) error
- func (m MemBlockstore) PutMany(ctx context.Context, bs []blocks.Block) error
- func (m MemBlockstore) View(ctx context.Context, k cid.Cid, callback func([]byte) error) error
- type MhString
- type NetRPCErrType
- type NetRPCReqType
- type NetRPCRespType
- type NetRpcErr
- type NetRpcReq
- type NetRpcResp
- type NetworkStore
- func (n *NetworkStore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (n *NetworkStore) DeleteBlock(ctx context.Context, c cid.Cid) error
- func (n *NetworkStore) DeleteMany(ctx context.Context, cids []cid.Cid) error
- func (*NetworkStore) Flush(context.Context) error
- func (n *NetworkStore) Get(ctx context.Context, c cid.Cid) (blocks.Block, error)
- func (n *NetworkStore) GetSize(ctx context.Context, c cid.Cid) (int, error)
- func (n *NetworkStore) Has(ctx context.Context, c cid.Cid) (bool, error)
- func (n *NetworkStore) OnClose(cb func())
- func (n *NetworkStore) Put(ctx context.Context, block blocks.Block) error
- func (n *NetworkStore) PutMany(ctx context.Context, blocks []blocks.Block) error
- func (n *NetworkStore) Stop(ctx context.Context) error
- func (n *NetworkStore) View(ctx context.Context, c cid.Cid, callback func([]byte) error) error
- type NetworkStoreHandler
- type ReadCachedBlockstore
- func (c *ReadCachedBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (c *ReadCachedBlockstore) DeleteBlock(ctx context.Context, cid cid.Cid) error
- func (c *ReadCachedBlockstore) DeleteMany(ctx context.Context, cids []cid.Cid) error
- func (c *ReadCachedBlockstore) Flush(ctx context.Context) error
- func (c *ReadCachedBlockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error)
- func (c *ReadCachedBlockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error)
- func (c *ReadCachedBlockstore) Has(ctx context.Context, cid cid.Cid) (bool, error)
- func (c *ReadCachedBlockstore) Put(ctx context.Context, block blocks.Block) error
- func (c *ReadCachedBlockstore) PutMany(ctx context.Context, blocks []blocks.Block) error
- func (c *ReadCachedBlockstore) View(ctx context.Context, cid cid.Cid, callback func([]byte) error) error
- type SyncBlockstore
- func (m *SyncBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (m *SyncBlockstore) DeleteBlock(ctx context.Context, k cid.Cid) error
- func (m *SyncBlockstore) DeleteMany(ctx context.Context, ks []cid.Cid) error
- func (*SyncBlockstore) Flush(context.Context) error
- func (m *SyncBlockstore) Get(ctx context.Context, k cid.Cid) (blocks.Block, error)
- func (m *SyncBlockstore) GetSize(ctx context.Context, k cid.Cid) (int, error)
- func (m *SyncBlockstore) Has(ctx context.Context, k cid.Cid) (bool, error)
- func (m *SyncBlockstore) Put(ctx context.Context, b blocks.Block) error
- func (m *SyncBlockstore) PutMany(ctx context.Context, bs []blocks.Block) error
- func (m *SyncBlockstore) View(ctx context.Context, k cid.Cid, callback func([]byte) error) error
- type TimedCacheBlockstore
- func (t *TimedCacheBlockstore) AllKeysChan(_ context.Context) (<-chan cid.Cid, error)
- func (t *TimedCacheBlockstore) DeleteBlock(ctx context.Context, k cid.Cid) error
- func (t *TimedCacheBlockstore) DeleteMany(ctx context.Context, ks []cid.Cid) error
- func (t *TimedCacheBlockstore) Flush(ctx context.Context) error
- func (t *TimedCacheBlockstore) Get(ctx context.Context, k cid.Cid) (blocks.Block, error)
- func (t *TimedCacheBlockstore) GetSize(ctx context.Context, k cid.Cid) (int, error)
- func (t *TimedCacheBlockstore) Has(ctx context.Context, k cid.Cid) (bool, error)
- func (t *TimedCacheBlockstore) Put(ctx context.Context, b blocks.Block) error
- func (t *TimedCacheBlockstore) PutMany(ctx context.Context, bs []blocks.Block) error
- func (t *TimedCacheBlockstore) Start(_ context.Context) error
- func (t *TimedCacheBlockstore) Stop(_ context.Context) error
- func (t *TimedCacheBlockstore) View(ctx context.Context, k cid.Cid, callback func([]byte) error) error
- type Viewer
Constants ¶
This section is empty.
Variables ¶
var (
CacheName, _ = tag.NewKey("cache_name")
FetchSource, _ = tag.NewKey("fetch_source") // "local" or "network"
)
var CacheMeasures = struct { HitRatio *stats.Float64Measure Hits *stats.Int64Measure Misses *stats.Int64Measure Entries *stats.Int64Measure QueriesServed *stats.Int64Measure Adds *stats.Int64Measure Updates *stats.Int64Measure Evictions *stats.Int64Measure CostAdded *stats.Int64Measure CostEvicted *stats.Int64Measure SetsDropped *stats.Int64Measure SetsRejected *stats.Int64Measure QueriesDropped *stats.Int64Measure }{ HitRatio: stats.Float64("blockstore/cache/hit_ratio", "Hit ratio of blockstore cache", stats.UnitDimensionless), Hits: stats.Int64("blockstore/cache/hits", "Total number of hits at blockstore cache", stats.UnitDimensionless), Misses: stats.Int64("blockstore/cache/misses", "Total number of misses at blockstore cache", stats.UnitDimensionless), Entries: stats.Int64("blockstore/cache/entry_count", "Total number of entries currently in the blockstore cache", stats.UnitDimensionless), QueriesServed: stats.Int64("blockstore/cache/queries_served", "Total number of queries served by the blockstore cache", stats.UnitDimensionless), Adds: stats.Int64("blockstore/cache/adds", "Total number of adds to blockstore cache", stats.UnitDimensionless), Updates: stats.Int64("blockstore/cache/updates", "Total number of updates in blockstore cache", stats.UnitDimensionless), Evictions: stats.Int64("blockstore/cache/evictions", "Total number of evictions from blockstore cache", stats.UnitDimensionless), CostAdded: stats.Int64("blockstore/cache/cost_added", "Total cost (byte size) of entries added into blockstore cache", stats.UnitBytes), CostEvicted: stats.Int64("blockstore/cache/cost_evicted", "Total cost (byte size) of entries evicted by blockstore cache", stats.UnitBytes), SetsDropped: stats.Int64("blockstore/cache/sets_dropped", "Total number of sets dropped by blockstore cache", stats.UnitDimensionless), SetsRejected: stats.Int64("blockstore/cache/sets_rejected", "Total number of sets rejected by blockstore cache", stats.UnitDimensionless), QueriesDropped: stats.Int64("blockstore/cache/queries_dropped", "Total number of queries dropped by blockstore cache", stats.UnitDimensionless), }
CacheMeasures groups all metrics emitted by the blockstore caches.
var CacheMetricsEmitInterval = 5 * time.Second
CacheMetricsEmitInterval is the interval at which metrics are emitted onto OpenCensus.
var CacheViews = struct { HitRatio *view.View Hits *view.View Misses *view.View Entries *view.View QueriesServed *view.View Adds *view.View Updates *view.View Evictions *view.View CostAdded *view.View CostEvicted *view.View SetsDropped *view.View SetsRejected *view.View QueriesDropped *view.View }{ HitRatio: &view.View{ Measure: CacheMeasures.HitRatio, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, Hits: &view.View{ Measure: CacheMeasures.Hits, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, Misses: &view.View{ Measure: CacheMeasures.Misses, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, Entries: &view.View{ Measure: CacheMeasures.Entries, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, QueriesServed: &view.View{ Measure: CacheMeasures.QueriesServed, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, Adds: &view.View{ Measure: CacheMeasures.Adds, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, Updates: &view.View{ Measure: CacheMeasures.Updates, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, Evictions: &view.View{ Measure: CacheMeasures.Evictions, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, CostAdded: &view.View{ Measure: CacheMeasures.CostAdded, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, CostEvicted: &view.View{ Measure: CacheMeasures.CostEvicted, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, SetsDropped: &view.View{ Measure: CacheMeasures.SetsDropped, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, SetsRejected: &view.View{ Measure: CacheMeasures.SetsRejected, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, QueriesDropped: &view.View{ Measure: CacheMeasures.QueriesDropped, Aggregation: view.LastValue(), TagKeys: []tag.Key{CacheName}, }, }
CacheViews groups all cache-related default views.
var DefaultViews = []*view.View{ CacheViews.HitRatio, CacheViews.Hits, CacheViews.Misses, CacheViews.Entries, CacheViews.QueriesServed, CacheViews.Adds, CacheViews.Updates, CacheViews.Evictions, CacheViews.CostAdded, CacheViews.CostEvicted, CacheViews.SetsDropped, CacheViews.SetsRejected, CacheViews.QueriesDropped, MessageFetchViews.Requested, MessageFetchViews.Local, MessageFetchViews.Network, MessageFetchViews.Duration, }
DefaultViews exports all default views for this package.
var MessageFetchMeasures = struct { Requested *stats.Int64Measure Local *stats.Int64Measure Network *stats.Int64Measure Duration *stats.Float64Measure }{ Requested: stats.Int64("message/fetch_requested", "Number of messages requested for fetch", stats.UnitDimensionless), Local: stats.Int64("message/fetch_local", "Number of messages found locally", stats.UnitDimensionless), Network: stats.Int64("message/fetch_network", "Number of messages fetched from network", stats.UnitDimensionless), Duration: stats.Float64("message/fetch_duration_ms", "Duration of message fetch operations", stats.UnitMilliseconds), }
MessageFetchMeasures groups metrics for message fetch tracking
var MessageFetchViews = struct { Requested *view.View Local *view.View Network *view.View Duration *view.View }{ Requested: &view.View{ Measure: MessageFetchMeasures.Requested, Aggregation: view.Sum(), }, Local: &view.View{ Measure: MessageFetchMeasures.Local, Aggregation: view.Sum(), }, Network: &view.View{ Measure: MessageFetchMeasures.Network, Aggregation: view.Sum(), }, Duration: &view.View{ Measure: MessageFetchMeasures.Duration, Aggregation: view.Distribution(0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1500, 2000, 3000, 4000, 5000), TagKeys: []tag.Key{FetchSource}, }, }
MessageFetchViews groups all message fetch-related views
Functions ¶
Types ¶
type AutobatchBlockstore ¶ added in v1.14.0
type AutobatchBlockstore struct {
// contains filtered or unexported fields
}
func NewAutobatch ¶ added in v1.14.0
func NewAutobatch(ctx context.Context, backingBs Blockstore, bufferCapacity int) *AutobatchBlockstore
func (*AutobatchBlockstore) AllKeysChan ¶ added in v1.14.0
func (*AutobatchBlockstore) DeleteBlock ¶ added in v1.14.0
func (*AutobatchBlockstore) DeleteMany ¶ added in v1.14.0
func (*AutobatchBlockstore) Flush ¶ added in v1.14.0
func (bs *AutobatchBlockstore) Flush(ctx context.Context) error
Flush caller must NOT hold stateLock
type BasicBlockstore ¶
type BasicBlockstore = blockstore.Blockstore
BasicBlockstore is an alias to the original IPFS Blockstore.
type BatchDeleter ¶
type Blockstore ¶
type Blockstore interface {
blockstore.Blockstore
blockstore.Viewer
BatchDeleter
Flusher
}
Blockstore is the blockstore interface used by Lotus. It is the union of the basic go-ipfs blockstore, with other capabilities required by Lotus, e.g. View or Sync.
func Adapt ¶
func Adapt(bs blockstore.Blockstore) Blockstore
Adapt adapts a standard blockstore to a Lotus blockstore by enriching it with the extra methods that Lotus requires (e.g. View, Sync).
View proxies over to Get and calls the callback with the value supplied by Get. Sync noops.
func FromDatastore ¶
func FromDatastore(dstore ds.Batching) Blockstore
FromDatastore creates a new blockstore backed by the given datastore.
func NewAPIBlockstore ¶
func NewAPIBlockstore(cio ChainIO) Blockstore
func NewDiscardStore ¶ added in v1.11.1
func NewDiscardStore(bs Blockstore) Blockstore
func NewIDStore ¶
func NewIDStore(bs Blockstore) Blockstore
func Union ¶
func Union(stores ...Blockstore) Blockstore
Union returns an unioned blockstore.
- Reads return from the first blockstore that has the value, querying in the supplied order.
- Writes (puts and deletes) are broadcast to all stores.
func UnwrapFallbackStore ¶
func UnwrapFallbackStore(bs Blockstore) (Blockstore, bool)
UnwrapFallbackStore takes a blockstore, and returns the underlying blockstore if it was a FallbackStore. Otherwise, it just returns the supplied store unmodified.
func WrapIDStore ¶
func WrapIDStore(bstore blockstore.Blockstore) Blockstore
WrapIDStore wraps the underlying blockstore in an "identity" blockstore. The ID store filters out all puts for blocks with CIDs using the "identity" hash function. It also extracts inlined blocks from CIDs using the identity hash function and returns them on get/has, ignoring the contents of the blockstore.
type BlockstoreCache ¶ added in v1.27.0
type BlockstoreCache interface {
Remove(mhString MhString) bool
Contains(mhString MhString) bool
Get(mhString MhString) (blocks.Block, bool)
Add(mhString MhString, block blocks.Block) (evicted bool)
}
BlockstoreCache is a cache for blocks, compatible with lru.Cache; Must be safe for concurrent access
type BlockstoreGC ¶ added in v1.11.1
type BlockstoreGC interface {
CollectGarbage(ctx context.Context, options ...BlockstoreGCOption) error
}
BlockstoreGC is a trait for blockstores that support online garbage collection
type BlockstoreGCOnce ¶ added in v1.23.0
type BlockstoreGCOnce interface {
GCOnce(ctx context.Context, options ...BlockstoreGCOption) error
}
BlockstoreGCOnce is a trait for a blockstore that supports incremental online garbage collection
type BlockstoreGCOption ¶ added in v1.11.1
type BlockstoreGCOption = func(*BlockstoreGCOptions) error
BlockstoreGCOption is a functional interface for controlling blockstore GC options
func WithCheck ¶ added in v1.23.0
func WithCheck(check func() error) BlockstoreGCOption
func WithCheckFreq ¶ added in v1.23.0
func WithCheckFreq(f time.Duration) BlockstoreGCOption
func WithFullGC ¶ added in v1.11.1
func WithFullGC(fullgc bool) BlockstoreGCOption
func WithThreshold ¶ added in v1.23.0
func WithThreshold(threshold float64) BlockstoreGCOption
type BlockstoreGCOptions ¶ added in v1.11.1
type BlockstoreGCOptions struct {
FullGC bool
// fraction of garbage in badger vlog before its worth processing in online GC
Threshold float64
// how often to call the check function
CheckFreq time.Duration
// function to call periodically to pause or early terminate GC
Check func() error
}
BlockstoreGCOptions is a struct with GC options
type BlockstoreIterator ¶ added in v1.11.1
BlockstoreIterator is a trait for efficient iteration
type BlockstoreSize ¶ added in v1.11.1
BlockstoreSize is a trait for on-disk blockstores that can report their size
type BufferedBlockstore ¶
type BufferedBlockstore struct {
// contains filtered or unexported fields
}
func NewBuffered ¶
func NewBuffered(base Blockstore) *BufferedBlockstore
func NewTieredBstore ¶
func NewTieredBstore(r Blockstore, w Blockstore) *BufferedBlockstore
func (*BufferedBlockstore) AllKeysChan ¶
func (*BufferedBlockstore) DeleteBlock ¶
func (*BufferedBlockstore) DeleteMany ¶
func (*BufferedBlockstore) Flush ¶ added in v1.23.0
func (bs *BufferedBlockstore) Flush(ctx context.Context) error
func (*BufferedBlockstore) Read ¶
func (bs *BufferedBlockstore) Read() Blockstore
type FallbackStore ¶
type FallbackStore struct {
Blockstore
// contains filtered or unexported fields
}
FallbackStore is a read-through store that queries another (potentially remote) source if the block is not found locally. If the block is found during the fallback, it stores it in the local store.
func (*FallbackStore) SetFallback ¶
type InstrumentedBlockService ¶ added in v1.34.0
type InstrumentedBlockService struct {
blockservice.BlockService
// contains filtered or unexported fields
}
InstrumentedBlockService wraps a blockservice.BlockService to provide metrics tracking for local vs network block fetches
func NewInstrumentedBlockService ¶ added in v1.34.0
func NewInstrumentedBlockService(bs Blockstore, exch exchange.Interface) *InstrumentedBlockService
NewInstrumentedBlockService creates a new instrumented block service
func (*InstrumentedBlockService) AddBlock ¶ added in v1.34.0
AddBlock adds a single block to the blockservice
func (*InstrumentedBlockService) AddBlocks ¶ added in v1.34.0
AddBlocks adds multiple blocks to the blockservice
func (*InstrumentedBlockService) Blockstore ¶ added in v1.34.0
func (ibs *InstrumentedBlockService) Blockstore() BasicBlockstore
Blockstore returns the underlying blockstore
func (*InstrumentedBlockService) Close ¶ added in v1.34.0
func (ibs *InstrumentedBlockService) Close() error
Close closes the blockservice
func (*InstrumentedBlockService) DeleteBlock ¶ added in v1.34.0
DeleteBlock deletes a block from the blockservice
func (*InstrumentedBlockService) Exchange ¶ added in v1.34.0
func (ibs *InstrumentedBlockService) Exchange() exchange.Interface
Exchange returns the underlying exchange
func (*InstrumentedBlockService) GetBlock ¶ added in v1.34.0
GetBlock wraps the underlying GetBlock to track individual fetches
func (*InstrumentedBlockService) GetBlocks ¶ added in v1.34.0
func (ibs *InstrumentedBlockService) GetBlocks(ctx context.Context, cids []cid.Cid) <-chan blocks.Block
GetBlocks wraps the underlying GetBlocks to track local vs network fetches
func (*InstrumentedBlockService) NewSession ¶ added in v1.34.0
func (ibs *InstrumentedBlockService) NewSession(ctx context.Context) *InstrumentedSession
NewSession creates a new instrumented session
type InstrumentedSession ¶ added in v1.34.0
type InstrumentedSession struct {
blockservice.BlockGetter
// contains filtered or unexported fields
}
InstrumentedSession wraps a blockservice session to provide metrics
type MemBlockstore ¶
MemBlockstore is a terminal blockstore that keeps blocks in memory. To match behavior of badger blockstore we index by multihash only.
func NewMemory ¶
func NewMemory() MemBlockstore
NewMemory returns a temporary memory-backed blockstore.
func (MemBlockstore) AllKeysChan ¶
AllKeysChan returns a channel from which the CIDs in the Blockstore can be read. It should respect the given context, closing the channel if it becomes Done.
func (MemBlockstore) DeleteBlock ¶
func (MemBlockstore) DeleteMany ¶
type NetRPCErrType ¶ added in v1.19.0
type NetRPCErrType byte
const ( NRpcErrGeneric NetRPCErrType = iota NRpcErrNotFound )
type NetRPCReqType ¶ added in v1.19.0
type NetRPCReqType byte
const ( NRpcHas NetRPCReqType = iota NRpcGet NRpcGetSize NRpcPut NRpcDelete )
type NetRPCRespType ¶ added in v1.19.0
type NetRPCRespType byte
const ( NRpcOK NetRPCRespType = iota NRpcErr NRpcMore )
type NetRpcErr ¶ added in v1.19.0
type NetRpcErr struct {
Type NetRPCErrType
Msg string
// in case of NRpcErrNotFound
Cid *cid.Cid
}
type NetRpcReq ¶ added in v1.19.0
type NetRpcReq struct {
Type NetRPCReqType
ID uint64
Cid []cid.Cid // todo maxsize?
Data [][]byte // todo maxsize?
}
type NetRpcResp ¶ added in v1.19.0
type NetRpcResp struct {
Type NetRPCRespType
ID uint64
// error or cids in allkeys
Data []byte // todo maxsize?
// contains filtered or unexported fields
}
func (*NetRpcResp) MarshalCBOR ¶ added in v1.19.0
func (t *NetRpcResp) MarshalCBOR(w io.Writer) error
func (*NetRpcResp) UnmarshalCBOR ¶ added in v1.19.0
func (t *NetRpcResp) UnmarshalCBOR(r io.Reader) (err error)
type NetworkStore ¶ added in v1.19.0
type NetworkStore struct {
// contains filtered or unexported fields
}
func NewNetworkStore ¶ added in v1.19.0
func NewNetworkStore(mss msgio.ReadWriteCloser) *NetworkStore
func NewNetworkStoreWS ¶ added in v1.19.0
func NewNetworkStoreWS(wc *websocket.Conn) *NetworkStore
func (*NetworkStore) AllKeysChan ¶ added in v1.19.0
func (*NetworkStore) DeleteBlock ¶ added in v1.19.0
func (*NetworkStore) DeleteMany ¶ added in v1.19.0
func (*NetworkStore) OnClose ¶ added in v1.19.0
func (n *NetworkStore) OnClose(cb func())
type NetworkStoreHandler ¶ added in v1.19.0
type NetworkStoreHandler struct {
// contains filtered or unexported fields
}
func HandleNetBstoreStream ¶ added in v1.19.0
func HandleNetBstoreStream(ctx context.Context, bs Blockstore, mss msgio.ReadWriteCloser) *NetworkStoreHandler
func HandleNetBstoreWS ¶ added in v1.19.0
func HandleNetBstoreWS(ctx context.Context, bs Blockstore, wc *websocket.Conn) *NetworkStoreHandler
type ReadCachedBlockstore ¶ added in v1.27.0
type ReadCachedBlockstore struct {
// contains filtered or unexported fields
}
func NewReadCachedBlockstore ¶ added in v1.27.0
func NewReadCachedBlockstore(top Blockstore, cache BlockstoreCache) *ReadCachedBlockstore
func (*ReadCachedBlockstore) AllKeysChan ¶ added in v1.27.0
func (*ReadCachedBlockstore) DeleteBlock ¶ added in v1.27.0
func (*ReadCachedBlockstore) DeleteMany ¶ added in v1.27.0
func (*ReadCachedBlockstore) Flush ¶ added in v1.27.0
func (c *ReadCachedBlockstore) Flush(ctx context.Context) error
type SyncBlockstore ¶
type SyncBlockstore struct {
// contains filtered or unexported fields
}
SyncBlockstore is a terminal blockstore that is a synchronized version of MemBlockstore.
func NewMemorySync ¶
func NewMemorySync() *SyncBlockstore
NewMemorySync returns a thread-safe in-memory blockstore.
func (*SyncBlockstore) AllKeysChan ¶
func (*SyncBlockstore) DeleteBlock ¶
func (*SyncBlockstore) DeleteMany ¶
type TimedCacheBlockstore ¶
type TimedCacheBlockstore struct {
// contains filtered or unexported fields
}
TimedCacheBlockstore is a blockstore that keeps blocks for at least the specified caching interval before discarding them. Garbage collection must be started and stopped by calling Start/Stop.
Under the covers, it's implemented with an active and an inactive blockstore that are rotated every cache time interval. This means all blocks will be stored at most 2x the cache interval.
Create a new instance by calling the NewTimedCacheBlockstore constructor.
func NewTimedCacheBlockstore ¶
func NewTimedCacheBlockstore(interval time.Duration) *TimedCacheBlockstore
func (*TimedCacheBlockstore) AllKeysChan ¶
func (*TimedCacheBlockstore) DeleteBlock ¶
func (*TimedCacheBlockstore) DeleteMany ¶
func (*TimedCacheBlockstore) Flush ¶ added in v1.23.0
func (t *TimedCacheBlockstore) Flush(ctx context.Context) error
type Viewer ¶
type Viewer = blockstore.Viewer