Documentation
¶
Overview ¶
Package recon provides the SKS reconciliation protocol, prefix tree interface and an in-memory prefix-tree implementation.
Index ¶
- Constants
- Variables
- func AddElementArray(t PrefixTree, z *Zp) (marray []*Zp, err error)
- func DelElementArray(t PrefixTree, z *Zp) (marray []*Zp)
- func NextChild(n PrefixNode, bs *Bitstring, depth int) int
- func PadSksElement(zb []byte) []byte
- func ReadBitstring(r io.Reader) (*Bitstring, error)
- func ReadInt(r io.Reader) (n int, err error)
- func ReadString(r io.Reader) (string, error)
- func ReadZSet(r io.Reader) (*ZSet, error)
- func ReadZZarray(r io.Reader) ([]*Zp, error)
- func ReadZp(r io.Reader) (*Zp, error)
- func WriteBitstring(w io.Writer, bs *Bitstring) (err error)
- func WriteInt(w io.Writer, n int) (err error)
- func WriteMsg(w io.Writer, msgs ...ReconMsg) (err error)
- func WriteMsgDirect(w io.Writer, msg ReconMsg) (err error)
- func WriteString(w io.Writer, text string) (err error)
- func WriteZSet(w io.Writer, zset *ZSet) error
- func WriteZZarray(w io.Writer, arr []*Zp) (err error)
- func WriteZp(w io.Writer, z *Zp) (err error)
- type Config
- type DbRepl
- type DbRqst
- type Done
- type Elements
- type Error
- type Flush
- type FullElements
- type MemPrefixNode
- func (n *MemPrefixNode) Children() (result []PrefixNode)
- func (n *MemPrefixNode) Elements() []*Zp
- func (n *MemPrefixNode) IsLeaf() bool
- func (n *MemPrefixNode) Key() *Bitstring
- func (n *MemPrefixNode) Parent() (PrefixNode, bool)
- func (n *MemPrefixNode) SValues() []*Zp
- func (n *MemPrefixNode) Size() int
- type MemPrefixTree
- func (t *MemPrefixTree) BitQuantum() int
- func (t *MemPrefixTree) Close() error
- func (t *MemPrefixTree) Create() error
- func (t *MemPrefixTree) Drop() error
- func (t *MemPrefixTree) Init()
- func (t *MemPrefixTree) Insert(z *Zp) error
- func (t *MemPrefixTree) JoinThreshold() int
- func (t *MemPrefixTree) Node(bs *Bitstring) (PrefixNode, error)
- func (t *MemPrefixTree) NumSamples() int
- func (t *MemPrefixTree) Points() []*Zp
- func (t *MemPrefixTree) Remove(z *Zp) error
- func (t *MemPrefixTree) Root() (PrefixNode, error)
- func (t *MemPrefixTree) SplitThreshold() int
- type MsgType
- type Partner
- type Peer
- func (p *Peer) Accept(conn net.Conn) error
- func (p *Peer) Disable()
- func (p *Peer) Enable()
- func (p *Peer) Enabled() bool
- func (p *Peer) ExecCmd(cmd reconCmd) (err error)
- func (p *Peer) Gossip()
- func (p *Peer) HandleCmds()
- func (p *Peer) InitiateRecon(conn net.Conn) error
- func (p *Peer) Insert(z *Zp) (err error)
- func (p *Peer) Remove(z *Zp) (err error)
- func (p *Peer) Serve() error
- func (p *Peer) Start()
- func (p *Peer) Stop()
- type PrefixNode
- type PrefixTree
- type ReconMsg
- type ReconRqstFull
- type ReconRqstPoly
- type Recover
- type RecoverChan
- type Settings
- type SyncFail
Constants ¶
const ( MsgTypeReconRqstPoly = MsgType(0) MsgTypeReconRqstFull = MsgType(1) MsgTypeElements = MsgType(2) MsgTypeFullElements = MsgType(3) MsgTypeSyncFail = MsgType(4) MsgTypeDone = MsgType(5) MsgTypeFlush = MsgType(6) MsgTypeError = MsgType(7) MsgTypeDbRqst = MsgType(8) MsgTypeDbRepl = MsgType(9) MsgTypeConfig = MsgType(10) )
const ( DefaultVersion = "1.1.3" DefaultLogName = "conflux.recon" DefaultHTTPAddr = ":11371" DefaultReconAddr = ":11370" DefaultGossipIntervalSecs = 60 DefaultMaxOutstandingReconRequests = 100 )
const DefaultBitQuantum = 2
const DefaultJoinThreshold = DefaultSplitThreshold / 2
const DefaultMBar = 5
const DefaultNumSamples = DefaultMBar + 1
const DefaultSplitThreshold = DefaultThreshMult * DefaultMBar
const DefaultThreshMult = 10
const GOSSIP = "gossip:"
const SERVE = "serve:"
Variables ¶
var ErrSamplePointElement = errors.New("Sample point added to elements")
var ErrUnexpectedLeafNode = errors.New("Unexpected leaf node")
var IncompatiblePeerError error = errors.New("Remote peer configuration is not compatible")
var NoPartnersError error = errors.New("No recon partners configured")
var PNodeNotFound error = errors.New("Prefix-tree node not found")
var ReconDone = errors.New("Reconciliation Done")
var ReconRqstPolyNotFound = errors.New("Peer should not receive a request for a non-existant node in ReconRqstPoly")
var RemoteConfigFailed string = "failed"
var RemoteConfigPassed string = "passed"
var RemoteRejectConfigError error = errors.New("Remote rejected configuration")
var SksZpNbytes int
Functions ¶
func AddElementArray ¶
func AddElementArray(t PrefixTree, z *Zp) (marray []*Zp, err error)
func DelElementArray ¶
func DelElementArray(t PrefixTree, z *Zp) (marray []*Zp)
func NextChild ¶
func NextChild(n PrefixNode, bs *Bitstring, depth int) int
func PadSksElement ¶
func ReadBitstring ¶
func ReadZZarray ¶
func WriteBitstring ¶
func WriteZZarray ¶
Types ¶
type Config ¶
type FullElements ¶
type FullElements struct {
*ZSet
}
func (*FullElements) MsgType ¶
func (msg *FullElements) MsgType() MsgType
func (*FullElements) String ¶
func (msg *FullElements) String() string
type MemPrefixNode ¶
type MemPrefixNode struct { // All nodes share the tree definition as a common context *MemPrefixTree // contains filtered or unexported fields }
func (*MemPrefixNode) Children ¶
func (n *MemPrefixNode) Children() (result []PrefixNode)
func (*MemPrefixNode) Elements ¶
func (n *MemPrefixNode) Elements() []*Zp
func (*MemPrefixNode) IsLeaf ¶
func (n *MemPrefixNode) IsLeaf() bool
func (*MemPrefixNode) Key ¶
func (n *MemPrefixNode) Key() *Bitstring
func (*MemPrefixNode) Parent ¶
func (n *MemPrefixNode) Parent() (PrefixNode, bool)
func (*MemPrefixNode) SValues ¶
func (n *MemPrefixNode) SValues() []*Zp
func (*MemPrefixNode) Size ¶
func (n *MemPrefixNode) Size() int
type MemPrefixTree ¶
type MemPrefixTree struct {
// contains filtered or unexported fields
}
func (*MemPrefixTree) BitQuantum ¶
func (t *MemPrefixTree) BitQuantum() int
func (*MemPrefixTree) Close ¶
func (t *MemPrefixTree) Close() error
func (*MemPrefixTree) Create ¶
func (t *MemPrefixTree) Create() error
func (*MemPrefixTree) Drop ¶
func (t *MemPrefixTree) Drop() error
func (*MemPrefixTree) Init ¶
func (t *MemPrefixTree) Init()
Init configures the tree with default settings if not already set, and initializes the internal state with sample data points, root node, etc.
func (*MemPrefixTree) Insert ¶
func (t *MemPrefixTree) Insert(z *Zp) error
Insert a Z/Zp integer into the prefix tree
func (*MemPrefixTree) JoinThreshold ¶
func (t *MemPrefixTree) JoinThreshold() int
func (*MemPrefixTree) Node ¶
func (t *MemPrefixTree) Node(bs *Bitstring) (PrefixNode, error)
func (*MemPrefixTree) NumSamples ¶
func (t *MemPrefixTree) NumSamples() int
func (*MemPrefixTree) Points ¶
func (t *MemPrefixTree) Points() []*Zp
func (*MemPrefixTree) Remove ¶
func (t *MemPrefixTree) Remove(z *Zp) error
Remove a Z/Zp integer from the prefix tree
func (*MemPrefixTree) Root ¶
func (t *MemPrefixTree) Root() (PrefixNode, error)
func (*MemPrefixTree) SplitThreshold ¶
func (t *MemPrefixTree) SplitThreshold() int
type Peer ¶
type Peer struct { RecoverChan RecoverChan // contains filtered or unexported fields }
func NewMemPeer ¶
func NewMemPeer() *Peer
func NewPeer ¶
func NewPeer(settings *Settings, tree PrefixTree) *Peer
func (*Peer) HandleCmds ¶
func (p *Peer) HandleCmds()
HandleCmds executes recon cmds in a single goroutine. This forces sequential reads and writes to the prefix tree.
type PrefixNode ¶
type PrefixNode interface { BitQuantum() int Parent() (PrefixNode, bool) Key() *Bitstring Elements() []*Zp Size() int Children() []PrefixNode SValues() []*Zp IsLeaf() bool }
func Find ¶
func Find(t PrefixTree, z *Zp) (PrefixNode, error)
type PrefixTree ¶
type ReconMsg ¶
type ReconMsg interface { MsgType() MsgType // contains filtered or unexported methods }
type ReconRqstFull ¶
type ReconRqstFull struct { Prefix *Bitstring Elements *ZSet }
func (*ReconRqstFull) MsgType ¶
func (msg *ReconRqstFull) MsgType() MsgType
func (*ReconRqstFull) String ¶
func (msg *ReconRqstFull) String() string
type ReconRqstPoly ¶
type ReconRqstPoly struct { Prefix *Bitstring Size int Samples []*Zp }
func (*ReconRqstPoly) MsgType ¶
func (msg *ReconRqstPoly) MsgType() MsgType
func (*ReconRqstPoly) String ¶
func (msg *ReconRqstPoly) String() string
type RecoverChan ¶
type RecoverChan chan *Recover
type Settings ¶
type Settings struct { Version string `toml:"version"` LogName string `toml:"logname"` HTTPAddr string `toml:"httpAddr"` HTTPNet network `toml:"httpNet"` ReconAddr string `toml:"reconAddr"` ReconNet network `toml:"reconNet"` Partners map[string]Partner `toml:"partner"` Filters []string `toml:"filters"` // Backwards-compatible keys CompatHTTPPort int `toml:"httpPort"` CompatReconPort int `toml:"reconPort"` CompatPartnerAddrs []string `toml:"partners"` ThreshMult int `toml:"threshMult"` BitQuantum int `toml:"bitQuantum"` MBar int `toml:"mBar"` GossipIntervalSecs int `toml:"gossipIntervalSecs"` MaxOutstandingReconRequests int `toml:"maxOutstandingReconRequests"` ConnTimeout int `toml:"connTimeout"` ReadTimeout int `toml:"readTimeout"` }
Settings holds the configuration settings for the local reconciliation peer.
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings returns default peer configuration settings.
func ParseSettings ¶
ParseSettings parses a TOML-formatted string representation into Settings.
func (*Settings) Config ¶
Config returns a recon protocol config message that described this peer's configuration settings.
func (*Settings) JoinThreshold ¶
JoinThreshold returns the minimum cumulative number of elements under a prefix tree parent node, below which all child nodes are merged into the parent.
func (*Settings) NumSamples ¶
NumSamples returns the number of sample points used for interpolation. This must match among all reconciliation peers.
func (*Settings) PartnerAddrs ¶
PartnerAddrs returns the resolved network addresses of configured partner peers.
func (*Settings) SplitThreshold ¶
SplitThreshold returns the maximum number of elements a prefix tree node may contain before creating child nodes and distributing the elements among them.