node

package
v0.0.0-...-81345a1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2017 Mosaic Networks Ltd

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HeartbeatTimeout time.Duration
	TCPTimeout       time.Duration
	CacheSize        int
	Logger           *logrus.Logger
}

func DefaultConfig

func DefaultConfig() *Config

func NewConfig

func NewConfig(heartbeat time.Duration, timeout time.Duration, cacheSize int, logger *logrus.Logger) *Config

func TestConfig

func TestConfig(t *testing.T) *Config

type Core

type Core struct {
	Head string
	Seq  int
	// contains filtered or unexported fields
}

func NewCore

func NewCore(
	id int,
	key *ecdsa.PrivateKey,
	participants map[string]int,
	store hg.Store,
	commitCh chan []hg.Event,
	logger *logrus.Logger) Core

func (*Core) Diff

func (c *Core) Diff(known map[int]int) (head string, events []hg.Event, err error)

returns events that c knowns about that are not in 'known', along with c's head

func (*Core) FromWire

func (c *Core) FromWire(wireEvents []hg.WireEvent) ([]hg.Event, error)

func (*Core) GetConsensusEvents

func (c *Core) GetConsensusEvents() []string

func (*Core) GetConsensusEventsCount

func (c *Core) GetConsensusEventsCount() int

func (*Core) GetConsensusTransactions

func (c *Core) GetConsensusTransactions() ([][]byte, error)

func (*Core) GetConsensusTransactionsCount

func (c *Core) GetConsensusTransactionsCount() int

func (*Core) GetEvent

func (c *Core) GetEvent(hash string) (hg.Event, error)

func (*Core) GetEventTransactions

func (c *Core) GetEventTransactions(hash string) ([][]byte, error)

func (*Core) GetHead

func (c *Core) GetHead() (hg.Event, error)

func (*Core) GetLastCommitedRoundEventsCount

func (c *Core) GetLastCommitedRoundEventsCount() int

func (*Core) GetLastConsensusRoundIndex

func (c *Core) GetLastConsensusRoundIndex() *int

func (*Core) GetUndeterminedEvents

func (c *Core) GetUndeterminedEvents() []string

func (*Core) ID

func (c *Core) ID() int

func (*Core) Init

func (c *Core) Init() error

func (*Core) InsertEvent

func (c *Core) InsertEvent(event hg.Event) error

func (*Core) Known

func (c *Core) Known() map[int]int

func (*Core) PubKey

func (c *Core) PubKey() []byte

func (*Core) RunConsensus

func (c *Core) RunConsensus() error

func (*Core) SignAndInsertSelfEvent

func (c *Core) SignAndInsertSelfEvent(event hg.Event) error

func (*Core) Sync

func (c *Core) Sync(otherHead string, unknown []hg.WireEvent, payload [][]byte) error

func (*Core) ToWire

func (c *Core) ToWire(events []hg.Event) ([]hg.WireEvent, error)

type Node

type Node struct {
	// contains filtered or unexported fields
}

func NewNode

func NewNode(conf *Config, key *ecdsa.PrivateKey, participants []net.Peer, trans net.Transport, proxy proxy.AppProxy) Node

func (*Node) Commit

func (n *Node) Commit(events []hg.Event) error

func (*Node) GetStats

func (n *Node) GetStats() map[string]string

func (*Node) Init

func (n *Node) Init() error

func (*Node) Run

func (n *Node) Run(gossip bool)

func (*Node) RunAsync

func (n *Node) RunAsync(gossip bool)

func (*Node) Shutdown

func (n *Node) Shutdown()

func (*Node) SyncRate

func (n *Node) SyncRate() float64

type PeerSelector

type PeerSelector interface {
	Peers() []net.Peer
	UpdateLast(peer string)
	Next() net.Peer
}

type RandomPeerSelector

type RandomPeerSelector struct {
	// contains filtered or unexported fields
}

func NewRandomPeerSelector

func NewRandomPeerSelector(participants []net.Peer, localAddr string) *RandomPeerSelector

func (*RandomPeerSelector) Next

func (ps *RandomPeerSelector) Next() net.Peer

func (*RandomPeerSelector) Peers

func (ps *RandomPeerSelector) Peers() []net.Peer

func (*RandomPeerSelector) UpdateLast

func (ps *RandomPeerSelector) UpdateLast(peer string)

Jump to

Keyboard shortcuts

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