coordinator

package
v0.4.1-rc3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNetworkBootstrapped is returned when the flag for bootstrap network was given, but a state file already exists.
	ErrNetworkBootstrapped = errors.New("network already bootstrapped")
)

Functions

func CheckpointCaller

func CheckpointCaller(handler interface{}, params ...interface{})

CheckpointCaller is used to signal issued checkpoints.

func MilestoneCaller

func MilestoneCaller(handler interface{}, params ...interface{})

MilestoneCaller is used to signal issued milestones.

Types

type Bundle

type Bundle = []*transaction.Transaction

Bundle represents grouped together transactions forming a transfer.

type Coordinator

type Coordinator struct {

	// events of the coordinator
	Events *coordinatorEvents
	// contains filtered or unexported fields
}

Coordinator is used to issue signed transactions, called "milestones" to secure an IOTA network and prevent double spends.

func New

func New(seed trinary.Hash, securityLvl consts.SecurityLevel, merkleTreeDepth int, minWeightMagnitude int, stateFilePath string, milestoneIntervalSec int, checkpointTransactions int, powFunc pow.ProofOfWorkFunc, tipselFunc tipselection.TipSelectionFunc, sendBundleFunc SendBundleFunc) *Coordinator

New creates a new coordinator instance.

func (*Coordinator) GetInterval

func (coo *Coordinator) GetInterval() time.Duration

GetInterval returns the interval milestones or checkpoints should be issued.

func (*Coordinator) InitMerkleTree

func (coo *Coordinator) InitMerkleTree(filePath string, cooAddress trinary.Hash) error

InitMerkleTree loads the Merkle tree file and checks the coordinator address.

func (*Coordinator) InitState

func (coo *Coordinator) InitState(bootstrap bool, startIndex milestone.Index) error

InitState loads an existing state file or bootstraps the network.

func (*Coordinator) IssueNextCheckpointOrMilestone

func (coo *Coordinator) IssueNextCheckpointOrMilestone() (error, error)

IssueNextCheckpointOrMilestone creates the next checkpoint or milestone. if the network was not bootstrapped yet, it creates the first milestone. Returns non-critical and critical errors.

type SendBundleFunc

type SendBundleFunc = func(b Bundle) error

SendBundleFunc is a function which sends a bundle to the network.

type State

type State struct {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler

	LatestMilestoneIndex milestone.Index
	LatestMilestoneHash  hornet.Hash
	LatestMilestoneTime  int64

	// LatestMilestoneTransactions are the transaction hashes of the latest milestone
	LatestMilestoneTransactions hornet.Hashes
}

State stores the latest state of the coordinator.

func (*State) MarshalBinary

func (cs *State) MarshalBinary() (data []byte, err error)

MarshalBinary returns the binary representation of the coordinator state.

func (*State) UnmarshalBinary

func (cs *State) UnmarshalBinary(data []byte) error

Unmarshal parses the binary encoded representation of the coordinator state.

Jump to

Keyboard shortcuts

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