Documentation ¶
Overview ¶
Package recon provides the SKS reconciliation protocol, prefix tree interface and an in-memory prefix-tree implementation.
The Conflux recon API is versioned with gopkg. Use in your projects with:
import "gopkg.in/hockeypuck/conflux.v2/recon"
Index ¶
- Constants
- Variables
- func AddElementArray(t PrefixTree, z *cf.Zp) (marray []*cf.Zp, err error)
- func DelElementArray(t PrefixTree, z *cf.Zp) (marray []*cf.Zp)
- func IsGossipBlocked(err error) bool
- func MustElements(node PrefixNode) []*cf.Zp
- func NextChild(n PrefixNode, bs *cf.Bitstring, depth int) int
- func PadSksElement(zb []byte) []byte
- func ReadBitstring(r io.Reader) (*cf.Bitstring, error)
- func ReadInt(r io.Reader) (n int, err error)
- func ReadLen(r io.Reader) (int, error)
- func ReadString(r io.Reader) (string, error)
- func ReadZSet(r io.Reader) (*cf.ZSet, error)
- func ReadZZarray(r io.Reader) ([]*cf.Zp, error)
- func ReadZp(r io.Reader) (*cf.Zp, error)
- func WriteBitstring(w io.Writer, bs *cf.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 *cf.ZSet) error
- func WriteZZarray(w io.Writer, arr []*cf.Zp) (err error)
- func WriteZp(w io.Writer, z *cf.Zp) (err error)
- type Config
- type DbRepl
- type DbRqst
- type Done
- type Elements
- type Error
- type Flush
- type FullElements
- type IPMatcher
- type MemPrefixNode
- func (n *MemPrefixNode) Children() ([]PrefixNode, error)
- func (n *MemPrefixNode) Config() *PTreeConfig
- func (n *MemPrefixNode) Elements() ([]*cf.Zp, error)
- func (n *MemPrefixNode) IsLeaf() bool
- func (n *MemPrefixNode) Key() *cf.Bitstring
- func (n *MemPrefixNode) Parent() (PrefixNode, bool, error)
- func (n *MemPrefixNode) SValues() []*cf.Zp
- func (n *MemPrefixNode) Size() int
- type MemPrefixTree
- func (t *MemPrefixTree) Close() error
- func (t *MemPrefixTree) Create() error
- func (t *MemPrefixTree) Drop() error
- func (t *MemPrefixTree) Init()
- func (t *MemPrefixTree) Insert(z *cf.Zp) error
- func (t *MemPrefixTree) Node(bs *cf.Bitstring) (PrefixNode, error)
- func (t *MemPrefixTree) Points() []*cf.Zp
- func (t *MemPrefixTree) Remove(z *cf.Zp) error
- func (t *MemPrefixTree) Root() (PrefixNode, error)
- type MsgType
- type PTreeConfig
- type Partner
- type PartnerMap
- type Peer
- func (p *Peer) Accept(conn net.Conn) (_err error)
- func (p *Peer) Flush()
- func (p *Peer) Gossip() error
- func (p *Peer) InitiateRecon(addr net.Addr) error
- func (p *Peer) Insert(zs ...*cf.Zp)
- func (p *Peer) Remove(zs ...*cf.Zp)
- func (p *Peer) Serve() error
- func (p *Peer) SetMutatedFunc(f func())
- func (p *Peer) Start()
- func (p *Peer) StartMode(mode PeerMode)
- func (p *Peer) Stop() error
- type PeerMode
- 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 ( NetworkDefault = netType("") NetworkTCP = netType("tcp") NetworkUnix = netType("unix") )
const ( DefaultVersion = "1.1.3" DefaultLogName = "conflux.recon" DefaultHTTPAddr = ":11371" DefaultReconAddr = ":11370" DefaultGossipIntervalSecs = 60 DefaultMaxOutstandingReconRequests = 100 DefaultThreshMult = 10 DefaultBitQuantum = 2 DefaultMBar = 5 )
const GOSSIP = "gossip"
const SERVE = "serve"
Variables ¶
var ( PeerModeDefault = PeerMode("") PeerModeGossipOnly = PeerMode("gossip only") PeerModeServeOnly = PeerMode("serve only") )
var ErrIncompatiblePeer error = errors.New("remote peer configuration is not compatible")
var ErrNoPartners error = errors.New("no recon partners configured")
var ErrNodeNotFound error = errors.New("prefix-tree node not found")
var ErrPeerBusy error = errors.New("peer is busy handling another request")
var ErrReconDone = errors.New("reconciliation done")
var ErrReconRqstPolyNotFound = errors.New(
"peer should not receive a request for a non-existant node in ReconRqstPoly")
var ErrRemoteRejectedConfig error = errors.New("remote rejected configuration")
var ErrSamplePointElement = errors.New("sample point added to elements")
var ErrUnexpectedLeafNode = errors.New("unexpected leaf node")
var RemoteConfigFailed string = "failed"
var RemoteConfigPassed string = "passed"
var (
SksZpNbytes int
)
Functions ¶
func AddElementArray ¶
func DelElementArray ¶
func DelElementArray(t PrefixTree, z *cf.Zp) (marray []*cf.Zp)
func IsGossipBlocked ¶
func MustElements ¶
func MustElements(node PrefixNode) []*cf.Zp
func PadSksElement ¶
Types ¶
type Config ¶
type FullElements ¶
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() ([]PrefixNode, error)
func (*MemPrefixNode) Config ¶
func (n *MemPrefixNode) Config() *PTreeConfig
func (*MemPrefixNode) IsLeaf ¶
func (n *MemPrefixNode) IsLeaf() bool
func (*MemPrefixNode) Key ¶
func (n *MemPrefixNode) Key() *cf.Bitstring
func (*MemPrefixNode) Parent ¶
func (n *MemPrefixNode) Parent() (PrefixNode, bool, error)
func (*MemPrefixNode) SValues ¶
func (n *MemPrefixNode) SValues() []*cf.Zp
func (*MemPrefixNode) Size ¶
func (n *MemPrefixNode) Size() int
type MemPrefixTree ¶
type MemPrefixTree struct { PTreeConfig // contains filtered or unexported fields }
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 *cf.Zp) error
Insert a Z/Zp integer into the prefix tree
func (*MemPrefixTree) Node ¶
func (t *MemPrefixTree) Node(bs *cf.Bitstring) (PrefixNode, error)
func (*MemPrefixTree) Points ¶
func (t *MemPrefixTree) Points() []*cf.Zp
func (*MemPrefixTree) Remove ¶
func (t *MemPrefixTree) Remove(z *cf.Zp) error
Remove a Z/Zp integer from the prefix tree
func (*MemPrefixTree) Root ¶
func (t *MemPrefixTree) Root() (PrefixNode, error)
type PTreeConfig ¶
type PTreeConfig struct { ThreshMult int `toml:"threshMult"` BitQuantum int `toml:"bitQuantum"` MBar int `toml:"mBar"` }
func (*PTreeConfig) JoinThreshold ¶
func (c *PTreeConfig) JoinThreshold() int
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 (*PTreeConfig) NumSamples ¶
func (c *PTreeConfig) NumSamples() int
NumSamples returns the number of sample points used for interpolation. This must match among all reconciliation peers.
func (*PTreeConfig) SplitThreshold ¶
func (c *PTreeConfig) SplitThreshold() int
SplitThreshold returns the maximum number of elements a prefix tree node may contain before creating child nodes and distributing the elements among them.
type PartnerMap ¶
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) SetMutatedFunc ¶
func (p *Peer) SetMutatedFunc(f func())
type PrefixNode ¶
type PrefixNode interface { Config() *PTreeConfig Parent() (PrefixNode, bool, error) Key() *cf.Bitstring Elements() ([]*cf.Zp, error) Size() int Children() ([]PrefixNode, error) SValues() []*cf.Zp IsLeaf() bool }
func Find ¶
func Find(t PrefixTree, z *cf.Zp) (PrefixNode, error)
func MustChildren ¶
func MustChildren(node PrefixNode) []PrefixNode
type PrefixTree ¶
type ReconMsg ¶
type ReconMsg interface { MsgType() MsgType // contains filtered or unexported methods }
type ReconRqstFull ¶
func (*ReconRqstFull) MsgType ¶
func (msg *ReconRqstFull) MsgType() MsgType
func (*ReconRqstFull) String ¶
func (msg *ReconRqstFull) String() string
type ReconRqstPoly ¶
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 { PTreeConfig Version string `toml:"version"` LogName string `toml:"logname" json:"-"` HTTPAddr string `toml:"httpAddr"` HTTPNet netType `toml:"httpNet" json:"-"` ReconAddr string `toml:"reconAddr"` ReconNet netType `toml:"reconNet" json:"-"` Partners PartnerMap `toml:"partner"` AllowCIDRs []string `toml:"allowCIDRs"` Filters []string `toml:"filters"` // Backwards-compatible keys CompatHTTPPort int `toml:"httpPort" json:"-"` CompatReconPort int `toml:"reconPort" json:"-"` CompatPartnerAddrs []string `toml:"partners" json:"-"` GossipIntervalSecs int `toml:"gossipIntervalSecs" json:"-"` MaxOutstandingReconRequests int `toml:"maxOutstandingReconRequests" json:"-"` }
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) PartnerAddrs ¶
PartnerAddrs returns the resolved network addresses of configured partner peers.
Directories ¶
Path | Synopsis |
---|---|
Package leveldb provides a key-value storage implementation of the recon prefix tree interface.
|
Package leveldb provides a key-value storage implementation of the recon prefix tree interface. |
Package testing provides some unit-testing support functions.
|
Package testing provides some unit-testing support functions. |