Documentation ¶
Index ¶
- Constants
- Variables
- func NewLinkedTicketStore() *linkedTicketStore
- type BasicTicket
- func (t *BasicTicket) ACKed()
- func (t *BasicTicket) BasicInfo() string
- func (t *BasicTicket) Canceled()
- func (t *BasicTicket) Cid() cid.Cid
- func (t *BasicTicket) GetSize() int64
- func (t *BasicTicket) GetState() int32
- func (t *BasicTicket) GetStateString() string
- func (t *BasicTicket) Level() int64
- func (t *BasicTicket) Loggable() map[string]interface{}
- func (t *BasicTicket) Publisher() peer.ID
- func (t *BasicTicket) SendTo() peer.ID
- func (t *BasicTicket) SetPublisher(p peer.ID)
- func (a *BasicTicket) SetTimeStamp(timeStamp int64)
- func (t *BasicTicket) ToProto() *pb.Ticket
- type BasicTicketAck
- type InvalidPublisherError
- type Loggable
- type NotInitializeError
- type Ticket
- type TicketAck
- type TicketNotFound
- type TicketStore
- type TicketTask
Constants ¶
View Source
const ( STATE_NEW int32 = iota STATE_ACK STATE_CANCEL STATE_TIMEOUT )
View Source
const ( ACK_ACCEPT int32 = iota ACK_CANCEL )
View Source
const ( STORE_SEND int32 = iota STORE_RECV )
Variables ¶
View Source
var SendingListTypeError = fmt.Errorf("Elements in prapareSendingList is not TicketAck")
Functions ¶
func NewLinkedTicketStore ¶
func NewLinkedTicketStore() *linkedTicketStore
Types ¶
type BasicTicket ¶
type BasicTicket struct {
// contains filtered or unexported fields
}
func CreateBasicTicket ¶
func NewBasicTicket ¶
func NewBasicTicket(ticket *pb.Ticket) (*BasicTicket, error)
func (*BasicTicket) ACKed ¶
func (t *BasicTicket) ACKed()
func (*BasicTicket) BasicInfo ¶
func (t *BasicTicket) BasicInfo() string
func (*BasicTicket) Canceled ¶
func (t *BasicTicket) Canceled()
func (*BasicTicket) Cid ¶
func (t *BasicTicket) Cid() cid.Cid
func (*BasicTicket) GetSize ¶
func (t *BasicTicket) GetSize() int64
func (*BasicTicket) GetState ¶
func (t *BasicTicket) GetState() int32
func (*BasicTicket) GetStateString ¶
func (t *BasicTicket) GetStateString() string
func (*BasicTicket) Level ¶
func (t *BasicTicket) Level() int64
func (*BasicTicket) Loggable ¶
func (t *BasicTicket) Loggable() map[string]interface{}
func (*BasicTicket) Publisher ¶
func (t *BasicTicket) Publisher() peer.ID
func (*BasicTicket) SendTo ¶
func (t *BasicTicket) SendTo() peer.ID
func (*BasicTicket) SetPublisher ¶
func (t *BasicTicket) SetPublisher(p peer.ID)
func (*BasicTicket) SetTimeStamp ¶
func (a *BasicTicket) SetTimeStamp(timeStamp int64)
func (*BasicTicket) ToProto ¶
func (t *BasicTicket) ToProto() *pb.Ticket
type BasicTicketAck ¶
type BasicTicketAck struct {
// contains filtered or unexported fields
}
func CreateBasicTicketAck ¶
func NewBasicTicketAck ¶
func NewBasicTicketAck(ack *pb.TicketAck) (*BasicTicketAck, error)
func (*BasicTicketAck) ACK ¶
func (a *BasicTicketAck) ACK() int32
func (*BasicTicketAck) Cid ¶
func (a *BasicTicketAck) Cid() cid.Cid
func (*BasicTicketAck) Loggable ¶
func (a *BasicTicketAck) Loggable() map[string]interface{}
func (*BasicTicketAck) Publisher ¶
func (a *BasicTicketAck) Publisher() peer.ID
func (*BasicTicketAck) Receiver ¶
func (a *BasicTicketAck) Receiver() peer.ID
func (*BasicTicketAck) ToProto ¶
func (a *BasicTicketAck) ToProto() *pb.TicketAck
type InvalidPublisherError ¶
type InvalidPublisherError struct {
// contains filtered or unexported fields
}
func (*InvalidPublisherError) Error ¶
func (e *InvalidPublisherError) Error() string
type NotInitializeError ¶
type NotInitializeError struct{}
func (*NotInitializeError) Error ¶
func (e *NotInitializeError) Error() string
type Ticket ¶
type Ticket interface { Publisher() peer.ID // Needed because the ticket receiver should send ack to ticket sender SendTo() peer.ID Cid() cid.Cid Level() int64 // Higher level, lower priority //Valid(peer.ID, peer.ID) bool GetSize() int64 GetState() int32 BasicInfo() string //Called when receive ack for this Ticket ACKed() //Called when receive cancel for thie Ticket Canceled() //TODO: Add digital signature to ticket. - Riften //Signature String ToProto() *pb.Ticket SetPublisher(peer.ID) SetTimeStamp(timeStamp int64) Loggable }
type TicketAck ¶
type TicketNotFound ¶
type TicketNotFound struct {
// contains filtered or unexported fields
}
func (*TicketNotFound) Error ¶
func (e *TicketNotFound) Error() string
type TicketStore ¶
type TicketStore interface { AddTicket(ticket Ticket) error // called after sending a ticket AddTickets(ticket []Ticket) error GetTickets(cid cid.Cid) ([]Ticket, error) //GetTicketsByCids(cids []cid.Cid) (map[cid.Cid] []Ticket, error) RemoveTicket(pid peer.ID, cid cid.Cid) error // remove a specific ticket from the `sended ticket list`, called after receive a reject RemoveTicketEqualsTo(ticket Ticket) Clean() RemoveCanceled() int PopTickets() *TicketTask TicketNumber() int TicketSize() int64 // Interfaces for sending tickets - Add by Jerry RemoveTickets(pid peer.ID, cids []cid.Cid) error // remove a set of tickets from the `sended ticket list` PrepareSending(acks []TicketAck) error // called if don't have corresponding block when receiving an ACK, put the entry on a list RemoveSendingTask(pid peer.ID, cids []cid.Cid) error // remove a specific task from the `prepared sending task list`, called after receive a reject PopSendingTasks(cids []cid.Cid) ([]TicketAck, error) // pop all tasks for a specific cid in `prepared sending task list`, called when a block is received PredictTime() int64 // Get the predicted time used to complete all the tickets sent. Return time in millsecond // Interfaces for receving tickets - Add by Jerry StoreReceivedTickets(tickets []Ticket) error GetReceivedTicket(cids []cid.Cid) (map[cid.Cid]Ticket, error) }
*
- ticketStore is used to store the tickets published.
- Please do not use it to store the ticket received!!!
- It is used in following cases:
- - Compute the size of tickets waiting for deliving
- - Record the tickets so that we can verify the ticket ack.
- - Control how many tickets to publish
type TicketTask ¶
Click to show internal directories.
Click to hide internal directories.