Documentation ¶
Index ¶
- func New() *mockStorer
- func NewWithChunkStore(cs storage.ChunkStore) *mockStorer
- func NewWithDebugInfo(info storer.Info) *mockStorer
- type DelayedStore
- type ForgettingStore
- func (f *ForgettingStore) Get(ctx context.Context, addr swarm.Address) (ch swarm.Chunk, err error)
- func (f *ForgettingStore) Miss(addr swarm.Address)
- func (f *ForgettingStore) Missed() int
- func (f *ForgettingStore) Put(ctx context.Context, ch swarm.Chunk) (err error)
- func (f *ForgettingStore) Record()
- func (f *ForgettingStore) Reset()
- func (f *ForgettingStore) Stored() int64
- func (f *ForgettingStore) Unmiss(addr swarm.Address)
- func (f *ForgettingStore) Unrecord()
- type Option
- func WithCapacityDoubling(s int) Option
- func WithChunks(chs ...swarm.Chunk) Option
- func WithCursors(c []uint64, e uint64) Option
- func WithCursorsErr(e error) Option
- func WithEvilChunk(addr swarm.Address, ch swarm.Chunk) Option
- func WithPutHook(f func(swarm.Chunk) error) Option
- func WithRadius(r uint8) Option
- func WithReserveSize(s int) Option
- func WithSample(s storer.Sample) Option
- func WithSubscribeResp(chunks []*storer.BinC, err error) Option
- type ReserveStore
- func (s *ReserveStore) EvictBatch(ctx context.Context, batchID []byte) error
- func (s *ReserveStore) IsFullySynced() bool
- func (s *ReserveStore) IsWithinStorageRadius(addr swarm.Address) bool
- func (s *ReserveStore) PutCalls() int
- func (s *ReserveStore) ReserveGet(ctx context.Context, addr swarm.Address, batchID []byte, stampHash []byte) (swarm.Chunk, error)
- func (s *ReserveStore) ReserveHas(addr swarm.Address, batchID []byte, stampHash []byte) (bool, error)
- func (s *ReserveStore) ReserveLastBinIDs() (curs []uint64, epoch uint64, err error)
- func (s *ReserveStore) ReservePutter() storage.Putter
- func (s *ReserveStore) ReserveSample(context.Context, []byte, uint8, uint64, *big.Int) (storer.Sample, error)
- func (s *ReserveStore) ReserveSize() int
- func (s *ReserveStore) SetCalls() int
- func (s *ReserveStore) SetStorageRadius(r uint8)
- func (s *ReserveStore) StorageRadius() uint8
- func (s *ReserveStore) SubscribeBin(ctx context.Context, bin uint8, start uint64) (<-chan *storer.BinC, func(), <-chan error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New() *mockStorer
New returns a mock storer implementation that is designed to be used for the unit tests.
func NewWithChunkStore ¶
func NewWithChunkStore(cs storage.ChunkStore) *mockStorer
func NewWithDebugInfo ¶
Types ¶
type DelayedStore ¶
type DelayedStore struct { storage.ChunkStore // contains filtered or unexported fields }
func NewDelayedStore ¶
func NewDelayedStore(s storage.ChunkStore) *DelayedStore
type ForgettingStore ¶
type ForgettingStore struct { storage.ChunkStore // contains filtered or unexported fields }
func NewForgettingStore ¶
func NewForgettingStore(s storage.ChunkStore) *ForgettingStore
func (*ForgettingStore) Get ¶
Get implements the ChunkStore interface. if in recording phase, record the chunk address as miss and returns Get on the embedded store if in forgetting phase, returns ErrNotFound if the chunk address is recorded as miss
func (*ForgettingStore) Miss ¶
func (f *ForgettingStore) Miss(addr swarm.Address)
func (*ForgettingStore) Missed ¶
func (f *ForgettingStore) Missed() int
func (*ForgettingStore) Record ¶
func (f *ForgettingStore) Record()
func (*ForgettingStore) Reset ¶
func (f *ForgettingStore) Reset()
func (*ForgettingStore) Stored ¶
func (f *ForgettingStore) Stored() int64
func (*ForgettingStore) Unmiss ¶
func (f *ForgettingStore) Unmiss(addr swarm.Address)
func (*ForgettingStore) Unrecord ¶
func (f *ForgettingStore) Unrecord()
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithCapacityDoubling ¶
func WithChunks ¶
WithChunks mocks the set of chunks that the store is aware of (used in Get and Has calls).
func WithCursors ¶
func WithCursorsErr ¶
func WithEvilChunk ¶
WithEvilChunk allows to inject a malicious chunk (request a certain address of a chunk, but get another), in order to mock unsolicited chunk delivery.
func WithRadius ¶
func WithReserveSize ¶
func WithSample ¶
func WithSubscribeResp ¶
WithSubscribeResp mocks a desired response when calling IntervalChunks method. Different possible responses for subsequent responses in multi-call scenarios are possible (i.e. first call yields a,b,c, second call yields d,e,f). Mock maintains state of current call using chunksCalls counter.
type ReserveStore ¶
type ReserveStore struct {
// contains filtered or unexported fields
}
func NewReserve ¶
func NewReserve(opts ...Option) *ReserveStore
NewReserve returns a new Reserve mock.
func (*ReserveStore) EvictBatch ¶
func (s *ReserveStore) EvictBatch(ctx context.Context, batchID []byte) error
func (*ReserveStore) IsFullySynced ¶
func (s *ReserveStore) IsFullySynced() bool
func (*ReserveStore) IsWithinStorageRadius ¶
func (s *ReserveStore) IsWithinStorageRadius(addr swarm.Address) bool
func (*ReserveStore) PutCalls ¶
func (s *ReserveStore) PutCalls() int
PutCalls returns the amount of times Put was called.
func (*ReserveStore) ReserveGet ¶
func (s *ReserveStore) ReserveGet(ctx context.Context, addr swarm.Address, batchID []byte, stampHash []byte) (swarm.Chunk, error)
Get chunks.
func (*ReserveStore) ReserveHas ¶
func (s *ReserveStore) ReserveHas(addr swarm.Address, batchID []byte, stampHash []byte) (bool, error)
Has chunks.
func (*ReserveStore) ReserveLastBinIDs ¶
func (s *ReserveStore) ReserveLastBinIDs() (curs []uint64, epoch uint64, err error)
func (*ReserveStore) ReservePutter ¶
func (s *ReserveStore) ReservePutter() storage.Putter
Put chunks.
func (*ReserveStore) ReserveSample ¶
func (*ReserveStore) ReserveSize ¶
func (s *ReserveStore) ReserveSize() int
func (*ReserveStore) SetCalls ¶
func (s *ReserveStore) SetCalls() int
SetCalls returns the amount of times Set was called.
func (*ReserveStore) SetStorageRadius ¶
func (s *ReserveStore) SetStorageRadius(r uint8)
func (*ReserveStore) StorageRadius ¶
func (s *ReserveStore) StorageRadius() uint8
func (*ReserveStore) SubscribeBin ¶
func (s *ReserveStore) SubscribeBin(ctx context.Context, bin uint8, start uint64) (<-chan *storer.BinC, func(), <-chan error)
IntervalChunks returns a set of chunk in a requested interval.