Documentation
¶
Index ¶
- Constants
- Variables
- func AddCodingBlobs2(blobs *Blobs, start int)
- func BlobGenerator(reader net.PacketConn, capacity int) <-chan *Blobs
- func BlobSender(writer net.PacketConn, input <-chan *Blobs)
- func DecodeRS(frame []*Blob, start, end uint64) error
- func DecodeRSBlock(coding [][]byte, data [][]byte) error
- func EncodeRS(frame []*Blob, start, numBlobs uint64) error
- func EncodeRSBlock(coding [][]byte, data [][]byte) error
- func FrameGenerator(frame *Frame, input <-chan *Blobs) (chan *Blobs, chan []uint64)
- func PacketGenerator(reader net.PacketConn, capacity int) <-chan *Packets
- type Blob
- type Blobs
- type Frame
- type PCon
- func (p *PCon) Close() error
- func (p *PCon) LocalAddr() net.Addr
- func (p *PCon) ReadFrom(b []byte) (n int, addr net.Addr, err error)
- func (p *PCon) SetDeadline(t time.Time) error
- func (p *PCon) SetReadDeadline(t time.Time) error
- func (p *PCon) SetWriteDeadline(t time.Time) error
- func (p *PCon) WriteTo(b []byte, addr net.Addr) (n int, err error)
- type Packet
- type Packets
- type SocketMock
- func (conn *SocketMock) AddToReadBuff(b []byte)
- func (conn *SocketMock) Close() error
- func (conn *SocketMock) EmptyWriteBuff() []byte
- func (conn *SocketMock) LocalAddr() net.Addr
- func (conn *SocketMock) ReadBuffSize() int
- func (conn *SocketMock) ReadFrom(b []byte) (n int, addr net.Addr, err error)
- func (conn *SocketMock) SetDeadline(t time.Time) error
- func (conn *SocketMock) SetReadDeadline(t time.Time) error
- func (conn *SocketMock) SetWriteDeadline(t time.Time) error
- func (conn *SocketMock) WriteBuffSize() int
- func (conn *SocketMock) WriteTo(b []byte, addr net.Addr) (n int, err error)
Constants ¶
const ( // BlobDataSize represents size of data in blob BlobDataSize = 1024 * 64 // BlobRealDataSize represents real data in blob BlobRealDataSize = BlobDataSize - ed25519.PublicKeySize - 8 - 4 // NumBlobs represents number of packets in Packets struct NumBlobs = NumPackets * packetDataSize / BlobDataSize // DataOffset identifies where blob data starts in blob.Data[] array DataOffset = flagsOffset + 4 )
const ( // TransactionAddrServer is an address for transaction socket TransactionAddrServer = "0.0.0.0:40051" // BlockAddrServer is an address for incoming blocks BlockAddrServer = "127.0.0.1:40052" // MessagingAddrServer is an address for messaging socket MessagingAddrServer = "0.0.0.0:40057" )
const ( NumCoded = 20 MaxMissing = 4 NumData = NumCoded - MaxMissing )
const FrameSize = 2 * 1024
FrameSize represents blob count in frame
const (
// NumPackets represents number of packets in Packets struct
NumPackets = 1024 * 8
)
Variables ¶
var BlockAddrUserUDP = net.UDPAddr{ Port: 50053, IP: net.ParseIP("127.0.0.1"), }
BlockAddrUserUDP is UDP address for Block transfering
Functions ¶
func AddCodingBlobs2 ¶
func BlobGenerator ¶
func BlobGenerator(reader net.PacketConn, capacity int) <-chan *Blobs
BlobGenerator thread is responsible for reading blobs from socket and sending to the output channel
func BlobSender ¶
func BlobSender(writer net.PacketConn, input <-chan *Blobs)
BlobSender thread is responsible for getting blobs from input channel and sending to the socket
func DecodeRS ¶
DecodeRS receives frame and recovers damaged data for efficiency it recovers only data, if coded blobs are demaged they will not be recovered
func DecodeRSBlock ¶
DecodeRSBlock receives data and coding blocks. Recovers data from coding blocks Damaged data or coding block should be set to zero-length or nil Data and Coding must contain slices or else data will be copied and recovered at another memory address After recovery data is verified. The unsuccessful recovery causes error.
func EncodeRSBlock ¶
EncodeRSBlock generates Reed-Solomon codes and writes to coding array coding and data elements must all be the same size
func FrameGenerator ¶
FrameGenerator thread is responsible for generating recovered chunks of blobs form the Frame. Other nodes send Encoded blobs, so we have to make sure blobs can be decoded properly.
func PacketGenerator ¶
func PacketGenerator(reader net.PacketConn, capacity int) <-chan *Packets
PacketGenerator thread is responsible for reading packets from socket and sending to the output channel
Types ¶
type Blob ¶
type Blob struct {
Data [BlobDataSize]byte
Addr net.Addr //UDP Address
Size uint32
}
Blob stores block data Note: for now blob is just the copy of the Packet type with the exception of the byte array size
func AddCodingBlobs ¶
AddCodingBlobs adds dummy blobs for parity codes
type Blobs ¶
type Blobs struct {
Bs []Blob
}
Blobs stores slice of Blobs
func NewNumBlobs ¶
NewNumBlobs returns Packets object with num packets
func (*Blobs) IndexBlobs ¶
IndexBlobs method will index blobs and set From
type Frame ¶
type Frame struct {
Blobs []*Blob
}
Frame struct saves blobs. We use it to encode and decode blobs
type PCon ¶
type PCon struct {
B []byte
}
PCon mock
func (*PCon) SetDeadline ¶
SetDeadline implements the PacketConn SetDeadline mock method.
func (*PCon) SetReadDeadline ¶
SetReadDeadline implements the PacketConn SetReadDeadline mock method.
func (*PCon) SetWriteDeadline ¶
SetWriteDeadline implements the PacketConn SetWriteDeadline mock method.
type Packet ¶
type Packet struct {
Data [packetDataSize]byte
Size uint8
Addr net.Addr //UDP Address
// contains filtered or unexported fields
}
Packet stores transaction data
type Packets ¶
type Packets struct {
Ps []Packet
}
Packets stores slice of packets
func NewNumPackets ¶
NewNumPackets returns Packets object with num packets
func PacketBatch ¶
PacketBatch is responsible for reading packets from channel and sending batches of packets to the output maximum batch size should be maxBatchSize packets PacketBatch waits for 1 second for the incoming packets
type SocketMock ¶
SocketMock is socket connection mock for testing
func NewSocketMock ¶
func NewSocketMock(readError error, writeError error, addr net.Addr) *SocketMock
func (*SocketMock) AddToReadBuff ¶
func (conn *SocketMock) AddToReadBuff(b []byte)
func (*SocketMock) Close ¶
func (conn *SocketMock) Close() error
Close implements the PacketConn Close mock method.
func (*SocketMock) EmptyWriteBuff ¶
func (conn *SocketMock) EmptyWriteBuff() []byte
func (*SocketMock) LocalAddr ¶
func (conn *SocketMock) LocalAddr() net.Addr
LocalAddr implements the PacketConn LocalAddr mock method.
func (*SocketMock) ReadBuffSize ¶
func (conn *SocketMock) ReadBuffSize() int
func (*SocketMock) SetDeadline ¶
func (conn *SocketMock) SetDeadline(t time.Time) error
SetDeadline implements the PacketConn SetDeadline mock method.
func (*SocketMock) SetReadDeadline ¶
func (conn *SocketMock) SetReadDeadline(t time.Time) error
SetReadDeadline implements the PacketConn SetReadDeadline mock method.
func (*SocketMock) SetWriteDeadline ¶
func (conn *SocketMock) SetWriteDeadline(t time.Time) error
SetWriteDeadline implements the PacketConn SetWriteDeadline mock method.
func (*SocketMock) WriteBuffSize ¶
func (conn *SocketMock) WriteBuffSize() int