sebak: boscoin.io/sebak/lib/node Index | Files | Directories

package node

import "boscoin.io/sebak/lib/node"

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

Package Files

info.go local_node.go node.go node_state.go queue.go test.go validator.go

func MakeAlias Uses

func MakeAlias(address string) string

type LocalNode Uses

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

func NewLocalNode Uses

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

func NewTestLocalNode Uses

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

Ditto

func NewTestLocalNode0 Uses

func NewTestLocalNode0() *LocalNode

Return a new LocalNode with sensible defaults

func (*LocalNode) AddValidators Uses

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

func (*LocalNode) Address Uses

func (n *LocalNode) Address() string

func (*LocalNode) Alias Uses

func (n *LocalNode) Alias() string

func (*LocalNode) BindEndpoint Uses

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

func (*LocalNode) ClearValidators Uses

func (n *LocalNode) ClearValidators()

func (*LocalNode) ConvertToValidator Uses

func (n *LocalNode) ConvertToValidator() *Validator

func (*LocalNode) Endpoint Uses

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

func (*LocalNode) Equal Uses

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

func (*LocalNode) GetValidators Uses

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

func (*LocalNode) HasValidators Uses

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

func (*LocalNode) Keypair Uses

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

func (*LocalNode) MarshalJSON Uses

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

func (*LocalNode) PublishEndpoint Uses

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

func (*LocalNode) Serialize Uses

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

func (*LocalNode) SetBooting Uses

func (n *LocalNode) SetBooting()

func (*LocalNode) SetConsensus Uses

func (n *LocalNode) SetConsensus()

func (*LocalNode) SetPublishEndpoint Uses

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

func (*LocalNode) SetSync Uses

func (n *LocalNode) SetSync()

func (*LocalNode) SetWatch Uses

func (n *LocalNode) SetWatch()

func (*LocalNode) State Uses

func (n *LocalNode) State() State

func (*LocalNode) String Uses

func (n *LocalNode) String() string

func (*LocalNode) Validator Uses

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

type Node Uses

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

type NodeBlockInfo Uses

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 Uses

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

func NewNodeInfoFromJSON Uses

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

type NodeInfoNode Uses

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 Uses

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 Uses

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

type Queue Uses

type Queue []*Node

func (*Queue) Len Uses

func (q *Queue) Len() int

func (*Queue) Pop Uses

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

func (*Queue) Push Uses

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

type State Uses

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

func (State) MarshalJSON Uses

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

func (State) String Uses

func (s State) String() string

func (*State) UnmarshalJSON Uses

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

type Validator Uses

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

func NewValidator Uses

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

func NewValidatorFromURI Uses

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

func (*Validator) Address Uses

func (v *Validator) Address() string

func (*Validator) Alias Uses

func (v *Validator) Alias() string

func (*Validator) Endpoint Uses

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

func (*Validator) Equal Uses

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

func (*Validator) MarshalJSON Uses

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

func (*Validator) Serialize Uses

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

func (*Validator) SetEndpoint Uses

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

func (*Validator) String Uses

func (v *Validator) String() string

func (*Validator) UnmarshalJSON Uses

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

type ValidatorFromJSON Uses

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

Directories

PathSynopsis
runnerPackage sebak is the node of blockchain, which implements "ISAAC" Consensus Protocol at first time.
runner/api
runner/api/resource
runner/node_api

Package node imports 8 packages (graph) and is imported by 16 packages. Updated 2019-02-14. Refresh now. Tools for package owners.