Documentation
¶
Index ¶
Constants ¶
const ( // DefaultGCInterval is the default interval that the WriteBufferPool // will perform a sweep to see which expired buffers can be released to // the runtime. DefaultGCInterval = 15 * time.Second // DefaultExpiryInterval is the default, minimum interval that must // elapse before a WriteBuffer will be released. The maximum time before // the buffer can be released is equal to the expiry interval plus the // gc interval. DefaultExpiryInterval = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Peer ¶
type Peer interface { // SendMessage sends a variadic number of message to remote peer. The // first argument denotes if the method should block until the message // has been sent to the remote peer. SendMessage(sync bool, msg ...lnwire.Message) error // AddNewChannel adds a new channel to the peer. The channel should fail // to be added if the cancel channel is closed. AddNewChannel(channel *channeldb.OpenChannel, cancel <-chan struct{}) error // WipeChannel removes the channel uniquely identified by its channel // point from all indexes associated with the peer. WipeChannel(*wire.OutPoint) error // PubKey returns the serialized public key of the remote peer. PubKey() [33]byte // IdentityKey returns the public key of the remote peer. IdentityKey() *btcec.PublicKey // Address returns the network address of the remote peer. Address() net.Addr // QuitSignal is a method that should return a channel which will be // sent upon or closed once the backing peer exits. This allows callers // using the interface to cancel any processing in the event the backing // implementation exits. QuitSignal() <-chan struct{} }
Peer is an interface which represents the remote lightning node inside our system.
type WriteBuffer ¶
type WriteBuffer [lnwire.MaxMessagePayload]byte
WriteBuffer is static byte array occupying to maximum-allowed plaintext-message size.
func (*WriteBuffer) Recycle ¶
func (b *WriteBuffer) Recycle()
Recycle zeroes the WriteBuffer, making it fresh for another use. Zeroing the buffer using a logarithmic number of calls to the optimized copy method. Benchmarking shows this to be ~30 times faster than a for loop that sets each index to 0 for this buffer size. Inspired by: https://stackoverflow.com/questions/30614165/is-there-analog-of-memset-in-go
This is part of the queue.Recycler interface.
type WriteBufferPool ¶
type WriteBufferPool struct {
// contains filtered or unexported fields
}
WriteBufferPool acts a global pool of WriteBuffers, that dynamically allocates and reclaims buffers in response to load.
func NewWriteBufferPool ¶
func NewWriteBufferPool( gcInterval, expiryInterval time.Duration) *WriteBufferPool
NewWriteBufferPool returns a freshly instantiated WriteBufferPool, using the given gcInterval and expiryIntervals.
func (*WriteBufferPool) Return ¶
func (p *WriteBufferPool) Return(buf *WriteBuffer)
Return returns the WriteBuffer to the pool, so that it can be recycled or released.
func (*WriteBufferPool) Take ¶
func (p *WriteBufferPool) Take() *WriteBuffer
Take returns a fresh WriteBuffer to the caller.