Documentation ¶
Index ¶
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.
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 ¶
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 ¶
Unmarshal parses the binary encoded representation of the coordinator state.