Documentation ¶
Index ¶
- Constants
- type AppError
- type GroupID
- type Header
- func (h Header) GetCounter() uint32
- func (h Header) GetErrorCode() uint8
- func (h Header) GetOriginTime() PhaseTime32
- func (h Header) GetPartCount() uint16
- func (h Header) GetPartIndex() uint16
- func (h Header) GetTimeout() time.Duration
- func (h Header) GetTotalSize() uint32
- func (h Header) GroupID() GroupID
- func (h Header) IsAsk() bool
- func (h Header) IsReply() bool
- func (h Header) SetCounter(x uint32)
- func (h Header) SetErrorCode(v uint8)
- func (h Header) SetIsAsk(yes bool)
- func (h Header) SetIsReply(yes bool)
- func (h Header) SetOriginTime(pt PhaseTime32)
- func (h Header) SetPartCount(v uint16)
- func (h Header) SetPartIndex(v uint16)
- func (h Header) SetTimeout(v uint32)
- func (h Header) SetTotalSize(size uint32)
- type Option
- type PhaseTime32
- type Swarm
- func (s *Swarm[A, Pub]) Ask(ctx context.Context, resp []byte, dst A, req p2p.IOVec) (int, error)
- func (s *Swarm[A, Pub]) Close() error
- func (s *Swarm[A, Pub]) LocalAddrs() []A
- func (s *Swarm[A, Pub]) LookupPublicKey(ctx context.Context, x A) (Pub, error)
- func (s *Swarm[A, Pub]) MTU() int
- func (s *Swarm[A, Pub]) ParseAddr(x []byte) (A, error)
- func (s *Swarm[A, Pub]) PublicKey() Pub
- func (s *Swarm[A, Pub]) Receive(ctx context.Context, th func(p2p.Message[A])) error
- func (s *Swarm[A, Pub]) ServeAsk(ctx context.Context, fn func(context.Context, []byte, p2p.Message[A]) int) error
- func (s *Swarm[A, Pub]) Tell(ctx context.Context, dst A, msg p2p.IOVec) error
Constants ¶
View Source
const (
HeaderSize = 6 * 4
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GroupID ¶
type GroupID struct { OriginTime PhaseTime32 Counter uint32 }
type Header ¶
type Header []byte
Header
|<- 32 bits ->|
0 | mode bits 24| resp code 8| 1 | origin time 32| 2 | counter 32| 3 | part size 32| 4 | part index 16| part count 16| 5 | timeout or dest time
func (Header) GetErrorCode ¶
func (Header) GetPartCount ¶
func (Header) GetTimeout ¶
func (Header) SetCounter ¶
func (Header) SetErrorCode ¶
func (Header) SetIsReply ¶
func (Header) SetOriginTime ¶
func (h Header) SetOriginTime(pt PhaseTime32)
func (Header) SetPartCount ¶
func (Header) SetPartIndex ¶
func (Header) SetTotalSize ¶
type PhaseTime32 ¶
type PhaseTime32 uint32
PhaseTime32 represents a timestamp but relative to another timestamp with a longer memory. If a bound can be placed on the difference in clocks between two processes it can provide higher accuracy with fewer bits.
func NewPhaseTime32 ¶
func NewPhaseTime32(x time.Time, units time.Duration) PhaseTime32
type Swarm ¶
type Swarm[A p2p.Addr, Pub any] struct { // contains filtered or unexported fields }
func (*Swarm[A, Pub]) LocalAddrs ¶
func (s *Swarm[A, Pub]) LocalAddrs() []A
func (*Swarm[A, Pub]) LookupPublicKey ¶
Click to show internal directories.
Click to hide internal directories.