CovenantSQL: github.com/CovenantSQL/CovenantSQL/proto Index | Files

package proto

import "github.com/CovenantSQL/CovenantSQL/proto"

Package proto contains DHT RPC protocol struct.

Index

Package Files

nodeinfo.go nodeinfo_gen.go proto.go proto_gen.go servers.go servers_gen.go

Constants

const (
    // NodeIDLen is the NodeID length.
    NodeIDLen = 2 * hash.HashSize
)

Variables

var (
    // NewNodeIDDifficulty is exposed for easy testing.
    NewNodeIDDifficulty = 40
    // NewNodeIDDifficultyTimeout is exposed for easy testing.
    NewNodeIDDifficultyTimeout = 60 * time.Second
)

type AccountAddress Uses

type AccountAddress hash.Hash

AccountAddress is wallet address, will be generated from Hash(nodePublicKey).

func (*AccountAddress) DatabaseID Uses

func (z *AccountAddress) DatabaseID() (d DatabaseID)

DatabaseID converts AccountAddress to DatabaseID.

func (*AccountAddress) MarshalHash Uses

func (z *AccountAddress) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash.

func (AccountAddress) MarshalJSON Uses

func (z AccountAddress) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (AccountAddress) MarshalYAML Uses

func (z AccountAddress) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*AccountAddress) Msgsize Uses

func (z *AccountAddress) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message.

func (AccountAddress) String Uses

func (z AccountAddress) String() string

String is a string variable.

func (*AccountAddress) UnmarshalJSON Uses

func (z *AccountAddress) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*AccountAddress) UnmarshalYAML Uses

func (z *AccountAddress) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type AddrAndGas Uses

type AddrAndGas struct {
    AccountAddress AccountAddress
    RawNodeID      RawNodeID
    GasAmount      uint64
}

AddrAndGas records each node's address, node id and gas that node receives.

func (*AddrAndGas) MarshalHash Uses

func (z *AddrAndGas) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*AddrAndGas) Msgsize Uses

func (z *AddrAndGas) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type DatabaseID Uses

type DatabaseID string

DatabaseID is database name, will be generated from UUID.

func FromAccountAndNonce Uses

func FromAccountAndNonce(accountAddress AccountAddress, nonce uint32) DatabaseID

FromAccountAndNonce generates databaseID from Account and its nonce.

func (*DatabaseID) AccountAddress Uses

func (d *DatabaseID) AccountAddress() (a AccountAddress, err error)

AccountAddress converts DatabaseID to AccountAddress.

func (DatabaseID) MarshalHash Uses

func (z DatabaseID) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (DatabaseID) Msgsize Uses

func (z DatabaseID) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type Envelope Uses

type Envelope struct {
    Version string        `json:"v"`
    TTL     time.Duration `json:"t"`
    Expire  time.Duration `json:"e"`
    NodeID  *RawNodeID    `json:"id"`
    // contains filtered or unexported fields
}

Envelope is the protocol header.

func (*Envelope) GetContext Uses

func (e *Envelope) GetContext() context.Context

GetContext returns context from envelop which is set in server Accept.

func (*Envelope) GetExpire Uses

func (e *Envelope) GetExpire() time.Duration

GetExpire implements EnvelopeAPI.GetExpire.

func (*Envelope) GetNodeID Uses

func (e *Envelope) GetNodeID() *RawNodeID

GetNodeID implements EnvelopeAPI.GetNodeID.

func (*Envelope) GetTTL Uses

func (e *Envelope) GetTTL() time.Duration

GetTTL implements EnvelopeAPI.GetTTL.

func (*Envelope) GetVersion Uses

func (e *Envelope) GetVersion() string

GetVersion implements EnvelopeAPI.GetVersion.

func (*Envelope) MarshalHash Uses

func (z *Envelope) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*Envelope) Msgsize Uses

func (z *Envelope) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Envelope) SetContext Uses

func (e *Envelope) SetContext(ctx context.Context)

SetContext set a ctx in envelope.

func (*Envelope) SetExpire Uses

func (e *Envelope) SetExpire(exp time.Duration)

SetExpire implements EnvelopeAPI.SetExpire.

func (*Envelope) SetNodeID Uses

func (e *Envelope) SetNodeID(nodeID *RawNodeID)

SetNodeID implements EnvelopeAPI.SetNodeID.

func (*Envelope) SetTTL Uses

func (e *Envelope) SetTTL(ttl time.Duration)

SetTTL implements EnvelopeAPI.SetTTL.

func (*Envelope) SetVersion Uses

func (e *Envelope) SetVersion(ver string)

SetVersion implements EnvelopeAPI.SetVersion.

type EnvelopeAPI Uses

type EnvelopeAPI interface {
    GetVersion() string
    GetTTL() time.Duration
    GetExpire() time.Duration
    GetNodeID() *RawNodeID
    GetContext() context.Context

    SetVersion(string)
    SetTTL(time.Duration)
    SetExpire(time.Duration)
    SetNodeID(*RawNodeID)
    SetContext(context.Context)
}

EnvelopeAPI defines envelope access functions for rpc Request/Response.

type FindNeighborReq Uses

type FindNeighborReq struct {
    ID    NodeID
    Roles []ServerRole
    Count int
    Envelope
}

FindNeighborReq is FindNeighbor RPC request.

func (*FindNeighborReq) MarshalHash Uses

func (z *FindNeighborReq) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*FindNeighborReq) Msgsize Uses

func (z *FindNeighborReq) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type FindNeighborResp Uses

type FindNeighborResp struct {
    Nodes []Node
    Msg   string
    Envelope
}

FindNeighborResp is FindNeighbor RPC response.

func (*FindNeighborResp) MarshalHash Uses

func (z *FindNeighborResp) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*FindNeighborResp) Msgsize Uses

func (z *FindNeighborResp) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type FindNodeReq Uses

type FindNodeReq struct {
    ID  NodeID
    Envelope
}

FindNodeReq is FindNode RPC request.

func (*FindNodeReq) MarshalHash Uses

func (z *FindNodeReq) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*FindNodeReq) Msgsize Uses

func (z *FindNodeReq) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type FindNodeResp Uses

type FindNodeResp struct {
    Node *Node
    Msg  string
    Envelope
}

FindNodeResp is FindNode RPC response.

func (*FindNodeResp) MarshalHash Uses

func (z *FindNodeResp) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*FindNodeResp) Msgsize Uses

func (z *FindNodeResp) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type Node Uses

type Node struct {
    ID         NodeID                `yaml:"ID"`
    Role       ServerRole            `yaml:"Role"`
    Addr       string                `yaml:"Addr"`
    DirectAddr string                `yaml:"DirectAddr,omitempty"`
    PublicKey  *asymmetric.PublicKey `yaml:"PublicKey"`
    Nonce      mine.Uint256          `yaml:"Nonce"`
}

Node is all node info struct.

func NewNode Uses

func NewNode() *Node

NewNode just return a new node struct.

func (*Node) InitNodeCryptoInfo Uses

func (node *Node) InitNodeCryptoInfo(timeThreshold time.Duration) (err error)

InitNodeCryptoInfo generate Node asymmetric key pair and generate Node.NonceInfo. Node.ID = Node.NonceInfo.Hash.

func (*Node) MarshalHash Uses

func (z *Node) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*Node) Msgsize Uses

func (z *Node) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type NodeID Uses

type NodeID string

NodeID is the Hex of RawNodeID.

func (*NodeID) Difficulty Uses

func (id *NodeID) Difficulty() (difficulty int)

Difficulty returns NodeID difficulty, returns -1 on length mismatch or any error.

func (*NodeID) IsEmpty Uses

func (id *NodeID) IsEmpty() bool

IsEmpty test if a nodeID is empty.

func (*NodeID) IsEqual Uses

func (id *NodeID) IsEqual(target *NodeID) bool

IsEqual returns if two node id is equal.

func (*NodeID) MarshalBinary Uses

func (id *NodeID) MarshalBinary() (keyBytes []byte, err error)

MarshalBinary does the serialization.

func (NodeID) MarshalHash Uses

func (z NodeID) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (NodeID) Msgsize Uses

func (z NodeID) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*NodeID) ToRawNodeID Uses

func (id *NodeID) ToRawNodeID() *RawNodeID

ToRawNodeID converts NodeID to RawNodeID.

func (*NodeID) UnmarshalBinary Uses

func (id *NodeID) UnmarshalBinary(keyBytes []byte) (err error)

UnmarshalBinary does the deserialization.

type NodeKey Uses

type NodeKey RawNodeID

NodeKey is node key on consistent hash ring, generate from Hash(NodeID).

func (*NodeKey) Less Uses

func (k *NodeKey) Less(y *NodeKey) bool

Less return true if k is less than y.

func (*NodeKey) MarshalHash Uses

func (z *NodeKey) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*NodeKey) Msgsize Uses

func (z *NodeKey) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type Peers Uses

type Peers struct {
    PeersHeader
    verifier.DefaultHashSignVerifierImpl
}

Peers defines the peers configuration.

func (*Peers) Clone Uses

func (p *Peers) Clone() (copy Peers)

Clone makes a deep copy of Peers.

func (*Peers) Find Uses

func (p *Peers) Find(key NodeID) (index int32, found bool)

Find finds the index of the server with the specified key in the server list.

func (*Peers) MarshalHash Uses

func (z *Peers) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*Peers) Msgsize Uses

func (z *Peers) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Peers) Sign Uses

func (p *Peers) Sign(signer *asymmetric.PrivateKey) (err error)

Sign generates signature.

func (*Peers) Verify Uses

func (p *Peers) Verify() (err error)

Verify verify signature.

type PeersHeader Uses

type PeersHeader struct {
    Version uint64
    Term    uint64
    Leader  NodeID
    Servers []NodeID
}

PeersHeader defines the header for miner peers.

func (*PeersHeader) MarshalHash Uses

func (z *PeersHeader) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*PeersHeader) Msgsize Uses

func (z *PeersHeader) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type PingReq Uses

type PingReq struct {
    Node Node
    Envelope
}

PingReq is Ping RPC request.

func (*PingReq) MarshalHash Uses

func (z *PingReq) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*PingReq) Msgsize Uses

func (z *PingReq) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type PingResp Uses

type PingResp struct {
    Msg string
    Envelope
}

PingResp is Ping RPC response, i.e. Pong.

func (*PingResp) MarshalHash Uses

func (z *PingResp) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*PingResp) Msgsize Uses

func (z *PingResp) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type RawNodeID Uses

type RawNodeID struct {
    hash.Hash
}

RawNodeID is node name, will be generated from Hash(nodePublicKey) RawNodeID length should be 32 bytes normally.

func (*RawNodeID) MarshalHash Uses

func (z *RawNodeID) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*RawNodeID) Msgsize Uses

func (z *RawNodeID) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*RawNodeID) ToNodeID Uses

func (id *RawNodeID) ToNodeID() NodeID

ToNodeID converts RawNodeID to NodeID.

type ServerRole Uses

type ServerRole int

ServerRole defines the role of node to be leader/coordinator in peer set.

const (
    // Unknown is the zero value
    Unknown ServerRole = iota
    // Leader is a server that have the ability to organize committing requests.
    Leader
    // Follower is a server that follow the leader log commits.
    Follower
    // Miner is a server that run sql database.
    Miner
    // Client is a client that send sql query to database>
    Client
)

func (ServerRole) MarshalHash Uses

func (z ServerRole) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (ServerRole) MarshalYAML Uses

func (s ServerRole) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (ServerRole) Msgsize Uses

func (z ServerRole) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (ServerRole) String Uses

func (s ServerRole) String() string

String is a string variable of ServerRole.

func (*ServerRole) UnmarshalYAML Uses

func (s *ServerRole) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type ServerRoles Uses

type ServerRoles []ServerRole

ServerRoles is []ServerRole.

func (*ServerRoles) Contains Uses

func (ss *ServerRoles) Contains(role ServerRole) bool

Contains returns if given role is in the ServerRoles>.

func (ServerRoles) MarshalHash Uses

func (z ServerRoles) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (ServerRoles) Msgsize Uses

func (z ServerRoles) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type UploadMetricsReq Uses

type UploadMetricsReq struct {
    // MetricFamily Bytes array
    MFBytes [][]byte
    Envelope
}

UploadMetricsReq is UploadMetrics RPC request.

func (*UploadMetricsReq) MarshalHash Uses

func (z *UploadMetricsReq) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*UploadMetricsReq) Msgsize Uses

func (z *UploadMetricsReq) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type UploadMetricsResp Uses

type UploadMetricsResp struct {
    Msg string
    Envelope
}

UploadMetricsResp is UploadMetrics RPC response.

func (*UploadMetricsResp) MarshalHash Uses

func (z *UploadMetricsResp) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*UploadMetricsResp) Msgsize Uses

func (z *UploadMetricsResp) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

Package proto imports 11 packages (graph) and is imported by 45 packages. Updated 2019-06-19. Refresh now. Tools for package owners.