Documentation ¶
Index ¶
- Constants
- Variables
- type Account
- type AccountStatus
- type Action
- type Attribute
- type AttributeType
- type ChainInfo
- type Column
- type DataType
- type DatasetIdentifier
- type Extension
- type ExtensionConfig
- type ForeignKey
- type ForeignKeyAction
- type ForeignKeyActionDo
- type ForeignKeyActionOn
- type ForeignProcedure
- type HexBytes
- type Index
- type IndexType
- type JoinRequest
- type Modifier
- type NamedType
- type Procedure
- type ProcedureParameter
- type ProcedureReturn
- type Schema
- func (s *Schema) Clean() (err error)
- func (s *Schema) DBID() string
- func (s *Schema) FindAction(name string) (action *Action, found bool)
- func (s *Schema) FindExtensionImport(alias string) (extension *Extension, found bool)
- func (s *Schema) FindForeignProcedure(name string) (procedure *ForeignProcedure, found bool)
- func (s *Schema) FindProcedure(name string) (procedure *Procedure, found bool)
- func (s *Schema) FindTable(name string) (table *Table, found bool)
- type Table
- type UUID
- type UUIDArray
- type Uint256
- type Uint256Array
- type Validator
- type ValidatorRemoveProposal
- type VotableEvent
Constants ¶
const (
// DecimalStr is a fixed point number.
DecimalStr = "decimal"
)
Variables ¶
var ( IntType = &DataType{ Name: intStr, } TextType = &DataType{ Name: textStr, } BoolType = &DataType{ Name: boolStr, } BlobType = &DataType{ Name: blobStr, } UUIDType = &DataType{ Name: uuidStr, } Uint256Type = &DataType{ Name: uint256Str, } // NullType is a special type used internally NullType = &DataType{ Name: nullStr, } // Unknown is a special type used internally // when a type is unknown until runtime. UnknownType = &DataType{ Name: unknownStr, } )
declared DataType constants. We do not have one for fixed because fixed types require metadata.
var ZeroMetadata = [2]uint16{}
Functions ¶
This section is empty.
Types ¶
type AccountStatus ¶
type AccountStatus uint32
const ( AccountStatusLatest AccountStatus = iota AccountStatusPending )
type Action ¶ added in v0.2.0
type Action struct { Name string `json:"name"` Annotations []string `json:"annotations"` Parameters []string `json:"parameters"` Public bool `json:"public"` Modifiers []Modifier `json:"modifiers"` Body string `json:"body"` }
Action is a procedure in a database schema. These are defined by Kuneiform's `action` keyword.
func (*Action) Clean ¶ added in v0.2.0
Clean validates rules about the data in the struct (naming conventions, syntax, etc.).
func (*Action) IsOwnerOnly ¶ added in v0.2.0
IsOwnerOnly returns true if the procedure has an owner modifier.
type Attribute ¶ added in v0.2.0
type Attribute struct { Type AttributeType `json:"type"` Value string `json:"value"` }
Attribute is a column attribute. These are constraints and default values.
type AttributeType ¶ added in v0.2.0
type AttributeType string
AttributeType is a type of attribute (e.g. PRIMARY_KEY, UNIQUE, NOT_NULL, DEFAULT, MIN, MAX, MIN_LENGTH, MAX_LENGTH)
const ( PRIMARY_KEY AttributeType = "PRIMARY_KEY" UNIQUE AttributeType = "UNIQUE" NOT_NULL AttributeType = "NOT_NULL" DEFAULT AttributeType = "DEFAULT" MIN AttributeType = "MIN" MAX AttributeType = "MAX" MIN_LENGTH AttributeType = "MIN_LENGTH" MAX_LENGTH AttributeType = "MAX_LENGTH" // is this kwil custom? )
Attribute Types
func (*AttributeType) Clean ¶ added in v0.2.0
func (a *AttributeType) Clean() error
Clean validates rules about the data in the struct (naming conventions, syntax, etc.).
func (*AttributeType) IsValid ¶ added in v0.2.0
func (a *AttributeType) IsValid() bool
func (AttributeType) String ¶ added in v0.2.0
func (a AttributeType) String() string
type ChainInfo ¶
type ChainInfo struct { ChainID string `json:"chain_id"` BlockHeight uint64 `json:"block_height"` BlockHash string `json:"block_hash"` }
ChainInfo describes the current status of a Kwil blockchain.
type Column ¶ added in v0.2.0
type Column struct { Name string `json:"name"` Type *DataType `json:"type"` Attributes []*Attribute `json:"attributes"` }
Column is a column in a table.
func (*Column) HasAttribute ¶ added in v0.2.0
func (c *Column) HasAttribute(attr AttributeType) bool
HasAttribute returns true if the column has the given attribute.
type DataType ¶ added in v0.2.0
type DataType struct { // Name is the name of the type. Name string `json:"name"` // IsArray is true if the type is an array. IsArray bool `json:"is_array"` // Metadata is the metadata of the type. Metadata [2]uint16 `json:"metadata"` }
DataType is a data type. It includes both built-in types and user-defined types.
func ArrayType ¶ added in v0.2.0
ArrayType creates an array type of the given type. It panics if the type is already an array.
func NewDecimalType ¶ added in v0.2.0
NewDecimalType creates a new fixed point decimal type.
func (*DataType) Equals ¶ added in v0.2.0
Equals returns true if the type is equal to the other type, or if either type is null.
func (*DataType) EqualsStrict ¶ added in v0.2.0
EqualsStrict returns true if the type is equal to the other type. The types must be exactly the same, including metadata.
type DatasetIdentifier ¶
type DatasetIdentifier struct { Name string `json:"name"` Owner HexBytes `json:"owner"` DBID string `json:"dbid"` }
DatasetIdentifier contains the information required to identify a dataset.
type Extension ¶ added in v0.2.0
type Extension struct { // Name is the name of the extension registered in the node Name string `json:"name"` // Initialization is a list of key value pairs that are used to initialize the extension Initialization []*ExtensionConfig `json:"initialization"` // Alias is the alias of the extension, which is how its instance is referred to in the schema Alias string `json:"alias"` }
Extension defines what extensions the schema uses, and how they are initialized.
type ExtensionConfig ¶ added in v0.2.0
ExtensionConfig is a key value pair that represents a configuration value for an extension
type ForeignKey ¶ added in v0.2.0
type ForeignKey struct { // ChildKeys are the columns that are referencing another. // For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "a" is the child key ChildKeys []string `json:"child_keys"` // ParentKeys are the columns that are being referred to. // For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "b" is the parent key ParentKeys []string `json:"parent_keys"` // ParentTable is the table that holds the parent columns. // For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "tbl2" is the parent table ParentTable string `json:"parent_table"` // Action refers to what the foreign key should do when the parent is altered. // This is NOT the same as a database action; // however sqlite's docs refer to these as actions, // so we should be consistent with that. // For example, ON DELETE CASCADE is a foreign key action Actions []*ForeignKeyAction `json:"actions"` }
ForeignKey is a foreign key in a table.
func (*ForeignKey) Clean ¶ added in v0.2.0
func (f *ForeignKey) Clean(currentTable *Table, allTables []*Table) error
Clean runs a set of validations and cleans the foreign key
func (*ForeignKey) Copy ¶ added in v0.2.0
func (f *ForeignKey) Copy() *ForeignKey
Copy returns a copy of the foreign key
type ForeignKeyAction ¶ added in v0.2.0
type ForeignKeyAction struct { // On can be either "UPDATE" or "DELETE" On ForeignKeyActionOn `json:"on"` // Do specifies what a foreign key action should do Do ForeignKeyActionDo `json:"do"` }
ForeignKeyAction is used to specify what should occur if a parent key is updated or deleted
func (*ForeignKeyAction) Clean ¶ added in v0.2.0
func (f *ForeignKeyAction) Clean() error
Clean runs a set of validations and cleans the attributes in ForeignKeyAction
func (*ForeignKeyAction) Copy ¶ added in v0.2.0
func (f *ForeignKeyAction) Copy() *ForeignKeyAction
Copy returns a copy of the foreign key action
type ForeignKeyActionDo ¶ added in v0.2.0
type ForeignKeyActionDo string
ForeignKeyActionDo specifies what should be done when a foreign key action is triggered.
const ( // DO_NO_ACTION does nothing when a parent key is altered DO_NO_ACTION ForeignKeyActionDo = "NO ACTION" // DO_RESTRICT prevents the parent key from being altered DO_RESTRICT ForeignKeyActionDo = "RESTRICT" // DO_SET_NULL sets the child key(s) to NULL DO_SET_NULL ForeignKeyActionDo = "SET NULL" // DO_SET_DEFAULT sets the child key(s) to their default values DO_SET_DEFAULT ForeignKeyActionDo = "SET DEFAULT" // DO_CASCADE updates the child key(s) or deletes the records (depending on the action type) DO_CASCADE ForeignKeyActionDo = "CASCADE" )
ForeignKeyActionDo types
func (*ForeignKeyActionDo) Clean ¶ added in v0.2.0
func (f *ForeignKeyActionDo) Clean() error
Clean checks the validity or the string, and converts it to the correct case
func (*ForeignKeyActionDo) IsValid ¶ added in v0.2.0
func (f *ForeignKeyActionDo) IsValid() bool
IsValid checks if the string is a valid ForeignKeyActionDo
func (ForeignKeyActionDo) String ¶ added in v0.2.0
func (f ForeignKeyActionDo) String() string
String returns the ForeignKeyActionDo as a string
type ForeignKeyActionOn ¶ added in v0.2.0
type ForeignKeyActionOn string
ForeignKeyActionOn specifies when a foreign key action should occur. It can be either "UPDATE" or "DELETE".
const ( // ON_UPDATE is used to specify an action should occur when a parent key is updated ON_UPDATE ForeignKeyActionOn = "UPDATE" // ON_DELETE is used to specify an action should occur when a parent key is deleted ON_DELETE ForeignKeyActionOn = "DELETE" )
ForeignKeyActionOn types
func (*ForeignKeyActionOn) Clean ¶ added in v0.2.0
func (f *ForeignKeyActionOn) Clean() error
Clean checks whether the string is valid, and will convert it to the correct case.
func (*ForeignKeyActionOn) IsValid ¶ added in v0.2.0
func (f *ForeignKeyActionOn) IsValid() bool
IsValid checks whether or not the string is a valid ForeignKeyActionOn
func (ForeignKeyActionOn) String ¶ added in v0.2.0
func (f ForeignKeyActionOn) String() string
String returns the ForeignKeyActionOn as a string
type ForeignProcedure ¶ added in v0.2.0
type ForeignProcedure struct { // Name is the name of the foreign procedure. Name string `json:"name"` // Parameters are the parameters of the foreign procedure. Parameters []*DataType `json:"parameters"` // Returns specifies what the foreign procedure returns. // If it does not return a table, the names of the return // values are not needed, and should be left empty. Returns *ProcedureReturn `json:"return_types"` }
ForeignProcedure is used to define foreign procedures that can be dynamically called by the procedure.
func (*ForeignProcedure) Clean ¶ added in v0.2.0
func (f *ForeignProcedure) Clean() error
type HexBytes ¶
type HexBytes []byte
HexBytes is used to decode hexadecimal text into a byte slice.
func (HexBytes) Format ¶ added in v0.2.0
Format writes either address of 0th element in a slice in base 16 notation, with leading 0x (%p), or casts HexBytes to bytes and writes as hexadecimal string to s.
func (HexBytes) MarshalJSON ¶
MarshalJSON satisfies the json.Marshaler interface.
func (*HexBytes) UnmarshalJSON ¶
UnmarshalText satisfies the json.Unmarshaler interface.
type Index ¶ added in v0.2.0
type Index struct { Name string `json:"name"` Columns []string `json:"columns"` Type IndexType `json:"type"` }
Index is an index on a table.
type IndexType ¶ added in v0.2.0
type IndexType string
IndexType is a type of index (e.g. BTREE, UNIQUE_BTREE, PRIMARY)
const ( // BTREE is the default index type. BTREE IndexType = "BTREE" // UNIQUE_BTREE is a unique BTREE index. UNIQUE_BTREE IndexType = "UNIQUE_BTREE" // PRIMARY is a primary index. // Only one primary index is allowed per table. // A primary index cannot exist on a table that also has a primary key. PRIMARY IndexType = "PRIMARY" )
index types
type JoinRequest ¶
type JoinRequest struct { Candidate []byte `json:"candidate"` // pubkey of the candidate validator Power int64 `json:"power"` // the requested power ExpiresAt int64 `json:"expires_at"` // the block height at which the join request expires Board [][]byte `json:"board"` // slice of pubkeys of all the eligible voting validators Approved []bool `json:"approved"` // slice of bools indicating if the corresponding validator approved }
type Modifier ¶ added in v0.2.0
type Modifier string
Modifier modifies the access to a procedure.
const ( // View means that an action does not modify the database. ModifierView Modifier = "VIEW" // Authenticated requires that the caller is identified. ModifierAuthenticated Modifier = "AUTHENTICATED" // Owner requires that the caller is the owner of the database. ModifierOwner Modifier = "OWNER" )
type NamedType ¶ added in v0.2.0
type NamedType struct { // Name is the name of the column. Name string `json:"name"` // Type is the type of the column. Type *DataType `json:"type"` }
NamedType is a single column in a RETURN TABLE(...) statement in a procedure.
type Procedure ¶ added in v0.2.0
type Procedure struct { // Name is the name of the procedure. // It should always be lower case. Name string `json:"name"` // Parameters are the parameters of the procedure. Parameters []*ProcedureParameter `json:"parameters"` // Public is true if the procedure is public. Public bool `json:"public"` // Modifiers are the modifiers of the procedure. Modifiers []Modifier `json:"modifiers"` // Body is the body of the procedure. Body string `json:"body"` // Returns is the return type of the procedure. Returns *ProcedureReturn `json:"return_types"` // Annotations are the annotations of the procedure. Annotations []string `json:"annotations"` }
func (*Procedure) IsOwnerOnly ¶ added in v0.2.0
IsOwnerOnly returns true if the procedure has an owner modifier.
type ProcedureParameter ¶ added in v0.2.0
type ProcedureParameter struct { // Name is the name of the parameter. // It should always be lower case. Name string `json:"name"` // Type is the type of the parameter. Type *DataType `json:"type"` }
ProcedureParameter is a parameter in a procedure.
func (*ProcedureParameter) Clean ¶ added in v0.2.0
func (c *ProcedureParameter) Clean() error
type ProcedureReturn ¶ added in v0.2.0
ProcedureReturn holds the return type of a procedure. EITHER the Type field is set, OR the Table field is set.
func (*ProcedureReturn) Clean ¶ added in v0.2.0
func (p *ProcedureReturn) Clean() error
func (*ProcedureReturn) Copy ¶ added in v0.2.0
func (p *ProcedureReturn) Copy() *ProcedureReturn
type Schema ¶ added in v0.2.0
type Schema struct { // Name is the name of the schema given by the deployer. Name string `json:"name"` // Owner is the identifier (generally an address in bytes or public key) of the owner of the schema Owner HexBytes `json:"owner"` Extensions []*Extension `json:"extensions"` Tables []*Table `json:"tables"` Actions []*Action `json:"actions"` Procedures []*Procedure `json:"procedures"` ForeignProcedures []*ForeignProcedure `json:"foreign_calls"` }
Schema is a database schema that contains tables, procedures, and extensions.
func (*Schema) Clean ¶ added in v0.2.0
Clean validates rules about the data in the struct (naming conventions, syntax, etc.).
func (*Schema) FindAction ¶ added in v0.2.0
FindAction finds an action based on its name. It returns false if the action is not found.
func (*Schema) FindExtensionImport ¶ added in v0.2.0
FindExtensionImport finds an extension based on its alias. It returns false if the extension is not found.
func (*Schema) FindForeignProcedure ¶ added in v0.2.0
func (s *Schema) FindForeignProcedure(name string) (procedure *ForeignProcedure, found bool)
FindForeignProcedure finds a foreign procedure based on its name. It returns false if the procedure is not found.
func (*Schema) FindProcedure ¶ added in v0.2.0
FindProcedure finds a procedure based on its name. It returns false if the procedure is not found.
type Table ¶ added in v0.2.0
type Table struct { Name string `json:"name"` Columns []*Column `json:"columns"` Indexes []*Index `json:"indexes"` ForeignKeys []*ForeignKey `json:"foreign_keys"` }
Table is a table in a database schema.
func (*Table) Clean ¶ added in v0.2.0
Clean validates rules about the data in the struct (naming conventions, syntax, etc.). It takes a slice of all tables in the schema, which is used to check for foreign key references.
func (*Table) FindColumn ¶ added in v0.2.0
FindColumn finds a column based on its name. It returns false if the column is not found.
func (*Table) GetPrimaryKey ¶ added in v0.2.0
GetPrimaryKey returns the names of the column(s) that make up the primary key. If there is more than one, or no primary key, an error is returned.
type UUID ¶
type UUID [16]byte
UUID is a rfc4122 compliant uuidv5
func NewUUIDV5 ¶
NewUUIDV5 generates a uuidv5 from a byte slice. This is used to deterministically generate uuids.
func NewUUIDV5WithNamespace ¶ added in v0.2.0
NewUUIDV5WithNamespace generates a uuidv5 from a byte slice and a namespace. This is used to deterministically generate uuids.
func (UUID) MarshalJSON ¶ added in v0.2.0
Over json, we want to send uuids as strings
func (*UUID) UnmarshalJSON ¶ added in v0.2.0
type UUIDArray ¶
type UUIDArray []*UUID
UUIDArray is a slice of UUIDs. It is used to store arrays of UUIDs in the database.
type Uint256 ¶ added in v0.2.0
Uint256 is a 256-bit unsigned integer. It is mostly a wrapper around github.com/holiman/uint256.Int, but includes extra methods for usage in Postgres.
func Uint256FromBig ¶ added in v0.2.0
Uint256FromBig creates a new Uint256 from a big.Int.
func Uint256FromBytes ¶ added in v0.2.0
Uint256FromBytes creates a new Uint256 from a byte slice.
func Uint256FromInt ¶ added in v0.2.0
Uint256FromInt creates a new Uint256 from an int.
func Uint256FromString ¶ added in v0.2.0
Uint256FromString creates a new Uint256 from a string.
func (Uint256) MarshalJSON ¶ added in v0.2.0
func (*Uint256) UnmarshalJSON ¶ added in v0.2.0
type Uint256Array ¶ added in v0.2.0
type Uint256Array []*Uint256
Uint256Array is an array of Uint256s.
func (*Uint256Array) Scan ¶ added in v0.2.0
func (ua *Uint256Array) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type ValidatorRemoveProposal ¶
type ValidatorRemoveProposal struct { Target []byte `json:"target"` // pubkey of the validator to remove Remover []byte `json:"remover"` // pubkey of the validator proposing the removal }
ValidatorRemoveProposal is a proposal from an existing validator (remover) to remove a validator (the target) from the validator set.
type VotableEvent ¶
VotableEvent is an event that can be voted. It contains an event type and a body. An ID can be generated from the event type and body.
func (*VotableEvent) ID ¶
func (e *VotableEvent) ID() *UUID
Directories ¶
Path | Synopsis |
---|---|
_numbers
|
|
Package types contains the type used by the administrative RPC client and servers.
|
Package types contains the type used by the administrative RPC client and servers. |
Package client contains the shared client types, including the options used to construct a Client instance, and the records iterator used to represent the results of an action call.
|
Package client contains the shared client types, including the options used to construct a Client instance, and the records iterator used to represent the results of an action call. |
package Decimal implements a fixed-point decimal number.
|
package Decimal implements a fixed-point decimal number. |
Package transactions contains all the logic for creating and validating transactions and call messages.
|
Package transactions contains all the logic for creating and validating transactions and call messages. |