Documentation
¶
Index ¶
- Constants
- Variables
- func ExpandPath(path string) (string, error)
- func FormatPeerString(rawPubKey []byte, keyType crypto.KeyType, ip string, port int) string
- func NewKey(r io.Reader) *crypto.Secp256k1PrivateKey
- func RestoreDB(ctx context.Context, reader io.Reader, db *config.DBConfig, ...) error
- type AckRes
- type BlockProcessor
- type Config
- type ConsensusEngine
- type ConsensusReset
- type DB
- type DiscReq
- type DiscRes
- type Node
- func (n *Node) AbortBlockExecution(height int64, txIDs []types.Hash) error
- func (n *Node) Addrs() []string
- func (n *Node) BlockByHash(hash types.Hash) (*ktypes.Block, *types.CommitInfo, error)
- func (n *Node) BlockByHeight(height int64) (types.Hash, *ktypes.Block, *types.CommitInfo, error)
- func (n *Node) BlockHeight() int64
- func (n *Node) BlockResultByHash(hash types.Hash) ([]ktypes.TxResult, error)
- func (n *Node) BroadcastTx(ctx context.Context, tx *ktypes.Transaction, sync uint8) (*ktypes.ResultBroadcastTx, error)
- func (n *Node) ChainTx(hash types.Hash) (*chainTypes.Tx, error)
- func (n *Node) ChainUnconfirmedTx(limit int) (int, []types.NamedTx)
- func (n *Node) ConsensusParams() *ktypes.NetworkParameters
- func (n *Node) Dir() string
- func (n *Node) ID() string
- func (n *Node) InCatchup() bool
- func (n *Node) MultiAddrs() []string
- func (n *Node) Peers(context.Context) ([]*adminTypes.PeerInfo, error)
- func (n *Node) Role() types.Role
- func (n *Node) Start(ctx context.Context, bootpeers ...string) error
- func (n *Node) Status(ctx context.Context) (*adminTypes.Status, error)
- func (n *Node) TxQuery(ctx context.Context, hash types.Hash, prove bool) (*ktypes.TxQueryResponse, error)
- func (n *Node) Whitelister() *WhitelistMgr
- type Option
- type SnapshotStore
- type StateSyncService
- type Streamer
- type WhitelistMgr
Constants ¶
const ( TopicACKs = "acks" TopicReset = "reset" TopicDiscReq = "discovery_request" TopicDiscResp = "discovery_response" )
const ( ProtocolIDDiscover = peers.ProtocolIDDiscover ProtocolIDCrawler = peers.ProtocolIDCrawler ProtocolIDTx protocol.ID = "/kwil/tx/1.0.0" ProtocolIDTxAnn protocol.ID = "/kwil/txann/1.0.0" ProtocolIDBlockHeight protocol.ID = "/kwil/blkheight/1.0.0" ProtocolIDBlock protocol.ID = "/kwil/blk/1.0.0" ProtocolIDBlkAnn protocol.ID = "/kwil/blkann/1.0.0" ProtocolIDBlockPropose protocol.ID = "/kwil/blkprop/1.0.0" ProtocolIDSnapshotCatalog protocol.ID = "/kwil/snapcat/1.0.0" ProtocolIDSnapshotChunk protocol.ID = "/kwil/snapchunk/1.0.0" ProtocolIDSnapshotMeta protocol.ID = "/kwil/snapmeta/1.0.0" )
const AppVersion = 1
AppVersion encompasses all aspects of the Kwil DB application. A new version indicates incompatible changes to the application, and nodes with different versions should not communicate (TODO).
Variables ¶
var ( ErrNotFound = errors.New("resource not available") ErrTxNotFound = types.ErrTxNotFound ErrTxAlreadyExists = types.ErrTxAlreadyExists ErrBlkNotFound = types.ErrBlkNotFound ErrNoResponse = types.ErrNoResponse )
var (
ErrNoSnapshotsDiscovered = errors.New("no snapshots discovered")
)
var RequiredStreamProtocols = []protocol.ID{ ProtocolIDDiscover, ProtocolIDTx, ProtocolIDTxAnn, ProtocolIDBlockHeight, ProtocolIDBlock, ProtocolIDBlkAnn, ProtocolIDBlockPropose, pubsub.GossipSubID_v12, ProtocolIDSnapshotCatalog, ProtocolIDSnapshotChunk, ProtocolIDSnapshotMeta, }
Functions ¶
func ExpandPath ¶
TODO: this is WRONG considering paths like ~user. We should rewrite this correctly, for both ~/ and ~user/ and without assuming a platform separator.
func FormatPeerString ¶
Types ¶
type BlockProcessor ¶
type Config ¶
type Config struct {
RootDir string
ChainID string
PrivKey crypto.PrivateKey
DB DB
P2P *config.PeerConfig
DBConfig *config.DBConfig
Statesync *config.StateSyncConfig
Mempool types.MemPool
BlockStore types.BlockStore
Consensus ConsensusEngine
Snapshotter SnapshotStore
BlockProc BlockProcessor
Logger log.Logger
}
Config is the configuration for a Node instance.
type ConsensusEngine ¶
type ConsensusEngine interface {
Status() *types.NodeStatus // includes: role, inCatchup, consensus params, last commit info and block header
Role() types.Role
InCatchup() bool
AcceptProposal(height int64, blkID, prevBlkID types.Hash, leaderSig []byte, timestamp int64) bool
NotifyBlockProposal(blk *ktypes.Block)
AcceptCommit(height int64, blkID types.Hash, ci *types.CommitInfo, leaderSig []byte) bool
NotifyBlockCommit(blk *ktypes.Block, ci *types.CommitInfo)
NotifyACK(validatorPK []byte, ack types.AckRes)
NotifyResetState(height int64, txIDs []types.Hash, senderPubKey []byte)
NotifyDiscoveryMessage(validatorPK []byte, height int64)
Start(ctx context.Context, fns consensus.BroadcastFns, peerFns consensus.WhitelistFns) error
CheckTx(ctx context.Context, tx *ktypes.Transaction) error
BroadcastTx(ctx context.Context, tx *ktypes.Transaction, sync uint8) (*ktypes.ResultBroadcastTx, error)
ConsensusParams() *ktypes.NetworkParameters
CancelBlockExecution(height int64, txIDs []types.Hash) error
}
type ConsensusReset ¶
type ConsensusReset = types.ConsensusReset
type DB ¶
type DB interface {
sql.ReadTxMaker
}
type DiscReq ¶
type DiscReq = types.DiscoveryRequest
type DiscRes ¶
type DiscRes = types.DiscoveryResponse
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func NewNode ¶
NewNode creates a new node. The config struct is for required configuration, and the functional options for optional settings, like dependency overrides.
func (*Node) AbortBlockExecution ¶
func (*Node) BlockByHash ¶
BlockByHash returns the block by block hash.
func (*Node) BlockByHeight ¶
BlockByHeight returns the block by height. If height <= 0, the latest block will be returned.
func (*Node) BlockHeight ¶
func (*Node) BlockResultByHash ¶
BlockResultByHash returns the block result by block hash.
func (*Node) BroadcastTx ¶
func (n *Node) BroadcastTx(ctx context.Context, tx *ktypes.Transaction, sync uint8) (*ktypes.ResultBroadcastTx, error)
func (*Node) ChainUnconfirmedTx ¶
ChainUnconfirmedTx return unconfirmed tx info that is used in Chain rpc.
func (*Node) ConsensusParams ¶
func (n *Node) ConsensusParams() *ktypes.NetworkParameters
func (*Node) MultiAddrs ¶
func (*Node) Start ¶
Start begins tx and block gossip, connects to any bootstrap peers, and begins peer discovery.
func (*Node) Whitelister ¶
func (n *Node) Whitelister() *WhitelistMgr
Whitelister is a shim between the a Kwil consumer like RPC service and the p2p layer (PeerMan) which manages the persistent and effective white list in terms of libp2p types.
type SnapshotStore ¶
type StateSyncService ¶
type StateSyncService struct {
// contains filtered or unexported fields
}
func NewStateSyncService ¶
func NewStateSyncService(ctx context.Context, cfg *statesyncConfig) (*StateSyncService, error)
func (*StateSyncService) Bootstrap ¶
func (s *StateSyncService) Bootstrap(ctx context.Context) error
func (*StateSyncService) DiscoverSnapshots ¶
func (s *StateSyncService) DiscoverSnapshots(ctx context.Context) (int64, error)
DiscoverSnapshots discovers snapshot providers and their catalogs. It waits for responsesp from snapshot catalog providers for the duration of the discoveryTimeout. If the timeout is reached, the best snapshot is selected and snapshot chunks are requested. If no snapshots are discovered, it reenters the discovery phase after a delay, retrying up to maxRetries times. If discovery fails after maxRetries, the node will switch to block sync. If snapshots and their chunks are successfully fetched, the DB is restored from the snapshot and the application state is verified.
func (*StateSyncService) VerifySnapshot ¶
func (ss *StateSyncService) VerifySnapshot(ctx context.Context, snap *snapshotMetadata) (bool, []byte)
verifySnapshot verifies the snapshot with the trusted provider and returns the app hash if the snapshot is valid.
type Streamer ¶
type Streamer struct {
// contains filtered or unexported fields
}
Utility to stream chunks of a snapshot
type WhitelistMgr ¶
type WhitelistMgr struct {
// contains filtered or unexported fields
}
func (*WhitelistMgr) AddPeer ¶
func (wl *WhitelistMgr) AddPeer(nodeID string) error
func (*WhitelistMgr) List ¶
func (wl *WhitelistMgr) List() []string
func (*WhitelistMgr) RemovePeer ¶
func (wl *WhitelistMgr) RemovePeer(nodeID string) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
package adminclient provides a client for the Kwil admin service.
|
package adminclient provides a client for the Kwil admin service. |
|
interpreter
package interpreter provides a basic interpreter for Kuneiform procedures.
|
package interpreter provides a basic interpreter for Kuneiform procedures. |
|
parse
package parse contains logic for parsing SQL, DDL, and Actions, and SQL.
|
package parse contains logic for parsing SQL, DDL, and Actions, and SQL. |
|
pg_generate
pggenerate package is responsible for generating the Postgres-compatible SQL from the AST.
|
pggenerate package is responsible for generating the Postgres-compatible SQL from the AST. |
|
Package meta defines a chain metadata store for the ABCI application.
|
Package meta defines a chain metadata store for the ABCI application. |
|
package migrations implements a long-running migrations protocol for Kwil.
|
package migrations implements a long-running migrations protocol for Kwil. |
|
Package pg defines the primary PostgreSQL-powered DB and Pool types used to support Kwil DB.
|
Package pg defines the primary PostgreSQL-powered DB and Pool types used to support Kwil DB. |
|
services
|
|
|
memstore
Package memstore provides a memory-backed block store, which is only suitable for testing where a disk-based store or third party dependencies are not desired.
|
Package memstore provides a memory-backed block store, which is only suitable for testing where a disk-based store or third party dependencies are not desired. |
|
package tx_router routes transactions to the appropriate module(s)
|
package tx_router routes transactions to the appropriate module(s) |
|
sql
Package sql defines common type required by SQL database implementations and consumers.
|
Package sql defines common type required by SQL database implementations and consumers. |
|
utils
|
|
|
syncmap
Package syncmap provides a map that is safe for concurrent use.
|
Package syncmap provides a map that is safe for concurrent use. |
|
url
package url provides url fuctionalities to provide consistent parsing for Kwil clients.
|
package url provides url fuctionalities to provide consistent parsing for Kwil clients. |
|
package versioning provides standard schema versioning for Kwil databases.
|
package versioning provides standard schema versioning for Kwil databases. |
|
package events is used to track events that need to be included in a Kwil block.
|
package events is used to track events that need to be included in a Kwil block. |