types

package
v0.0.1-pre-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(w io.Writer) *logger

Types

type Buffer

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

func NewBuffer

func NewBuffer(size uint) *Buffer

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

func (*Buffer) Ref

func (b *Buffer) Ref() *[]byte

type ConcurrentBuffer

type ConcurrentBuffer struct {
	Buffer
	sync.Mutex
	// contains filtered or unexported fields
}

func NewConcurrentBuffer

func NewConcurrentBuffer(size uint) *ConcurrentBuffer

func (*ConcurrentBuffer) Bytes

func (cb *ConcurrentBuffer) Bytes() []byte

func (*ConcurrentBuffer) Close

func (cb *ConcurrentBuffer) Close()

func (*ConcurrentBuffer) DumpBytes

func (cb *ConcurrentBuffer) DumpBytes() []byte

func (*ConcurrentBuffer) IsOpen

func (cb *ConcurrentBuffer) IsOpen() bool

func (*ConcurrentBuffer) Open

func (cb *ConcurrentBuffer) Open()

func (*ConcurrentBuffer) Signal

func (cb *ConcurrentBuffer) Signal()

func (*ConcurrentBuffer) Signals

func (cb *ConcurrentBuffer) Signals() <-chan struct{}

func (*ConcurrentBuffer) Wait

func (cb *ConcurrentBuffer) Wait()

type Logger

type Logger interface {
	Debug(...interface{})
	Log(...interface{})
	Info(...interface{})
	Error(...interface{})
	Warn(...interface{})
}

type Packet

type Packet struct {
	Nonce uint32
	Data  []byte
	From  string // TODO(team): Change this temporary string when we strar using IDs
	// contains filtered or unexported fields
}

func NewPacket

func NewPacket(nonce uint32, data []byte, from string, isEncoded bool) Packet

type Request

type Request struct {
	Nonce       uint32
	ResponsesCh chan Packet
}

func (*Request) Respond

func (r *Request) Respond(packet Packet)

type RequestMap

type RequestMap struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TODO(derrandz): This structure is called a `RequestMap`, but is using a slice and therefore does not take advantage of the o(1) slice indexing.

func NewRequestMap

func NewRequestMap(cap uint) *RequestMap

func (*RequestMap) Delete

func (rm *RequestMap) Delete(nonce uint32) bool

func (*RequestMap) Find

func (rm *RequestMap) Find(nonce uint32) (uint32, chan Packet, bool)

Nonces are like IDs. Each generated Request is identified by an ID, so that if a peer makes a request (i.e. generates a work channel that is identified by ID) it can listen on responses coming from the network that have this nonce/ID. It can then redirect this this response to the proper workChannel, since the peer has kept this channel open (and blocking) to receive the response. This is how we achieve a SEND/ACK behavior in our p2p module.

func (*RequestMap) Get

func (rm *RequestMap) Get() *Request

Retrieves a new one request instance with a fresh new nonce. This is a factory function/method. The nonce is monotonically increasing with every .Get

func (*RequestMap) Len

func (rm *RequestMap) Len() int

func (*RequestMap) Requests

func (rm *RequestMap) Requests() []*Request

type Runner

type Runner interface {
	Sink() chan<- Packet
	Done() <-chan uint
}

TODO(derrandz): Document what this is used for

type SocketType

type SocketType string
const (
	Outbound            SocketType = "outbound"
	Inbound             SocketType = "inbound"
	UndefinedSocketType SocketType = "unspecified"
)

Jump to

Keyboard shortcuts

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