state

package
v0.0.0-...-43db901 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeData

type NodeData struct {
	IPAddress     SignedField `json:"ip_address"`
	ContentPort   SignedField `json:"content_port"`
	LastHeartbeat SignedField `json:"last_heartbeat"`
	DiskContent   SignedList  `json:"disk_content"`
}

NodeData is a type that stores infomration about an indiviudal node

type PoolData

type PoolData struct {
	RequiredContent SignedList `json:"required_content"`
}

PoolData is a type that stores information about the pool

type SignedField

type SignedField struct {
	Data          interface{}              `json:"data"`
	SignedMessage *signature.SignedMessage `json:"signed_message"`
}

SignedField is a type that represents a string field that includes the signature that last updated it

type SignedList

type SignedList struct {
	Data          []string                 `json:"data"`
	SignedMessage *signature.SignedMessage `json:"signed_message"`
}

SignedList is a type that represents a list of string fields and includes the signature that last updated it

type State

type State struct {
	PoolData    *PoolData            `json:"pool_data"`
	NodeDataMap map[string]*NodeData `json:"node_data_map"`
	// contains filtered or unexported fields
}

State is a type that represents the network state

func ParseNetworkState

func ParseNetworkState(stateString []byte) (*State, error)

ParseNetworkState takes the network state json string in and returns a state type if it is valid.

func (*State) GetJSON

func (s *State) GetJSON() ([]byte, error)

GetJSON gets the JSON representation of the state including signatures

func (*State) GetNodeField

func (s *State) GetNodeField(address, key string) interface{}

func (*State) GetNodeFields

func (s *State) GetNodeFields(key string) []interface{}

GetNodeFields gets the same field from all nodes

func (*State) GetNodeFieldsMap

func (s *State) GetNodeFieldsMap(key string) map[string]interface{}

GetNodeFieldsMap gets a map of node address to that field

func (*State) GetPoolField

func (s *State) GetPoolField(key string) interface{}

GetPoolField gets the field name from the pool

func (*State) GetSignatureList

func (s *State) GetSignatureList() []*signature.SignedMessage

GetSignatureList returns a list of all of the signed messages used to make the current state

func (*State) UpdateState

func (s *State) UpdateState(sm *signature.SignedMessage) error

UpdateState updates the local state with the signed message information

Jump to

Keyboard shortcuts

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