block

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector aggregates batches of blocks limited to some max size and fills requests with them.

func NewCollector

func NewCollector(ctx context.Context, reqs <-chan *Request, blocks blockstore.Blockstore, max int) *Collector

NewCollector creates new Collector

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request is a tuple of Request Request params.

func NewRequest

func NewRequest(ctx context.Context, id uint32, ids []cid.Cid) *Request

NewRequest creates new Request.

func (*Request) Cancel

func (req *Request) Cancel()

Cancel finishes the Request.

func (*Request) Done

func (req *Request) Done() <-chan struct{}

Done returns done channel of underlying context.

func (*Request) Error added in v1.1.5

func (req *Request) Error(err error)

Error cancels the request with an error.

func (*Request) Fill

func (req *Request) Fill(bs []blocks.Block) bool

Fill fills up the Request with asked blocks.

func (*Request) Fulfilled

func (req *Request) Fulfilled() bool

Fulfilled checks whenever Request is fully filled and finished.

func (*Request) Id

func (req *Request) Id() uint32

Id returns Request's id.

func (*Request) Next

func (req *Request) Next() ([]blocks.Block, error)

Next waits for new incoming blocks. Also returns false when Request is fulfilled.

func (*Request) Remains

func (req *Request) Remains() []cid.Cid

Remains returns remaining ids for the Request to become fulfilled.

type RequestQueue

type RequestQueue struct {
	// contains filtered or unexported fields
}

func NewRequestQueue

func NewRequestQueue(done <-chan struct{}) *RequestQueue

func (*RequestQueue) Back

func (rq *RequestQueue) Back() *Request

func (*RequestQueue) BackPopDone

func (rq *RequestQueue) BackPopDone() *Request

func (*RequestQueue) Cancel

func (rq *RequestQueue) Cancel(id uint32)

func (*RequestQueue) Enqueue

func (rq *RequestQueue) Enqueue(reqs ...*Request)

func (*RequestQueue) Len

func (rq *RequestQueue) Len() int

func (*RequestQueue) PopBack

func (rq *RequestQueue) PopBack()

type Result added in v1.2.0

type Result struct {
	blocks.Block

	Id  cid.Cid
	Err error
}

func (Result) Cid added in v1.2.1

func (r Result) Cid() cid.Cid

type Stream added in v1.2.0

type Stream struct {
	// contains filtered or unexported fields
}

func NewStream

func NewStream(ctx context.Context) *Stream

func (*Stream) Close added in v1.2.0

func (s *Stream) Close()

func (*Stream) Done added in v1.2.0

func (s *Stream) Done() <-chan struct{}

func (*Stream) Enqueue added in v1.2.0

func (s *Stream) Enqueue(reqs ...*Request)

func (*Stream) Output added in v1.2.0

func (s *Stream) Output() <-chan Result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL