Documentation ¶
Index ¶
- Variables
- func CheckpointCaller(handler interface{}, params ...interface{})
- func MilestoneCaller(handler interface{}, params ...interface{})
- func MilestoneMerkleTreeHashFuncWithName(name string) crypto.Hash
- type Bundle
- type CheckpointTipSelectionFunc
- type Coordinator
- func (coo *Coordinator) Bootstrap() error
- func (coo *Coordinator) GetInterval() time.Duration
- func (coo *Coordinator) InitMerkleTree(filePath string, cooAddress trinary.Hash) error
- func (coo *Coordinator) InitState(bootstrap bool, startIndex milestone.Index) error
- func (coo *Coordinator) IssueCheckpoint() error
- func (coo *Coordinator) IssueMilestone() (error, error)
- func (coo *Coordinator) State() *State
- type CoordinatorEvents
- type SendBundleFunc
- type State
Constants ¶
This section is empty.
Variables ¶
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.
func MilestoneMerkleTreeHashFuncWithName ¶ added in v0.5.0
MilestoneMerkleTreeHashFuncWithName maps the passed name to one of the supported crypto.Hash hashing functions. Also verifies that the available function is available or else panics.
Types ¶
type Bundle ¶
type Bundle = []*transaction.Transaction
Bundle represents grouped together transactions forming a transfer.
type CheckpointTipSelectionFunc ¶
CheckpointTipSelectionFunc is a function which performs a tipselection and returns several tips for a checkpoint.
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, powFunc pow.ProofOfWorkFunc, checkpointTipselFunc CheckpointTipSelectionFunc, sendBundleFunc SendBundleFunc, milestoneMerkleHashFunc crypto.Hash) *Coordinator
New creates a new coordinator instance.
func (*Coordinator) Bootstrap ¶ added in v0.5.0
func (coo *Coordinator) Bootstrap() error
Bootstrap creates the first milestone, if the network was not bootstrapped yet. Returns critical errors.
func (*Coordinator) GetInterval ¶
func (coo *Coordinator) GetInterval() time.Duration
GetInterval returns the interval milestones 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) IssueCheckpoint ¶ added in v0.5.0
func (coo *Coordinator) IssueCheckpoint() error
IssueCheckpoint tries to create and send a "checkpoint" to the network. a checkpoint can contain multiple chained transactions to reference big parts of the unconfirmed cone. this is done to keep the confirmation rate as high as possible, even if there is an attack ongoing. new checkpoints always reference the last checkpoint or the last milestone if it is the first checkpoint after a new milestone.
func (*Coordinator) IssueMilestone ¶ added in v0.5.0
func (coo *Coordinator) IssueMilestone() (error, error)
IssueMilestone creates the next milestone. a new checkpoint is created right in front of the milestone to raise confirmation rate. Returns non-critical and critical errors.
func (*Coordinator) State ¶ added in v0.5.0
func (coo *Coordinator) State() *State
State returns the current state of the coordinator.
type CoordinatorEvents ¶ added in v0.5.0
type CoordinatorEvents struct { // Fired when a checkpoint transaction is issued. IssuedCheckpointTransaction *events.Event // Fired when a milestone is issued. IssuedMilestone *events.Event }
CoordinatorEvents are the events issued by the coordinator.
type SendBundleFunc ¶
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 ¶
MarshalBinary returns the binary representation of the coordinator state.
func (*State) UnmarshalBinary ¶
UnmarshalBinary parses the binary encoded representation of the coordinator state.