Documentation ¶
Overview ¶
Package tags provides the implementation for upload progress tracking.
Index ¶
- Variables
- type State
- type Tag
- func (t *Tag) Context() context.Context
- func (t *Tag) Done(s State) bool
- func (t *Tag) DoneSplit(address swarm.Address) (int64, error)
- func (t *Tag) ETA(state State) (time.Time, error)
- func (t *Tag) FinishRootSpan()
- func (t *Tag) Get(state State) int64
- func (t *Tag) Inc(state State) error
- func (t *Tag) IncN(state State, n int64) error
- func (tag *Tag) MarshalBinary() (data []byte, err error)
- func (t *Tag) Status(state State) (int64, int64, error)
- func (t *Tag) TotalCounter() int64
- func (tag *Tag) UnmarshalBinary(buffer []byte) error
- func (t *Tag) WaitTillDone(ctx context.Context, s State) error
- type Tags
- func (ts *Tags) All() (t []*Tag)
- func (ts *Tags) Close() (err error)
- func (ts *Tags) Create(total int64) (*Tag, error)
- func (ts *Tags) Delete(k interface{})
- func (ts *Tags) Get(uid uint32) (*Tag, error)
- func (ts *Tags) GetByAddress(address swarm.Address) (*Tag, error)
- func (ts *Tags) ListAll(ctx context.Context, offset, limit int) (t []*Tag, err error)
- func (ts *Tags) MarshalJSON() (out []byte, err error)
- func (ts *Tags) Range(fn func(k, v interface{}) bool)
- func (ts *Tags) UnmarshalJSON(value []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( TagUidFunc = rand.Uint32 ErrNotFound = errors.New("tag not found") )
Functions ¶
This section is empty.
Types ¶
type State ¶
type State = uint32
State is the enum type for chunk states
const ( TotalChunks State = iota // The total no of chunks for the tag StateSplit // chunk has been processed by filehasher/swarm safe call StateStored // chunk stored locally StateSeen // chunk previously seen StateSent // chunk sent to neighbourhood StateSynced // proof is received; chunk removed from sync db; chunk is available everywhere )
type Tag ¶
type Tag struct { Total int64 // total chunks belonging to a tag Split int64 // number of chunks already processed by splitter for hashing Seen int64 // number of chunks already seen Stored int64 // number of chunks already stored locally Sent int64 // number of chunks sent for push syncing Synced int64 // number of chunks synced with proof Uid uint32 // a unique identifier for this tag Address swarm.Address // the associated swarm hash for this tag StartedAt time.Time // tag started to calculate ETA // contains filtered or unexported fields }
Tag represents info on the status of new chunks
func NewTag ¶
func NewTag(ctx context.Context, uid uint32, total int64, tracer *tracing.Tracer, stateStore storage.StateStorer, logger logging.Logger) *Tag
NewTag creates a new tag, and returns it
func (*Tag) DoneSplit ¶
DoneSplit sets total count to SPLIT count and sets the associated swarm hash for this tag is meant to be called when splitter finishes for input streams of unknown size
func (*Tag) ETA ¶
ETA returns the time of completion estimated based on time passed and rate of completion
func (*Tag) FinishRootSpan ¶
func (t *Tag) FinishRootSpan()
FinishRootSpan closes the pushsync span of the tags
func (*Tag) MarshalBinary ¶
MarshalBinary marshals the tag into a byte slice
func (*Tag) UnmarshalBinary ¶
UnmarshalBinary unmarshals a byte slice into a tag
type Tags ¶
type Tags struct {
// contains filtered or unexported fields
}
Tags hold tag information indexed by a unique random uint32
func NewTags ¶
func NewTags(stateStore storage.StateStorer, logger logging.Logger) *Tags
NewTags creates a tags object
func (*Tags) All ¶
All returns all existing tags in Tags' sync.Map Note that tags are returned in no particular order
func (*Tags) Close ¶
Close is called when the node goes down. This is when all the tags in memory is persisted.
func (*Tags) Create ¶
Create creates a new tag, stores it by the UID and returns it it returns an error if the tag with this UID already exists
func (*Tags) GetByAddress ¶
GetByAddress returns the latest underlying tag for the address or an error if not found