node

package
v0.0.0-...-8aa4d74 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Defines the `LocalNode` type of Node, which is our node

A `LocalNode` is the local node, as opposed to a `Validator` which is the remote nodes this `LocalNode` sees.

There should only be one `LocalNode` per program.

Functions and types usable only from unit tests

Defines the `Validator` type of Node, which is a remote node

A `Validator` is a remote node as seen by the other type of node (`LocalNode`). It provides any information which is node-specific and relevant to us / consensus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeAlias

func MakeAlias(address string) string

Types

type LocalNode

type LocalNode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLocalNode

func NewLocalNode(kp *keypair.Full, bindEndpoint *common.Endpoint, alias string) (*LocalNode, error)

func NewTestLocalNode

func NewTestLocalNode(kp *keypair.Full, endpoint *common.Endpoint) *LocalNode

Ditto

func NewTestLocalNode0

func NewTestLocalNode0() *LocalNode

Return a new LocalNode with sensible defaults

func (*LocalNode) AddValidators

func (n *LocalNode) AddValidators(validators ...*Validator) error

func (*LocalNode) Address

func (n *LocalNode) Address() string

func (*LocalNode) Alias

func (n *LocalNode) Alias() string

func (*LocalNode) BindEndpoint

func (n *LocalNode) BindEndpoint() *common.Endpoint

func (*LocalNode) ClearValidators

func (n *LocalNode) ClearValidators()

func (*LocalNode) ConvertToValidator

func (n *LocalNode) ConvertToValidator() *Validator

func (*LocalNode) Endpoint

func (n *LocalNode) Endpoint() *common.Endpoint

func (*LocalNode) Equal

func (n *LocalNode) Equal(a Node) bool

func (*LocalNode) GetValidators

func (n *LocalNode) GetValidators() map[string]*Validator

func (*LocalNode) HasValidators

func (n *LocalNode) HasValidators(address string) bool

func (*LocalNode) Keypair

func (n *LocalNode) Keypair() *keypair.Full

func (*LocalNode) MarshalJSON

func (n *LocalNode) MarshalJSON() ([]byte, error)

func (*LocalNode) PublishEndpoint

func (n *LocalNode) PublishEndpoint() *common.Endpoint

func (*LocalNode) Serialize

func (n *LocalNode) Serialize() ([]byte, error)

func (*LocalNode) SetBooting

func (n *LocalNode) SetBooting()

func (*LocalNode) SetConsensus

func (n *LocalNode) SetConsensus()

func (*LocalNode) SetPublishEndpoint

func (n *LocalNode) SetPublishEndpoint(endpoint *common.Endpoint)

func (*LocalNode) SetSync

func (n *LocalNode) SetSync()

func (*LocalNode) SetWatch

func (n *LocalNode) SetWatch()

func (*LocalNode) State

func (n *LocalNode) State() State

func (*LocalNode) String

func (n *LocalNode) String() string

func (*LocalNode) Validator

func (n *LocalNode) Validator(address string) *Validator

type Node

type Node interface {
	Address() string
	Alias() string
	Endpoint() *common.Endpoint
	Equal(Node) bool
	Serialize() ([]byte, error)
}

type NodeBlockInfo

type NodeBlockInfo struct {
	Height    uint64 `json:"height"`
	Hash      string `json:"hash"`
	TotalTxs  uint64 `json:"total-txs"`
	TotalOps  uint64 `json:"total-ops"`
	Proposed  string `json:"proposed"`
	Confirmed string `json:"confirmed"`
}

type NodeInfo

type NodeInfo struct {
	Node   NodeInfoNode  `json:"node"`
	Policy NodePolicy    `json:"policy"`
	Block  NodeBlockInfo `json:"block"`
}

func NewNodeInfoFromJSON

func NewNodeInfoFromJSON(b []byte) (nodeInfo NodeInfo, err error)

type NodeInfoNode

type NodeInfoNode struct {
	Version    NodeVersion           `json:"version"`
	Started    string                `json:"started"`
	State      State                 `json:"state"`
	Alias      string                `json:"alias"`
	Address    string                `json:"address"`
	Endpoint   *common.Endpoint      `json:"endpoint"`
	Validators map[string]*Validator `json:"validators"`
}

type NodePolicy

type NodePolicy struct {
	NetworkID                 string        `json:"network-id"`      // network id
	InitialBalance            common.Amount `json:"initial-balance"` // initial balance of genesis account
	BaseReserve               common.Amount `json:"base-reserve"`    // base reserve for one account
	BaseFee                   common.Amount `json:"base-fee"`        // base fee of operation
	BlockTime                 time.Duration `json:"block-time"`      // block creation time
	BlockTimeDelta            time.Duration `json:"block-time-delta"`
	TimeoutINIT               time.Duration `json:"timeout-init"`
	TimeoutSIGN               time.Duration `json:"timeout-sign"`
	TimeoutACCEPT             time.Duration `json:"timeout-accept"`
	TimeoutALLCONFIRM         time.Duration `json:"timeout-allconfirm"`
	RateLimitRuleAPI          string        `json:"rate-limit-api"`
	RateLimitRuleNode         string        `json:"rate-limit-node"`
	TransactionsLimit         int           `json:"transactions-limit"`            // transactions limit in a ballot
	OperationsLimit           int           `json:"operations-limit"`              // operations limit in a transaction
	OperationsInBallotLimit   int           `json:"operations-in-ballot-limit"`    // operations limit in a ballot
	GenesisBlockConfirmedTime string        `json:"genesis-block-confirmed-time"`  // confirmed time of genesis block; see `common.GenesisBlockConfirmedTime`
	InflationRatio            string        `json:"inflation-ratio"`               // inflation ratio; see `common.InflationRatio`
	UnfreezingPeriod          uint64        `json:"unfreezing-period"`             // unfreezing period
	BlockHeightEndOfInflation uint64        `json:"block-height-end-of-inflation"` // block height of inflation end; see `common.BlockHeightEndOfInflation`
}

type NodeVersion

type NodeVersion struct {
	Version   string `json:"version"`
	GitCommit string `json:"git-commit"`
	GitState  string `json:"git-state"`
	BuildDate string `json:"build-date"`
}

type Queue

type Queue []*Node

func (*Queue) Len

func (q *Queue) Len() int

func (*Queue) Pop

func (q *Queue) Pop() (n *Node)

func (*Queue) Push

func (q *Queue) Push(n *Node)

type State

type State uint
const (
	StateBOOTING State = iota
	StateCONSENSUS
	StateSYNC
	StateWATCH
)

func (State) MarshalJSON

func (s State) MarshalJSON() ([]byte, error)

func (State) String

func (s State) String() string

func (*State) UnmarshalJSON

func (s *State) UnmarshalJSON(b []byte) (err error)

type Validator

type Validator struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator(address string, endpoint *common.Endpoint, alias string) (v *Validator, err error)

func NewValidatorFromURI

func NewValidatorFromURI(v string) (validator *Validator, err error)

func (*Validator) Address

func (v *Validator) Address() string

func (*Validator) Alias

func (v *Validator) Alias() string

func (*Validator) Endpoint

func (v *Validator) Endpoint() *common.Endpoint

func (*Validator) Equal

func (v *Validator) Equal(a Node) bool

func (*Validator) MarshalJSON

func (v *Validator) MarshalJSON() ([]byte, error)

func (*Validator) Serialize

func (v *Validator) Serialize() ([]byte, error)

func (*Validator) SetEndpoint

func (v *Validator) SetEndpoint(endpoint *common.Endpoint)

func (*Validator) String

func (v *Validator) String() string

func (*Validator) UnmarshalJSON

func (v *Validator) UnmarshalJSON(b []byte) error

type ValidatorFromJSON

type ValidatorFromJSON struct {
	Alias    string           `json:"alias"`
	Address  string           `json:"address"`
	Endpoint *common.Endpoint `json:"endpoint"`
	State    State            `json:"state"`
}

Directories

Path Synopsis
Package sebak is the node of blockchain, which implements "ISAAC" Consensus Protocol at first time.
Package sebak is the node of blockchain, which implements "ISAAC" Consensus Protocol at first time.
api

Jump to

Keyboard shortcuts

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