Documentation
¶
Index ¶
Constants ¶
const ( // MaxMsgpackVoteSize is the maximum size of a vote, including msgpack control characters // and all required and optional data fields. MaxMsgpackVoteSize = msgpFixMapMarkerSize + len(msgpFixstrCred) + msgpFixMapMarkerSize + len(msgpFixstrPf) + msgpBin8Len80Size + len(msgpFixstrR) + msgpFixMapMarkerSize + len(msgpFixstrPer) + maxMsgpVaruintSize + len(msgpFixstrProp) + msgpFixMapMarkerSize + len(msgpFixstrDig) + msgpBin8Len32Size + len(msgpFixstrEncdig) + msgpBin8Len32Size + len(msgpFixstrOper) + maxMsgpVaruintSize + len(msgpFixstrOprop) + msgpBin8Len32Size + len(msgpFixstrRnd) + maxMsgpVaruintSize + len(msgpFixstrSnd) + msgpBin8Len32Size + len(msgpFixstrStep) + maxMsgpVaruintSize + len(msgpFixstrSig) + msgpFixMapMarkerSize + len(msgpFixstrP) + msgpBin8Len32Size + len(msgpFixstrP1s) + msgpBin8Len64Size + len(msgpFixstrP2) + msgpBin8Len32Size + len(msgpFixstrP2s) + msgpBin8Len64Size + len(msgpFixstrPs) + msgpBin8Len64Size + len(msgpFixstrS) + msgpBin8Len64Size // sig.s: bin8(64) // MaxCompressedVoteSize is the maximum size of a compressed vote using StatelessEncoder, // including all required and optional fields. MaxCompressedVoteSize = headerSize + 80 + maxMsgpVaruintSize*4 + 32*6 + 64*3 // sig.p1s, sig.p2s, sig.s (sig.ps is omitted) )
Variables ¶
var ErrBufferTooSmall = fmt.Errorf("destination buffer too small")
ErrBufferTooSmall is returned when the destination buffer is too small
var ErrLikelyUncompressed = fmt.Errorf("data appears to be uncompressed msgpack")
ErrLikelyUncompressed is returned when vpack decompression detects what appears to be uncompressed msgpack data from a peer claiming vpack support.
Functions ¶
This section is empty.
Types ¶
type StatefulDecoder ¶
type StatefulDecoder struct {
// contains filtered or unexported fields
}
StatefulDecoder decompresses votes by using references to previously seen values from earlier votes.
func NewStatefulDecoder ¶
func NewStatefulDecoder(tableSize uint) (*StatefulDecoder, error)
NewStatefulDecoder creates a new StatefulDecoder with initialized LRU tables of the specified size
func (*StatefulDecoder) Decompress ¶
func (d *StatefulDecoder) Decompress(dst, src []byte) ([]byte, error)
Decompress reverses StatefulEncoder, and writes a valid stateless vpack format buffer into dst. Caller must then pass it to StatelessDecoder.
type StatefulEncoder ¶
type StatefulEncoder struct {
// contains filtered or unexported fields
}
StatefulEncoder compresses votes by using references to previously seen values from earlier votes.
func NewStatefulEncoder ¶
func NewStatefulEncoder(tableSize uint) (*StatefulEncoder, error)
NewStatefulEncoder creates a new StatefulEncoder with initialized LRU tables of the specified size
type StatelessDecoder ¶
type StatelessDecoder struct {
// contains filtered or unexported fields
}
StatelessDecoder decompresses votes that were compressed by StatelessEncoder.
func NewStatelessDecoder ¶
func NewStatelessDecoder() *StatelessDecoder
NewStatelessDecoder returns a new StatelessDecoder.
func (*StatelessDecoder) DecompressVote ¶
func (d *StatelessDecoder) DecompressVote(dst, src []byte) ([]byte, error)
DecompressVote decodes a compressed vote in src and appends it to dst. To re-use dst, run like: dst = dec.DecompressVote(dst[:0], src)
type StatelessEncoder ¶
type StatelessEncoder struct {
// contains filtered or unexported fields
}
StatelessEncoder compresses a msgpack-encoded vote by stripping all msgpack formatting and field names, replacing them with a bitmask indicating which fields are present. It is not thread-safe.
func NewStatelessEncoder ¶
func NewStatelessEncoder() *StatelessEncoder
NewStatelessEncoder returns a new StatelessEncoder.
func (*StatelessEncoder) CompressVote ¶
func (e *StatelessEncoder) CompressVote(dst, src []byte) ([]byte, error)
CompressVote compresses a vote in src and writes it to dst. If the provided buffer dst is nil or too small, a new slice is allocated. The returned slice may be the same as dst. To re-use dst, run like: dst = enc.CompressVote(dst[:0], src)