Documentation ¶
Index ¶
- type AttachSectorsData
- type Event
- type EventAddSectors
- type EventAttachSectors
- type EventRemoveAllSectors
- type EventRemoveSpecificSectors
- type EventTokenDownload
- type EventTopUp
- type State
- func (s *State) Apply(e *Event)
- func (s *State) Close() error
- func (s *State) EnoughStorageResource(id types.TokenID, sectorsNum int64, now time.Time) (enoughResource bool)
- func (s *State) GetLimitedSectors(tokenID types.TokenID, pageID string, limit int) ([]crypto.Hash, string, error)
- func (s *State) GetSectors(tokenID types.TokenID) ([]crypto.Hash, error)
- func (s *State) HasSectors(tokenID types.TokenID, sectorIDs []crypto.Hash) ([]crypto.Hash, bool, error)
- func (s *State) LoadHistory(r io.Reader) error
- func (s *State) NonexistentSectors(tokenID types.TokenID, sectorIDs []crypto.Hash) ([]crypto.Hash, error)
- type TokenRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttachSectorsData ¶
AttachSectorsData include information about token sector and storing it.
type Event ¶
type Event struct { EventTopUp *EventTopUp `json:"event_top_up"` EventTokenDownload *EventTokenDownload `json:"event_token_download"` EventAddSectors *EventAddSectors `json:"event_add_sectors"` EventRemoveSpecificSectors *EventRemoveSpecificSectors `json:"event_remove_specific_sectors"` EventRemoveAllSectors *EventRemoveAllSectors `json:"event_remove_sectors"` EventAttachSectors *EventAttachSectors `json:"event_attach_sectors"` Time time.Time `json:"time"` }
Event include state events.
type EventAddSectors ¶
type EventAddSectors struct { TokenID types.TokenID `json:"token_id"` SectorsIDs [][]byte `json:"sectors_ids"` }
EventAddSectors represent adding sectors to token.
type EventAttachSectors ¶
type EventAttachSectors struct {
TokensSectors []AttachSectorsData `json:"tokens_sectors"`
}
EventAttachSectors represent attaching sector to contract.
type EventRemoveAllSectors ¶
type EventRemoveAllSectors struct { TokenID types.TokenID `json:"token_id"` SectorsIDs [][]byte `json:"sectors_ids"` }
EventRemoveAllSectors represent force removing sectors from token.
type EventRemoveSpecificSectors ¶
type EventRemoveSpecificSectors struct { TokenID types.TokenID `json:"token_id"` SectorsIDs [][]byte `json:"sectors_ids"` }
EventRemoveSpecificSectors represent removing specified sectors from token.
type EventTokenDownload ¶
type EventTokenDownload struct { TokenID types.TokenID `json:"token_id"` DownloadBytes int64 `json:"download_bytes"` SectorAccesses int64 `json:"sector_accesses"` }
EventTokenDownload change of state when downloading.
type EventTopUp ¶
type EventTopUp struct { TokenID types.TokenID `json:"token_id"` ResourceType types.Specifier `json:"resource_type"` ResourceAmount int64 `json:"resource_amount"` }
EventTopUp change of state when token replenishment.
type State ¶
type State struct { Tokens map[types.TokenID]TokenRecord `json:"tokens"` // contains filtered or unexported fields }
State representation of token storage state.
func (*State) EnoughStorageResource ¶
func (s *State) EnoughStorageResource(id types.TokenID, sectorsNum int64, now time.Time) (enoughResource bool)
EnoughStorageResource checks if there is enough storage resource to store existing sectors and new ones for one second. if the resource is less, it will return false.
func (*State) GetLimitedSectors ¶
func (s *State) GetLimitedSectors(tokenID types.TokenID, pageID string, limit int) ([]crypto.Hash, string, error)
GetLimitedSectors return paginated sectors.
func (*State) GetSectors ¶
GetSectors return sectors IDs from database by token ID.
func (*State) HasSectors ¶
func (s *State) HasSectors(tokenID types.TokenID, sectorIDs []crypto.Hash) ([]crypto.Hash, bool, error)
HasSectors checks if all sectors exist and returns a list of existing ones. It also removes duplicates from the list.
func (*State) LoadHistory ¶
LoadHistory load history in state.
type TokenRecord ¶
type TokenRecord struct { DownloadBytes int64 `json:"download_bytes"` UploadBytes int64 `json:"upload_bytes"` SectorAccesses int64 `json:"sector_accesses"` TokenInfo tokenStorageInfo `json:"token_info"` }
TokenRecord include information about token record.