database

package
v0.0.0-...-c729bb3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2019 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ValidMessageTypes - definitions for valid messsage types
	ValidMessageTypes = []string{"hardfork", "softfork", "update", "upgrade", "notice"}
)

Functions

func JoinDatabase

func JoinDatabase(bootstrapAddress string, databasePort uint, databaseAlias string) error

JoinDatabase - attempt to insert local node data into remote database instance

Types

type Message

type Message struct {
	Message  string `json:"message"`     // Message value
	Priority uint   `json:"priority"`    // Message priority
	Type     string `json:"messagetype"` // Message type
	Network  string `json:"network"`     // Message network
}

Message - string alias for database messages

func MessageFromBytes

func MessageFromBytes(b []byte) (*Message, error)

MessageFromBytes - attempt to decode message from given bytes

func NewMessage

func NewMessage(message string, priority uint, messageType string, networkName string) (*Message, error)

NewMessage - attempt to initialize new message with given parameters

func (*Message) ToBytes

func (message *Message) ToBytes() ([]byte, error)

ToBytes - attempt to serialize given message to bytes

type NodeDatabase

type NodeDatabase struct {
	Nodes *[]node.Node `json:"nodes"` // Nodes - primary list of nodes

	Shards *[]shard.Shard `json:"shards"` // Shards - primary list of shards

	NetworkAlias string `json:"network"`   // NetworkAlias - network 'name', used for identifying a common protocol
	NetworkID    uint   `json:"networkID"` // NetworkID - integer used for identifying common network

	HashedNetworkMessageKey string // HashedNetworkMessageKey - key used for network-wide messages

	AcceptableTimeout uint `json:"db-wide timeout"` // AcceptableTimeout - database-wide definition for operation timeout
}

NodeDatabase - database containing list of node addresses, as well as bootstrap addresses

func FetchRemoteDatabase

func FetchRemoteDatabase(bootstrapAddress string, databasePort uint, databaseAlias string) (*NodeDatabase, error)

FetchRemoteDatabase - attempt to fetch working copy of remote database

func FromBytes

func FromBytes(b []byte) (*NodeDatabase, error)

FromBytes - attempt to convert specified byte array to db

func NewDatabase

func NewDatabase(bootstrapNode *node.Node, networkName string, networkID uint, acceptableTimeout uint, privateNetworkKey string) (NodeDatabase, error)

NewDatabase - attempts creates new instance of the NodeDatabase struct

func ReadDatabaseFromMemory

func ReadDatabaseFromMemory(env *environment.Environment, networkAlias string) (*NodeDatabase, error)

ReadDatabaseFromMemory - read serialized object of specified node database from specified path

func (*NodeDatabase) AddNode

func (db *NodeDatabase) AddNode(destNode *node.Node) error

AddNode - adds node to specified nodedatabase, after checking address of node

func (*NodeDatabase) AddShard

func (db *NodeDatabase) AddShard(destinationShard *shard.Shard) error

AddShard - attempt to append shard to current NodeDatabase

func (*NodeDatabase) LogDatabase

func (db *NodeDatabase) LogDatabase() error

LogDatabase - serialize and print contents of entire database

func (*NodeDatabase) QueryForAddress

func (db *NodeDatabase) QueryForAddress(address string) (uint, error)

QueryForAddress - attempts to search specified node database for specified address, returning index of node

func (*NodeDatabase) QueryForShardAddress

func (db *NodeDatabase) QueryForShardAddress(address string) (uint, error)

QueryForShardAddress - attempts to search specified node database for specified address, returning index of shard

func (*NodeDatabase) RemoveNode

func (db *NodeDatabase) RemoveNode(address string) error

RemoveNode - removes node with specified address from database

func (*NodeDatabase) RemoveShard

func (db *NodeDatabase) RemoveShard(address string) error

RemoveShard - removes shard with specified address from database

func (*NodeDatabase) SendDatabaseMessage

func (db *NodeDatabase) SendDatabaseMessage(message *Message, messageKey string, databasePort uint) error

SendDatabaseMessage - send announcement message to all nodes in network

func (*NodeDatabase) String

func (db *NodeDatabase) String() string

String - convert shard to string

func (*NodeDatabase) UpdateRemoteDatabase

func (db *NodeDatabase) UpdateRemoteDatabase() error

UpdateRemoteDatabase - push database changes to remote network nodes

func (*NodeDatabase) WriteToMemory

func (db *NodeDatabase) WriteToMemory(env *environment.Environment) error

WriteToMemory - create serialized instance of specified NodeDatabase in specified path (string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL