Documentation
¶
Overview ¶
Package db manages persistent state and keeps track of previous and current builds.
Index ¶
- Constants
- func DeleteMeta(key string) error
- func DeleteServer(id int) error
- func DivideNodesByAbsMatch(nodes []Node, nodeNums []int) ([]Node, []Node, error)
- func GetAllServers() (map[string]Server, error)
- func GetHostIPsByTestNet(id int) ([]string, error)
- func GetMeta(key string) (interface{}, error)
- func GetMetaP(key string, v interface{}) error
- func GetUniqueServerIDs(nodes []Node) []int
- func InsertBuild(dd DeploymentDetails, testnetID string) error
- func InsertNode(node Node) (int, error)
- func InsertServer(name string, server Server) (int, error)
- func SetMeta(key string, value interface{}) error
- func UpdateServer(id int, server Server) error
- func UpdateServerNodes(id int, nodes int) error
- type DeploymentDetails
- type Node
- func GetAllNodes() ([]Node, error)
- func GetAllNodesByServer(serverID int) ([]Node, error)
- func GetAllNodesByTestNet(testID string) ([]Node, error)
- func GetNode(id string) (Node, error)
- func GetNodeByAbsNum(nodes []Node, absNum int) (Node, error)
- func GetNodeByLocalID(nodes []Node, localID int) (Node, error)
- type Server
- type SideCar
Constants ¶
const BuildsTable = "builds"
BuildsTable contains name of the builds table
const NodesTable = "nodes"
NodesTable contains name of the nodes table
const ServerTable = "servers"
ServerTable contains name of the server table
const Version = "2.2.4"
Version represents the database version, upon change of this constant, the database will be purged
Variables ¶
This section is empty.
Functions ¶
func DivideNodesByAbsMatch ¶
DivideNodesByAbsMatch spits the given nodes into nodes which have their absnum in the given nodeNums and those who don't
func GetAllServers ¶
GetAllServers gets all of the servers, indexed by name
func GetHostIPsByTestNet ¶
GetHostIPsByTestNet gets the ips of the hosts for a testnet
func GetUniqueServerIDs ¶ added in v1.6.5
GetUniqueServerIDs extracts the unique server ids from a slice of Node
func InsertBuild ¶
func InsertBuild(dd DeploymentDetails, testnetID string) error
InsertBuild inserts a build
func InsertNode ¶
InsertNode inserts a node into the database
func InsertServer ¶
InsertServer inserts a new server into the database
func UpdateServer ¶
UpdateServer updates a server by id
func UpdateServerNodes ¶
UpdateServerNodes update the number of nodes a server has
Types ¶
type DeploymentDetails ¶
type DeploymentDetails struct {
/*
Servers: The ids of the servers to build on
*/
Servers []int `json:"servers"`
/*
Blockchain: The blockchain to build.
*/
Blockchain string `json:"blockchain"`
/*
Nodes: The number of nodes to build
*/
Nodes int `json:"nodes"`
/*
Image: The docker image to build off of
*/
Images []string `json:"images"`
/*
Params: The blockchain specific parameters
*/
Params map[string]interface{} `json:"params"`
/*
Resources: The resources per node
*/
Resources []util.Resources `json:"resources"`
/*
Environments is the environment variables to be passed to each node.
If it doesn't exist for a node, it defaults first to index 0.
*/
Environments []map[string]string `json:"environments"`
/*
Custom files for each node
*/
Files []map[string]string `json:"files"`
/*
Logs to keep track of for each node
*/
Logs []map[string]string `json:"logs"`
/*
Fairly Arbitrary extras for when additional customizations are added.
*/
Extras map[string]interface{} `json:"extras"`
// contains filtered or unexported fields
}
DeploymentDetails represents the data for the construction of a testnet.
func GetAllBuilds ¶
func GetAllBuilds() ([]DeploymentDetails, error)
GetAllBuilds gets all of the builds done by a user
func GetBuildByTestnet ¶
func GetBuildByTestnet(id string) (DeploymentDetails, error)
GetBuildByTestnet gets the build parameters based off testnet id
func GetLastBuildByKid ¶
func GetLastBuildByKid(kid string) (DeploymentDetails, error)
GetLastBuildByKid gets the build parameters based off kid
func QueryBuilds ¶
func QueryBuilds(query string) ([]DeploymentDetails, error)
QueryBuilds fetches DeploymentDetails based on the given SQL select query
func (DeploymentDetails) GetJwt ¶
func (dd DeploymentDetails) GetJwt() string
GetJwt gets the jwt of the creator of this build
func (DeploymentDetails) GetKid ¶
func (dd DeploymentDetails) GetKid() string
GetKid gets the kid of the jwt of the creator of this build
func (*DeploymentDetails) SetJwt ¶
func (dd *DeploymentDetails) SetJwt(jwt string) error
SetJwt stores the callers jwt
type Node ¶
type Node struct {
// ID is the UUID of the node
ID string `json:"id"`
//AbsoluteNum is the number of the node in the testnet
AbsoluteNum int `json:"absNum"`
// TestNetId is the id of the testnet to which the node belongs to
TestNetID string `json:"testnetId"`
// Server is the id of the server on which the node resides
Server int `json:"server"`
// LocalID is the number of the node on the server it resides
LocalID int `json:"localId"`
// IP is the ip address of the node
IP string `json:"ip"`
// Label is the string given to the node by the build process
Label string `json:"label"`
// Image is the docker image used to build this node
Image string `json:"image"`
// Blockchain is the blockchain type of this node
Blockchain string `json:"blockchain"`
}
Node represents a node within the network
func GetAllNodes ¶
GetAllNodes gets every node that has ever existed.
func GetAllNodesByServer ¶
GetAllNodesByServer gets all nodes that have ever existed on a server
func GetAllNodesByTestNet ¶
GetAllNodesByTestNet gets all the nodes which are in the given testnet
func GetNodeByAbsNum ¶
GetNodeByAbsNum finds a node based on its absolute node number
func GetNodeByLocalID ¶ added in v1.6.5
GetNodeByLocalID looks up a node by its localID
func (Node) GetAbsoluteNumber ¶ added in v1.7.1
GetAbsoluteNumber gets the absolute number of the node in the testnet
func (Node) GetNodeName ¶ added in v1.7.1
GetNodeName gets the whiteblock name of this node
func (Node) GetRelativeNumber ¶ added in v1.7.1
GetRelativeNumber gets the local id of the node
func (Node) GetServerID ¶ added in v1.7.1
GetServerID gets the id of the server on which this node resides
func (Node) GetTestNetID ¶ added in v1.7.1
GetTestNetID gets the id of the testnet this node is a part of
type Server ¶
type Server struct {
// Addr is the address of the server which is accessible by genesis
Addr string `json:"addr"`
// Nodes is the number of nodes currently on this server
Nodes int `json:"nodes"`
// Max is the maximum number of nodes that server supports
Max int `json:"max"`
// ID is the ID of the server
ID int `json:"id"`
// SubnetID is the number used in the IP scheme for nodes on this server
SubnetID int `json:"subnetID"`
Ips []string //To be removed
}
Server represents a server on which genesis can build
func GetServers ¶
GetServers gets servers from their ids
type SideCar ¶ added in v1.7.1
type SideCar struct {
ID string `json:"id"`
NodeID string `json:"nodeID"`
AbsoluteNodeNum int `json:"absNum"`
// TestNetID is the id of the testnet to which the node belongs to
TestnetID string `json:"testnetID"`
// Server is the id of the server on which the node resides
Server int `json:"server"`
//LocalID is the number of the node in the testnet
LocalID int `json:"localID"`
NetworkIndex int `json:"networkIndex"`
// IP is the ip address of the node
IP string `json:"ip"`
// Image is the docker image on which the sidecar was built
Image string `json:"image"`
// Type is the type of sidecar
Type string `json:"type"`
}
SideCar represents a supporting node within the network
func (SideCar) GetAbsoluteNumber ¶ added in v1.7.1
GetAbsoluteNumber gets the absolute node number of the corresponding ndoe
func (SideCar) GetNodeName ¶ added in v1.7.1
GetNodeName gets the whiteblock name of this side car
func (SideCar) GetRelativeNumber ¶ added in v1.7.1
GetRelativeNumber gets the local id of the corresponding node
func (SideCar) GetServerID ¶ added in v1.7.1
GetServerID gets the id of the server this side car resides on
func (SideCar) GetTestNetID ¶ added in v1.7.1
GetTestNetID gets the id of the testnet this side car is a part of