ledgerstate

package
Version: v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0, BSD-2-Clause Imports: 36 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// UTXOInputType is the type of an Input that references an UTXO Output.
	UTXOInputType InputType = iota

	// MinInputCount defines the minimum amount of Inputs in a Transaction.
	MinInputCount = 1

	// MaxInputCount defines the maximum amount of Inputs in a Transaction.
	MaxInputCount = 127
)
View Source
const (
	// PrefixBranchStorage defines the storage prefix for the Branch object storage.
	PrefixBranchStorage byte = iota

	// PrefixChildBranchStorage defines the storage prefix for the ChildBranch object storage.
	PrefixChildBranchStorage

	// PrefixConflictStorage defines the storage prefix for the Conflict object storage.
	PrefixConflictStorage

	// PrefixConflictMemberStorage defines the storage prefix for the ConflictMember object storage.
	PrefixConflictMemberStorage

	// PrefixTransactionStorage defines the storage prefix for the Transaction object storage.
	PrefixTransactionStorage

	// PrefixTransactionMetadataStorage defines the storage prefix for the TransactionMetadata object storage.
	PrefixTransactionMetadataStorage

	// PrefixOutputStorage defines the storage prefix for the Output object storage.
	PrefixOutputStorage

	// PrefixOutputMetadataStorage defines the storage prefix for the OutputMetadata object storage.
	PrefixOutputMetadataStorage

	// PrefixConsumerStorage defines the storage prefix for the Consumer object storage.
	PrefixConsumerStorage

	// PrefixAddressOutputMappingStorage defines the storage prefix for the AddressOutputMapping object storage.
	PrefixAddressOutputMappingStorage
)
View Source
const (
	// MinOutputCount defines the minimum amount of Outputs in a Transaction.
	MinOutputCount = 1

	// MaxOutputCount defines the maximum amount of Outputs in a Transaction.
	MaxOutputCount = 127

	// MinOutputBalance defines the minimum balance per Output.
	MinOutputBalance = 1

	// MaxOutputBalance defines the maximum balance on an Output (the supply).
	MaxOutputBalance = 2779530283277761
)
View Source
const AddressLength = 33

AddressLength contains the length of an address (type length = 1, digest length = 32).

View Source
const AliasAddressDigestSize = 32

AliasAddressDigestSize defines the length of the alias address digest in bytes.

View Source
const BranchIDLength = 32

BranchIDLength contains the amount of bytes that a marshaled version of the BranchID contains.

View Source
const ColorLength = 32

ColorLength represents the length of a Color (amount of bytes).

View Source
const ConflictIDLength = OutputIDLength

ConflictIDLength contains the amount of bytes that a marshaled version of the ConflictID contains.

View Source
const DustThresholdAliasOutputIOTA = uint64(100)

DustThresholdAliasOutputIOTA is minimum number of iotas enforced for the output to be correct TODO protocol-wide dust threshold configuration

View Source
const MaxOutputPayloadSize = 4 * 1024

MaxOutputPayloadSize size limit on the data payload in the output.

OutputIDLength contains the amount of bytes that a marshaled version of the OutputID contains.

View Source
const TransactionIDLength = 32

TransactionIDLength contains the amount of bytes that a marshaled version of the ID contains.

Variables

View Source
var (
	// UndefinedBranchID is the zero value of a BranchID and represents a branch that has not been set.
	UndefinedBranchID = BranchID{}

	// MasterBranchID is the identifier of the MasterBranch (root of the ConflictBranch DAG).
	MasterBranchID = BranchID{1}

	// LazyBookedConflictsBranchID is the identifier of the Branch that is the root of all lazy booked ConflictBranches.
	LazyBookedConflictsBranchID = BranchID{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254}

	// InvalidBranchID is the identifier of the Branch that contains the invalid Transactions.
	InvalidBranchID = BranchID{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
)
View Source
var (
	// ErrTransactionInvalid is returned if a Transaction or any of its building blocks is considered to be invalid.
	ErrTransactionInvalid = errors.New("transaction invalid")

	// ErrTransactionNotSolid is returned if a Transaction is processed whose Inputs are not known.
	ErrTransactionNotSolid = errors.New("transaction not solid")

	// ErrInvalidStateTransition is returned if there is an invalid state transition in the ledger state.
	ErrInvalidStateTransition = errors.New("invalid state transition")
)

ChildBranchKeyPartition defines the partition of the storage key of the ChildBranch model.

View Source
var ColorIOTA = Color{}

ColorIOTA is the zero value of the Color and represents uncolored tokens.

View Source
var ColorMint = Color{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}

ColorMint represents a placeholder Color that indicates that tokens should be "colored" in their Output.

ConflictMemberKeyPartition defines the partition of the storage key of the ConflictMember model.

ConsumerPartitionKeys defines the "layout" of the key. This enables prefix iterations in the objectstorage.

View Source
var InputTypeNames = [...]string{
	"UTXOInputType",
}

InputTypeNames contains the names of the existing InputTypes.

View Source
var TransactionType payload.Type

TransactionType represents the payload Type of a Transaction.

Functions

func AddressOutputMappingFromObjectStorage

func AddressOutputMappingFromObjectStorage(key []byte, _ []byte) (result objectstorage.StorableObject, err error)

AddressOutputMappingFromObjectStorage is a factory method that creates a new AddressOutputMapping instance from a storage key of the object storage. It is used by the object storage, to create new instances of this entity.

func BranchFromObjectStorage

func BranchFromObjectStorage(_ []byte, data []byte) (branch objectstorage.StorableObject, err error)

BranchFromObjectStorage restores a Branch that was stored in the object storage.

func ChildBranchFromObjectStorage

func ChildBranchFromObjectStorage(key, value []byte) (result objectstorage.StorableObject, err error)

ChildBranchFromObjectStorage is a factory method that creates a new ChildBranch instance from a storage key of the object storage. It is used by the object storage, to create new instances of this entity.

func ConflictFromObjectStorage

func ConflictFromObjectStorage(key []byte, data []byte) (conflict objectstorage.StorableObject, err error)

ConflictFromObjectStorage restores a Conflict object that was stored in the ObjectStorage.

func ConflictMemberFromObjectStorage

func ConflictMemberFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)

ConflictMemberFromObjectStorage is a factory method that creates a new ConflictMember instance from a storage key of the object storage. It is used by the object storage, to create new instances of this entity.

func ConsumerFromObjectStorage

func ConsumerFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)

ConsumerFromObjectStorage is a factory method that creates a new Consumer instance from a storage key of the object storage. It is used by the object storage, to create new instances of this entity.

func IsAboveDustThreshold added in v0.6.0

func IsAboveDustThreshold(m map[Color]uint64) bool

IsAboveDustThreshold internal utility to check if balances pass dust constraint

func IsExactDustMinimum added in v0.6.0

func IsExactDustMinimum(b *ColoredBalances) bool

IsExactDustMinimum checks if colored balances are exactly what is required by dust constraint

func OutputFromObjectStorage

func OutputFromObjectStorage(key []byte, data []byte) (output objectstorage.StorableObject, err error)

OutputFromObjectStorage restores an Output that was stored in the ObjectStorage.

func OutputMetadataFromObjectStorage

func OutputMetadataFromObjectStorage(key []byte, data []byte) (outputMetadata objectstorage.StorableObject, err error)

OutputMetadataFromObjectStorage restores an OutputMetadata object that was stored in the ObjectStorage.

func RegisterBranchIDAlias added in v0.5.7

func RegisterBranchIDAlias(branchID BranchID, alias string)

RegisterBranchIDAlias registers an alias that will modify the String() output of the BranchID to show a human readable string instead of the base58 encoded version of itself.

func SafeAddUint64 added in v0.4.0

func SafeAddUint64(a uint64, b uint64) (result uint64, valid bool)

SafeAddUint64 adds two uint64 values. It returns the result and a valid flag that indicates whether the addition is valid without causing an overflow.

func SafeSubUint64 added in v0.4.0

func SafeSubUint64(a uint64, b uint64) (result uint64, valid bool)

SafeSubUint64 subtracts two uint64 values. It returns the result and a valid flag that indicates whether the subtraction is valid without causing an overflow.

func TransactionBalancesValid added in v0.4.0

func TransactionBalancesValid(inputs Outputs, outputs Outputs) (valid bool)

TransactionBalancesValid is an internal utility function that checks if the sum of the balance changes equals to 0.

func TransactionFromObjectStorage

func TransactionFromObjectStorage(key []byte, data []byte) (transaction objectstorage.StorableObject, err error)

TransactionFromObjectStorage restores a Transaction that was stored in the ObjectStorage.

func TransactionMetadataFromObjectStorage

func TransactionMetadataFromObjectStorage(key []byte, data []byte) (transactionMetadata objectstorage.StorableObject, err error)

TransactionMetadataFromObjectStorage restores TransactionMetadata that were stored in the ObjectStorage.

func UnlockBlocksValid added in v0.4.0

func UnlockBlocksValid(inputs Outputs, transaction *Transaction) (valid bool)

UnlockBlocksValid is an internal utility function that checks if the UnlockBlocks are matching the referenced Inputs.

func UnlockBlocksValidWithError added in v0.6.0

func UnlockBlocksValidWithError(inputs Outputs, transaction *Transaction) (bool, error)

UnlockBlocksValidWithError is an internal utility function that checks if the UnlockBlocks are matching the referenced Inputs. In case an unlockblock is invalid, it returns the error that caused it.

func UnregisterBranchIDAliases added in v0.5.7

func UnregisterBranchIDAliases()

UnregisterBranchIDAliases removes all aliases registered through the RegisterBranchIDAlias function.

Types

type AccessMana added in v0.6.2

type AccessMana struct {
	Value     float64
	Timestamp time.Time
}

AccessMana defines the info for the aMana snapshot.

type Address

type Address interface {
	// Type returns the AddressType of the Address.
	Type() AddressType

	// Digest returns the hashed version of the Addresses public key.
	Digest() []byte

	// Clone creates a copy of the Address.
	Clone() Address

	// Equals returns true if the two Addresses are equal.
	Equals(other Address) bool

	// Bytes returns a marshaled version of the Address.
	Bytes() []byte

	// Array returns an array of bytes that contains the marshaled version of the Address.
	Array() [AddressLength]byte

	// Base58 returns a base58 encoded version of the Address.
	Base58() string

	// String returns a human readable version of the Address for debug purposes.
	String() string
}

Address is an interface for the different kind of Addresses that are supported by the ledger state.

func AddressFromBase58EncodedString

func AddressFromBase58EncodedString(base58String string) (address Address, err error)

AddressFromBase58EncodedString creates an Address from a base58 encoded string.

func AddressFromBytes

func AddressFromBytes(bytes []byte) (address Address, consumedBytes int, err error)

AddressFromBytes unmarshals an Address from a sequence of bytes.

func AddressFromMarshalUtil

func AddressFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (address Address, err error)

AddressFromMarshalUtil reads an Address from the bytes in the given MarshalUtil.

func AddressFromSignature added in v0.6.0

func AddressFromSignature(sig Signature) (Address, error)

AddressFromSignature returns address corresponding to the signature if it has one (for ed25519 and BLS).

type AddressOutputMapping

type AddressOutputMapping struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

AddressOutputMapping represents a mapping between Addresses and their corresponding Outputs. Since an Address can have a potentially unbounded amount of Outputs, we store this as a separate k/v pair instead of a marshaled list of spending Transactions inside the Output.

func AddressOutputMappingFromBytes

func AddressOutputMappingFromBytes(bytes []byte) (addressOutputMapping *AddressOutputMapping, consumedBytes int, err error)

AddressOutputMappingFromBytes unmarshals a AddressOutputMapping from a sequence of bytes.

func AddressOutputMappingFromMarshalUtil

func AddressOutputMappingFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (addressOutputMapping *AddressOutputMapping, err error)

AddressOutputMappingFromMarshalUtil unmarshals an AddressOutputMapping using a MarshalUtil (for easier unmarshaling).

func NewAddressOutputMapping added in v0.4.0

func NewAddressOutputMapping(address Address, outputID OutputID) *AddressOutputMapping

NewAddressOutputMapping returns a new AddressOutputMapping.

func (*AddressOutputMapping) Address

func (a *AddressOutputMapping) Address() Address

Address returns the Address of the AddressOutputMapping.

func (*AddressOutputMapping) Bytes

func (a *AddressOutputMapping) Bytes() []byte

Bytes marshals the Consumer into a sequence of bytes.

func (*AddressOutputMapping) ObjectStorageKey

func (a *AddressOutputMapping) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*AddressOutputMapping) ObjectStorageValue

func (a *AddressOutputMapping) ObjectStorageValue() (value []byte)

ObjectStorageValue marshals the Consumer into a sequence of bytes that are used as the value part in the object storage.

func (*AddressOutputMapping) OutputID

func (a *AddressOutputMapping) OutputID() OutputID

OutputID returns the OutputID of the AddressOutputMapping.

func (*AddressOutputMapping) String

func (a *AddressOutputMapping) String() (humanReadableConsumer string)

String returns a human readable version of the Consumer.

func (*AddressOutputMapping) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type AddressType

type AddressType byte

AddressType represents the type of the Address (different types encode different signature schemes).

const (
	// ED25519AddressType represents an Address secured by the ED25519 signature scheme.
	ED25519AddressType AddressType = iota

	// BLSAddressType represents an Address secured by the BLS signature scheme.
	BLSAddressType

	// AliasAddressType represents ID used in AliasOutput and AliasLockOutput
	AliasAddressType
)

func (AddressType) String

func (a AddressType) String() string

String returns a human readable representation of the AddressType.

type AggregatedBranch

type AggregatedBranch struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

AggregatedBranch represents a container for Transactions and Outputs representing a certain perception of the ledger state.

func AggregatedBranchFromBytes

func AggregatedBranchFromBytes(bytes []byte) (aggregatedBranch *AggregatedBranch, consumedBytes int, err error)

AggregatedBranchFromBytes unmarshals an AggregatedBranch from a sequence of bytes.

func AggregatedBranchFromMarshalUtil

func AggregatedBranchFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (aggregatedBranch *AggregatedBranch, err error)

AggregatedBranchFromMarshalUtil unmarshals an AggregatedBranch using a MarshalUtil (for easier unmarshaling).

func NewAggregatedBranch

func NewAggregatedBranch(parents BranchIDs) *AggregatedBranch

NewAggregatedBranch creates a new AggregatedBranch from the given details.

func (*AggregatedBranch) Bytes

func (a *AggregatedBranch) Bytes() []byte

Bytes returns a marshaled version of the Branch.

func (*AggregatedBranch) Finalized

func (a *AggregatedBranch) Finalized() bool

Finalized returns true if the decision whether it is liked has been finalized.

func (*AggregatedBranch) ID

func (a *AggregatedBranch) ID() BranchID

ID returns the identifier of the Branch.

func (*AggregatedBranch) InclusionState

func (a *AggregatedBranch) InclusionState() (inclusionState InclusionState)

InclusionState returns the InclusionState of the Branch which encodes if the Branch has been included in the ledger state.

func (*AggregatedBranch) Liked

func (a *AggregatedBranch) Liked() bool

Liked returns true if the branch is "liked within it's scope" (ignoring monotonicity).

func (*AggregatedBranch) MonotonicallyLiked

func (a *AggregatedBranch) MonotonicallyLiked() bool

MonotonicallyLiked returns true if the branch is monotonically liked (all parents are also liked).

func (*AggregatedBranch) ObjectStorageKey

func (a *AggregatedBranch) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*AggregatedBranch) ObjectStorageValue

func (a *AggregatedBranch) ObjectStorageValue() []byte

ObjectStorageValue marshals the AggregatedBranch into a sequence of bytes that are used as the value part in the object storage.

func (*AggregatedBranch) Parents

func (a *AggregatedBranch) Parents() BranchIDs

Parents returns the BranchIDs of the Branches parents in the BranchDAG.

func (*AggregatedBranch) String

func (a *AggregatedBranch) String() string

String returns a human readable version of the Branch.

func (*AggregatedBranch) Type

func (a *AggregatedBranch) Type() BranchType

Type returns the type of the Branch.

func (*AggregatedBranch) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type AliasAddress added in v0.6.0

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

AliasAddress represents a special type of Address which is not backed by a private key directly, but is indirectly backed by a private key defined by corresponding AliasOutput parameters

func AliasAddressFromBase58EncodedString added in v0.6.0

func AliasAddressFromBase58EncodedString(base58String string) (address *AliasAddress, err error)

AliasAddressFromBase58EncodedString creates an AliasAddress from a base58 encoded string.

func AliasAddressFromBytes added in v0.6.0

func AliasAddressFromBytes(data []byte) (address *AliasAddress, consumedBytes int, err error)

AliasAddressFromBytes unmarshals an AliasAddress from a sequence of bytes.

func AliasAddressFromMarshalUtil added in v0.6.0

func AliasAddressFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (address *AliasAddress, err error)

AliasAddressFromMarshalUtil parses a AliasAddress from the given MarshalUtil.

func NewAliasAddress added in v0.6.0

func NewAliasAddress(data []byte) *AliasAddress

NewAliasAddress creates a new AliasAddress from the given bytes used as seed. Normally the seed is an OutputID.

func (*AliasAddress) Array added in v0.6.0

func (a *AliasAddress) Array() (array [AddressLength]byte)

Array returns an array of bytes that contains the marshaled version of the Address.

func (*AliasAddress) Base58 added in v0.6.0

func (a *AliasAddress) Base58() string

Base58 returns a base58 encoded version of the Address.

func (*AliasAddress) Bytes added in v0.6.0

func (a *AliasAddress) Bytes() []byte

Bytes returns a marshaled version of the Address.

func (*AliasAddress) Clone added in v0.6.0

func (a *AliasAddress) Clone() Address

Clone creates a copy of the Address.

func (*AliasAddress) Digest added in v0.6.0

func (a *AliasAddress) Digest() []byte

Digest returns the hashed version of the Addresses public key.

func (*AliasAddress) Equals added in v0.6.0

func (a *AliasAddress) Equals(other Address) bool

Equals returns true if the two Addresses are equal.

func (*AliasAddress) IsNil added in v0.6.0

func (a *AliasAddress) IsNil() bool

IsNil returns if the alias address is zero value (uninitialized).

func (*AliasAddress) String added in v0.6.0

func (a *AliasAddress) String() string

String returns a human readable version of the addresses for debug purposes.

func (*AliasAddress) Type added in v0.6.0

func (a *AliasAddress) Type() AddressType

Type returns the AddressType of the Address.

type AliasOutput added in v0.6.0

type AliasOutput struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

AliasOutput represents output which defines as AliasAddress. It can only be used in a chained manner

func AliasOutputFromMarshalUtil added in v0.6.0

func AliasOutputFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (*AliasOutput, error)

AliasOutputFromMarshalUtil unmarshals a AliasOutput using a MarshalUtil (for easier unmarshaling).

func NewAliasOutputMint added in v0.6.0

func NewAliasOutputMint(balances map[Color]uint64, stateAddr Address, immutableData ...[]byte) (*AliasOutput, error)

NewAliasOutputMint creates new AliasOutput as minting output, i.e. the one which does not contain corresponding input.

func (*AliasOutput) Address added in v0.6.0

func (a *AliasOutput) Address() Address

Address AliasOutput is searchable in the ledger through its AliasAddress

func (*AliasOutput) Balances added in v0.6.0

func (a *AliasOutput) Balances() *ColoredBalances

Balances return colored balances of the output

func (*AliasOutput) Bytes added in v0.6.0

func (a *AliasOutput) Bytes() []byte

Bytes serialized form

func (*AliasOutput) Clone added in v0.6.0

func (a *AliasOutput) Clone() Output

Clone clones the structure

func (*AliasOutput) Compare added in v0.6.0

func (a *AliasOutput) Compare(other Output) int

Compare the two outputs

func (*AliasOutput) DelegationTimeLockedNow added in v0.6.0

func (a *AliasOutput) DelegationTimeLockedNow(nowis time.Time) bool

DelegationTimeLockedNow determines if the alias output is delegation timelocked at a given time.

func (*AliasOutput) DelegationTimelock added in v0.6.0

func (a *AliasOutput) DelegationTimelock() time.Time

DelegationTimelock returns the delegation timelock. If the output is not delegated, or delegation timelock is not set, it returns the zero time object.

func (*AliasOutput) GetAliasAddress added in v0.6.0

func (a *AliasOutput) GetAliasAddress() *AliasAddress

GetAliasAddress calculates new ID if it is a minting output. Otherwise it takes stored value

func (*AliasOutput) GetGovernanceMetadata added in v0.6.0

func (a *AliasOutput) GetGovernanceMetadata() []byte

GetGovernanceMetadata gets the governance metadata

func (*AliasOutput) GetGoverningAddress added in v0.6.0

func (a *AliasOutput) GetGoverningAddress() Address

GetGoverningAddress return governing address. If self-governed, it is the same as state controlling address

func (*AliasOutput) GetImmutableData added in v0.6.0

func (a *AliasOutput) GetImmutableData() []byte

GetImmutableData gets the state data

func (*AliasOutput) GetIsGovernanceUpdated added in v0.6.0

func (a *AliasOutput) GetIsGovernanceUpdated() bool

GetIsGovernanceUpdated returns if the output was unlocked for governance in the transaction.

func (*AliasOutput) GetStateAddress added in v0.6.0

func (a *AliasOutput) GetStateAddress() Address

GetStateAddress return state controlling address

func (*AliasOutput) GetStateData added in v0.6.0

func (a *AliasOutput) GetStateData() []byte

GetStateData gets the state data

func (*AliasOutput) GetStateIndex added in v0.6.0

func (a *AliasOutput) GetStateIndex() uint32

GetStateIndex returns the state index

func (*AliasOutput) ID added in v0.6.0

func (a *AliasOutput) ID() OutputID

ID is the ID of the output

func (*AliasOutput) Input added in v0.6.0

func (a *AliasOutput) Input() Input

Input makes input from the output

func (*AliasOutput) IsDelegated added in v0.6.0

func (a *AliasOutput) IsDelegated() bool

IsDelegated returns true if the output is delegated.

func (*AliasOutput) IsOrigin added in v0.6.0

func (a *AliasOutput) IsOrigin() bool

IsOrigin returns true if it starts the chain

func (*AliasOutput) IsSelfGoverned added in v0.6.0

func (a *AliasOutput) IsSelfGoverned() bool

IsSelfGoverned returns if governing address is not set which means that stateAddress is same as governingAddress

func (*AliasOutput) NewAliasOutputNext added in v0.6.0

func (a *AliasOutput) NewAliasOutputNext(governanceUpdate ...bool) *AliasOutput

NewAliasOutputNext creates new AliasOutput as state transition from the previous one

func (*AliasOutput) ObjectStorageKey added in v0.6.0

func (a *AliasOutput) ObjectStorageKey() []byte

ObjectStorageKey a key

func (*AliasOutput) ObjectStorageValue added in v0.6.0

func (a *AliasOutput) ObjectStorageValue() []byte

ObjectStorageValue binary form

func (*AliasOutput) SetAliasAddress added in v0.6.0

func (a *AliasOutput) SetAliasAddress(addr *AliasAddress)

SetAliasAddress sets the alias address of the alias output.

func (*AliasOutput) SetBalances added in v0.6.0

func (a *AliasOutput) SetBalances(balances map[Color]uint64) error

SetBalances sets colored balances of the output

func (*AliasOutput) SetDelegationTimelock added in v0.6.0

func (a *AliasOutput) SetDelegationTimelock(timelock time.Time) error

SetDelegationTimelock sets the delegation timelock. An error is returned if the output is not a delegated.

func (*AliasOutput) SetGovernanceMetadata added in v0.6.0

func (a *AliasOutput) SetGovernanceMetadata(data []byte) error

SetGovernanceMetadata sets governance metadata

func (*AliasOutput) SetGoverningAddress added in v0.6.0

func (a *AliasOutput) SetGoverningAddress(addr Address)

SetGoverningAddress sets the governing address or nil for self-governing

func (*AliasOutput) SetID added in v0.6.0

func (a *AliasOutput) SetID(outputID OutputID) Output

SetID set the output ID after unmarshalling

func (*AliasOutput) SetImmutableData added in v0.6.0

func (a *AliasOutput) SetImmutableData(data []byte) error

SetImmutableData sets the immutable data field of the alias output.

func (*AliasOutput) SetIsDelegated added in v0.6.0

func (a *AliasOutput) SetIsDelegated(isDelegated bool)

SetIsDelegated sets the isDelegated field of the output.

func (*AliasOutput) SetIsGovernanceUpdated added in v0.6.0

func (a *AliasOutput) SetIsGovernanceUpdated(i bool)

SetIsGovernanceUpdated sets the isGovernanceUpdated flag.

func (*AliasOutput) SetIsOrigin added in v0.6.0

func (a *AliasOutput) SetIsOrigin(isOrigin bool)

SetIsOrigin sets the isOrigin field of the output.

func (*AliasOutput) SetStateAddress added in v0.6.0

func (a *AliasOutput) SetStateAddress(addr Address) error

SetStateAddress sets the state controlling address

func (*AliasOutput) SetStateData added in v0.6.0

func (a *AliasOutput) SetStateData(data []byte) error

SetStateData sets state data

func (*AliasOutput) SetStateIndex added in v0.6.0

func (a *AliasOutput) SetStateIndex(index uint32)

SetStateIndex sets the state index in the input. It is enforced to increment by 1 with each state transition

func (*AliasOutput) String added in v0.6.0

func (a *AliasOutput) String() string

String human readable form

func (*AliasOutput) Type added in v0.6.0

func (a *AliasOutput) Type() OutputType

Type return the type of the output

func (*AliasOutput) UnlockValid added in v0.6.0

func (a *AliasOutput) UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (bool, error)

UnlockValid check unlock and validates chain

func (*AliasOutput) Update added in v0.6.0

func (a *AliasOutput) Update(other objectstorage.StorableObject)

Update is disabled

func (*AliasOutput) UpdateMintingColor added in v0.6.0

func (a *AliasOutput) UpdateMintingColor() Output

UpdateMintingColor replaces minting code with computed color code, and calculates the alias address if it is a freshly minted alias output

func (*AliasOutput) WithDelegation added in v0.6.0

func (a *AliasOutput) WithDelegation() *AliasOutput

WithDelegation returns the output as a delegateds alias output.

func (*AliasOutput) WithDelegationAndTimelock added in v0.6.0

func (a *AliasOutput) WithDelegationAndTimelock(lockUntil time.Time) *AliasOutput

WithDelegationAndTimelock returns the output as a delegated alias output and a set delegation timelock.

type AliasUnlockBlock added in v0.6.0

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

AliasUnlockBlock defines an UnlockBlock which contains an index of corresponding AliasOutput

func AliasUnlockBlockFromBytes added in v0.6.0

func AliasUnlockBlockFromBytes(bytes []byte) (unlockBlock *AliasUnlockBlock, consumedBytes int, err error)

AliasUnlockBlockFromBytes unmarshals a AliasUnlockBlock from a sequence of bytes.

func AliasUnlockBlockFromMarshalUtil added in v0.6.0

func AliasUnlockBlockFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (unlockBlock *AliasUnlockBlock, err error)

AliasUnlockBlockFromMarshalUtil unmarshals a AliasUnlockBlock using a MarshalUtil (for easier unmarshaling).

func NewAliasUnlockBlock added in v0.6.0

func NewAliasUnlockBlock(chainInputIndex uint16) *AliasUnlockBlock

NewAliasUnlockBlock is the constructor for AliasUnlockBlocks.

func (*AliasUnlockBlock) AliasInputIndex added in v0.6.0

func (r *AliasUnlockBlock) AliasInputIndex() uint16

AliasInputIndex returns the index of the input, the AliasOutput which contains AliasAddress

func (*AliasUnlockBlock) Bytes added in v0.6.0

func (r *AliasUnlockBlock) Bytes() []byte

Bytes returns a marshaled version of the UnlockBlock.

func (*AliasUnlockBlock) String added in v0.6.0

func (r *AliasUnlockBlock) String() string

String returns a human readable version of the UnlockBlock.

func (*AliasUnlockBlock) Type added in v0.6.0

Type returns the UnlockBlockType of the UnlockBlock.

type BLSAddress

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

BLSAddress represents an Address that is secured by the BLS signature scheme.

func BLSAddressFromBase58EncodedString

func BLSAddressFromBase58EncodedString(base58String string) (address *BLSAddress, err error)

BLSAddressFromBase58EncodedString creates an BLSAddress from a base58 encoded string.

func BLSAddressFromBytes

func BLSAddressFromBytes(bytes []byte) (address *BLSAddress, consumedBytes int, err error)

BLSAddressFromBytes unmarshals an BLSAddress from a sequence of bytes.

func BLSAddressFromMarshalUtil

func BLSAddressFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (address *BLSAddress, err error)

BLSAddressFromMarshalUtil parses a BLSAddress from the given MarshalUtil.

func NewBLSAddress

func NewBLSAddress(publicKey []byte) *BLSAddress

NewBLSAddress creates a new BLSAddress from the given public key.

func (*BLSAddress) Array added in v0.4.0

func (b *BLSAddress) Array() (array [AddressLength]byte)

Array returns an array of bytes that contains the marshaled version of the Address.

func (*BLSAddress) Base58

func (b *BLSAddress) Base58() string

Base58 returns a base58 encoded version of the Address.

func (*BLSAddress) Bytes

func (b *BLSAddress) Bytes() []byte

Bytes returns a marshaled version of the Address.

func (*BLSAddress) Clone

func (b *BLSAddress) Clone() Address

Clone creates a copy of the Address.

func (*BLSAddress) Digest

func (b *BLSAddress) Digest() []byte

Digest returns the hashed version of the Addresses public key.

func (*BLSAddress) Equals added in v0.6.0

func (b *BLSAddress) Equals(other Address) bool

Equals returns true if the two Addresses are equal.

func (*BLSAddress) String

func (b *BLSAddress) String() string

String returns a human readable version of the addresses for debug purposes.

func (*BLSAddress) Type

func (b *BLSAddress) Type() AddressType

Type returns the AddressType of the Address.

type BLSSignature

type BLSSignature struct {
	Signature bls.SignatureWithPublicKey
}

BLSSignature represents a Signature created with the BLS signature scheme.

func BLSSignatureFromBase58EncodedString

func BLSSignatureFromBase58EncodedString(base58String string) (signature *BLSSignature, err error)

BLSSignatureFromBase58EncodedString creates a BLSSignature from a base58 encoded string.

func BLSSignatureFromBytes

func BLSSignatureFromBytes(bytes []byte) (signature *BLSSignature, consumedBytes int, err error)

BLSSignatureFromBytes unmarshals a BLSSignature from a sequence of bytes.

func BLSSignatureFromMarshalUtil

func BLSSignatureFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (signature *BLSSignature, err error)

BLSSignatureFromMarshalUtil unmarshals a BLSSignature using a MarshalUtil (for easier unmarshaling).

func NewBLSSignature

func NewBLSSignature(signature bls.SignatureWithPublicKey) *BLSSignature

NewBLSSignature is the constructor of a BLSSignature.

func (*BLSSignature) AddressSignatureValid

func (b *BLSSignature) AddressSignatureValid(address Address, data []byte) bool

AddressSignatureValid returns true if the Signature signs the given Address.

func (*BLSSignature) Base58

func (b *BLSSignature) Base58() string

Base58 returns a base58 encoded version of the Signature.

func (*BLSSignature) Bytes

func (b *BLSSignature) Bytes() []byte

Bytes returns a marshaled version of the Signature.

func (*BLSSignature) SignatureValid

func (b *BLSSignature) SignatureValid(data []byte) bool

SignatureValid returns true if the Signature signs the given data.

func (*BLSSignature) String

func (b *BLSSignature) String() string

String returns a human readable version of the Signature.

func (*BLSSignature) Type

func (b *BLSSignature) Type() SignatureType

Type returns the SignatureType of this Signature.

type Branch

type Branch interface {
	// ID returns the identifier of the Branch.
	ID() BranchID

	// Type returns the type of the Branch.
	Type() BranchType

	// Parents returns the BranchIDs of the Branches parents in the BranchDAG.
	Parents() BranchIDs

	// Liked returns true if the branch is "liked within it's scope" (ignoring monotonicity).
	Liked() bool

	// MonotonicallyLiked returns true if the branch is monotonically liked (all parents are also liked).
	MonotonicallyLiked() bool

	// Finalized returns true if the decision whether it is liked has been finalized.
	Finalized() bool

	// InclusionState returns the InclusionState of the Branch which encodes if the Branch has been included in the
	// ledger state.
	InclusionState() InclusionState

	// Bytes returns a marshaled version of the Branch.
	Bytes() []byte

	// String returns a human readable version of the Branch.
	String() string

	// StorableObject enables the Branch to be stored in the object storage.
	objectstorage.StorableObject
	// contains filtered or unexported methods
}

Branch is an interface for a container for Transactions and Outputs representing a certain perception of the ledger state.

func BranchFromBytes

func BranchFromBytes(bytes []byte) (branch Branch, consumedBytes int, err error)

BranchFromBytes unmarshals a Branch from a sequence of bytes.

func BranchFromMarshalUtil

func BranchFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (branch Branch, err error)

BranchFromMarshalUtil unmarshals a Branch using a MarshalUtil (for easier unmarshaling).

type BranchDAG

type BranchDAG struct {
	// Events is a container for all of the BranchDAG related events.
	Events *BranchDAGEvents
	// contains filtered or unexported fields
}

BranchDAG represents the DAG of Branches which contains the business logic to manage the creation and maintenance of the Branches which represents containers for the different perceptions of the ledger state that exist in the tangle.

func NewBranchDAG

func NewBranchDAG(store kvstore.KVStore, cacheProvider *database.CacheTimeProvider) (newBranchDAG *BranchDAG)

NewBranchDAG returns a new BranchDAG instance that stores its state in the given KVStore.

func (*BranchDAG) AggregateBranches

func (b *BranchDAG) AggregateBranches(branchIDS BranchIDs) (cachedAggregatedBranch *CachedBranch, newBranchCreated bool, err error)

AggregateBranches retrieves the AggregatedBranch that corresponds to the given BranchIDs. It automatically creates the AggregatedBranch if it didn't exist, yet.

func (*BranchDAG) Branch

func (b *BranchDAG) Branch(branchID BranchID) (cachedBranch *CachedBranch)

Branch retrieves the Branch with the given BranchID from the object storage.

func (*BranchDAG) BranchIDsContainRejectedBranch

func (b *BranchDAG) BranchIDsContainRejectedBranch(branchIDs BranchIDs) (rejected bool, rejectedBranchID BranchID)

BranchIDsContainRejectedBranch is an utility function that checks if the given BranchIDs contain a Rejected Branch. It returns the BranchID of the first Rejected Branch that it finds.

func (*BranchDAG) ChildBranches

func (b *BranchDAG) ChildBranches(branchID BranchID) (cachedChildBranches CachedChildBranches)

ChildBranches loads the references to the ChildBranches of the given Branch from the object storage.

func (*BranchDAG) Conflict

func (b *BranchDAG) Conflict(conflictID ConflictID) *CachedConflict

Conflict loads a Conflict from the object storage.

func (*BranchDAG) ConflictMembers

func (b *BranchDAG) ConflictMembers(conflictID ConflictID) (cachedConflictMembers CachedConflictMembers)

ConflictMembers loads the referenced ConflictMembers of a Conflict from the object storage.

func (*BranchDAG) CreateConflictBranch

func (b *BranchDAG) CreateConflictBranch(branchID BranchID, parentBranchIDs BranchIDs, conflictIDs ConflictIDs) (cachedConflictBranch *CachedBranch, newBranchCreated bool, err error)

CreateConflictBranch retrieves the ConflictBranch that corresponds to the given details. It automatically creates and updates the ConflictBranch according to the new details if necessary.

func (*BranchDAG) ForEachBranch added in v0.5.3

func (b *BranchDAG) ForEachBranch(consumer func(branch Branch))

ForEachBranch iterates over all of the branches and executes consumer.

func (*BranchDAG) ForEachConflictingBranchID added in v0.5.7

func (b *BranchDAG) ForEachConflictingBranchID(branchID BranchID, callback func(conflictingBranchID BranchID))

ForEachConflictingBranchID executes the callback for each ConflictBranch that is conflicting with the Branch identified by the given BranchID.

func (*BranchDAG) InclusionState added in v0.5.7

func (b *BranchDAG) InclusionState(branchID BranchID) (inclusionState InclusionState)

InclusionState returns the InclusionState of the given Branch.

func (*BranchDAG) MergeToMaster

func (b *BranchDAG) MergeToMaster(branchID BranchID) (movedBranches map[BranchID]BranchID, err error)

MergeToMaster merges a confirmed Branch with the MasterBranch to clean up the BranchDAG. It reorganizes existing ChildBranches by adjusting their parents accordingly.

func (*BranchDAG) Prune

func (b *BranchDAG) Prune() (err error)

Prune resets the database and deletes all objects (for testing or "node resets").

func (*BranchDAG) ResolveConflictBranchIDs added in v0.5.7

func (b *BranchDAG) ResolveConflictBranchIDs(branchIDs BranchIDs) (conflictBranchIDs BranchIDs, err error)

ResolveConflictBranchIDs returns the BranchIDs of the ConflictBranches that the given Branches represent by resolving AggregatedBranches to their corresponding ConflictBranches.

func (*BranchDAG) SetBranchConfirmed added in v0.5.8

func (b *BranchDAG) SetBranchConfirmed(branchID BranchID) (err error)

SetBranchConfirmed sets a Branch to be monotonically liked and finalized. It automatically triggers conflicting Branches to be marked as rejected.

func (*BranchDAG) SetBranchFinalized

func (b *BranchDAG) SetBranchFinalized(branchID BranchID, finalized bool) (modified bool, err error)

SetBranchFinalized sets the finalized flag of the given Branch. It returns true if the value has been updated or an error if it failed.

func (*BranchDAG) SetBranchLiked

func (b *BranchDAG) SetBranchLiked(branchID BranchID, liked bool) (modified bool, err error)

SetBranchLiked sets the liked flag of the given Branch. It returns true if the value has been updated or an error if it failed.

func (*BranchDAG) SetBranchMonotonicallyLiked

func (b *BranchDAG) SetBranchMonotonicallyLiked(branchID BranchID, monotonicallyLiked bool) (modified bool, err error)

SetBranchMonotonicallyLiked sets the monotonically liked flag of the given Branch. It returns true if the value has been updated or an error if failed.

func (*BranchDAG) Shutdown

func (b *BranchDAG) Shutdown()

Shutdown shuts down the BranchDAG and persists its state.

func (*BranchDAG) UpdateConflictBranchParents

func (b *BranchDAG) UpdateConflictBranchParents(conflictBranchID BranchID, newParentBranchIDs BranchIDs) (err error)

UpdateConflictBranchParents changes the parents of a ConflictBranch (also updating the references of the ChildBranches).

type BranchDAGEvent

type BranchDAGEvent struct {
	Branch *CachedBranch
}

BranchDAGEvent represents an event object that contains a Branch and that is triggered by the BranchDAG.

func NewBranchDAGEvent

func NewBranchDAGEvent(branch *CachedBranch) (newBranchEvent *BranchDAGEvent)

NewBranchDAGEvent creates a new BranchDAGEvent from the given CachedBranch.

func (*BranchDAGEvent) Release

func (b *BranchDAGEvent) Release() *BranchDAGEvent

Release marks all of the CachedObjects in the event as not used anymore.

func (*BranchDAGEvent) Retain

func (b *BranchDAGEvent) Retain() *BranchDAGEvent

Retain marks all of the CachedObjects in the event to be retained for future use.

type BranchDAGEvents

type BranchDAGEvents struct {
	// BranchLiked gets triggered whenever a Branch becomes liked that was not liked before.
	BranchLiked *events.Event

	// BranchDisliked gets triggered whenever a Branch becomes disliked that was liked before.
	BranchDisliked *events.Event

	// BranchMonotonicallyLiked gets triggered whenever a Branch becomes monotonically liked that was not monotonically
	// liked before.
	BranchMonotonicallyLiked *events.Event

	// BranchMonotonicallyDisliked gets triggered whenever a Branch becomes monotonically disliked that was
	// monotonically liked before.
	BranchMonotonicallyDisliked *events.Event

	// BranchFinalized gets triggered when a decision on a Branch is finalized and there will be no further state
	// changes regarding its liked state.
	BranchFinalized *events.Event

	// BranchUnfinalized gets triggered when a previously finalized Branch is marked as not finalized again (i.e. during
	// a reorg).
	BranchUnfinalized *events.Event

	// BranchConfirmed gets triggered whenever a Branch becomes confirmed that was not confirmed before.
	BranchConfirmed *events.Event

	// BranchRejected gets triggered whenever a Branch becomes rejected that was not rejected before.
	BranchRejected *events.Event

	// BranchPending gets triggered whenever a Branch becomes pending that was not pending before (i.e. during a reorg).
	BranchPending *events.Event
}

BranchDAGEvents is a container for all of the BranchDAG related events.

func NewBranchDAGEvents

func NewBranchDAGEvents() *BranchDAGEvents

NewBranchDAGEvents creates a container for all of the BranchDAG related events.

type BranchID

type BranchID [BranchIDLength]byte

BranchID is the data type that represents the identifier of a ConflictBranch.

func BranchIDFromBase58

func BranchIDFromBase58(base58String string) (branchID BranchID, err error)

BranchIDFromBase58 creates a BranchID from a base58 encoded string.

func BranchIDFromBytes

func BranchIDFromBytes(bytes []byte) (branchID BranchID, consumedBytes int, err error)

BranchIDFromBytes unmarshals a BranchID from a sequence of bytes.

func BranchIDFromMarshalUtil

func BranchIDFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (branchID BranchID, err error)

BranchIDFromMarshalUtil unmarshals a BranchID using a MarshalUtil (for easier unmarshaling).

func BranchIDFromRandomness added in v0.5.7

func BranchIDFromRandomness() (branchID BranchID)

BranchIDFromRandomness returns a random BranchID which can for example be used for unit tests.

func NewBranchID

func NewBranchID(transactionID TransactionID) (branchID BranchID)

NewBranchID creates a new BranchID from a TransactionID.

func (BranchID) Base58

func (b BranchID) Base58() string

Base58 returns a base58 encoded version of the BranchID.

func (BranchID) Bytes

func (b BranchID) Bytes() []byte

Bytes returns a marshaled version of the BranchID.

func (BranchID) String

func (b BranchID) String() string

String returns a human readable version of the BranchID.

func (BranchID) TransactionID added in v0.5.8

func (b BranchID) TransactionID() (transactionID TransactionID)

TransactionID returns the TransactionID of its underlying conflicting Transaction.

type BranchIDs

type BranchIDs map[BranchID]types.Empty

BranchIDs represents a collection of BranchIDs.

func BranchIDsFromBytes

func BranchIDsFromBytes(bytes []byte) (branchIDs BranchIDs, consumedBytes int, err error)

BranchIDsFromBytes unmarshals a collection of BranchIDs from a sequence of bytes.

func BranchIDsFromMarshalUtil

func BranchIDsFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (branchIDs BranchIDs, err error)

BranchIDsFromMarshalUtil unmarshals a collection of BranchIDs using a MarshalUtil (for easier unmarshaling).

func NewBranchIDs

func NewBranchIDs(branches ...BranchID) (branchIDs BranchIDs)

NewBranchIDs creates a new collection of BranchIDs from the given BranchIDs.

func (BranchIDs) Add

func (b BranchIDs) Add(branchID BranchID) BranchIDs

Add adds a BranchID to the collection and returns the collection to enable chaining.

func (BranchIDs) Bytes

func (b BranchIDs) Bytes() []byte

Bytes returns a marshaled version of the BranchIDs.

func (BranchIDs) Clone

func (b BranchIDs) Clone() (clonedBranchIDs BranchIDs)

Clone creates a copy of the BranchIDs.

func (BranchIDs) Contains

func (b BranchIDs) Contains(targetBranchID BranchID) (contains bool)

Contains checks if the given target BranchID is part of the BranchIDs.

func (BranchIDs) Slice

func (b BranchIDs) Slice() (list []BranchID)

Slice creates a slice of BranchIDs from the collection.

func (BranchIDs) String

func (b BranchIDs) String() string

String returns a human readable version of the BranchIDs.

type BranchType

type BranchType uint8

BranchType represents the type of a Branch which can either be a ConflictBranch or an AggregatedBranch.

const (
	// ConflictBranchType represents the type of a Branch that was created by a Transaction spending conflicting Outputs.
	ConflictBranchType BranchType = iota

	// AggregatedBranchType represents the type of a Branch that was created by combining Outputs of multiple
	// non-conflicting Branches.
	AggregatedBranchType
)

func BranchTypeFromBytes

func BranchTypeFromBytes(branchTypeBytes []byte) (branchType BranchType, consumedBytes int, err error)

BranchTypeFromBytes unmarshals a BranchType from a sequence of bytes.

func BranchTypeFromMarshalUtil

func BranchTypeFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (branchType BranchType, err error)

BranchTypeFromMarshalUtil unmarshals a BranchType using a MarshalUtil (for easier unmarshaling).

func (BranchType) Bytes

func (b BranchType) Bytes() []byte

Bytes returns a marshaled version of the BranchType.

func (BranchType) String

func (b BranchType) String() string

String returns a human readable representation of the BranchType.

type CachedAddressOutputMapping

type CachedAddressOutputMapping struct {
	objectstorage.CachedObject
}

CachedAddressOutputMapping is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedAddressOutputMapping) Consume

func (c *CachedAddressOutputMapping) Consume(consumer func(addressOutputMapping *AddressOutputMapping), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedAddressOutputMapping) Retain

Retain marks the CachedObject to still be in use by the program.

func (*CachedAddressOutputMapping) String

func (c *CachedAddressOutputMapping) String() string

String returns a human readable version of the CachedAddressOutputMapping.

func (*CachedAddressOutputMapping) Unwrap

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedAddressOutputMappings

type CachedAddressOutputMappings []*CachedAddressOutputMapping

CachedAddressOutputMappings represents a collection of CachedAddressOutputMapping objects.

func (CachedAddressOutputMappings) Consume

func (c CachedAddressOutputMappings) Consume(consumer func(addressOutputMapping *AddressOutputMapping), forceRelease ...bool) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

func (CachedAddressOutputMappings) Release

func (c CachedAddressOutputMappings) Release(force ...bool)

Release is a utility function that allows us to release all CachedObjects in the collection.

func (CachedAddressOutputMappings) String

String returns a human readable version of the CachedAddressOutputMappings.

func (CachedAddressOutputMappings) Unwrap

func (c CachedAddressOutputMappings) Unwrap() (unwrappedOutputs []*AddressOutputMapping)

Unwrap is the type-casted equivalent of Get. It returns a slice of unwrapped objects with the object being nil if it does not exist.

type CachedBranch

type CachedBranch struct {
	objectstorage.CachedObject
}

CachedBranch is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedBranch) Consume

func (c *CachedBranch) Consume(consumer func(branch Branch), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedBranch) ID

func (c *CachedBranch) ID() (branchID BranchID)

ID returns the BranchID of the requested Branch.

func (*CachedBranch) Retain

func (c *CachedBranch) Retain() *CachedBranch

Retain marks the CachedObject to still be in use by the program.

func (*CachedBranch) String

func (c *CachedBranch) String() string

String returns a human readable version of the CachedBranch.

func (*CachedBranch) Unwrap

func (c *CachedBranch) Unwrap() Branch

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

func (*CachedBranch) UnwrapAggregatedBranch

func (c *CachedBranch) UnwrapAggregatedBranch() (aggregatedBranch *AggregatedBranch, err error)

UnwrapAggregatedBranch is a more specialized Unwrap method that returns an AggregatedBranch instead of the more generic interface.

func (*CachedBranch) UnwrapConflictBranch

func (c *CachedBranch) UnwrapConflictBranch() (conflictBranch *ConflictBranch, err error)

UnwrapConflictBranch is a more specialized Unwrap method that returns a ConflictBranch instead of the more generic interface.

type CachedChildBranch

type CachedChildBranch struct {
	objectstorage.CachedObject
}

CachedChildBranch is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedChildBranch) Consume

func (c *CachedChildBranch) Consume(consumer func(childBranch *ChildBranch), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedChildBranch) Retain

func (c *CachedChildBranch) Retain() *CachedChildBranch

Retain marks the CachedObject to still be in use by the program.

func (*CachedChildBranch) String

func (c *CachedChildBranch) String() string

String returns a human readable version of the CachedChildBranch.

func (*CachedChildBranch) Unwrap

func (c *CachedChildBranch) Unwrap() *ChildBranch

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedChildBranches

type CachedChildBranches []*CachedChildBranch

CachedChildBranches represents a collection of CachedChildBranch objects.

func (CachedChildBranches) Consume

func (c CachedChildBranches) Consume(consumer func(childBranch *ChildBranch), forceRelease ...bool) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

func (CachedChildBranches) Release

func (c CachedChildBranches) Release(force ...bool)

Release is a utility function that allows us to release all CachedObjects in the collection.

func (CachedChildBranches) String

func (c CachedChildBranches) String() string

String returns a human readable version of the CachedChildBranches.

func (CachedChildBranches) Unwrap

func (c CachedChildBranches) Unwrap() (unwrappedChildBranches []*ChildBranch)

Unwrap is the type-casted equivalent of Get. It returns a slice of unwrapped objects with the object being nil if it does not exist.

type CachedConflict

type CachedConflict struct {
	objectstorage.CachedObject
}

CachedConflict is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedConflict) Consume

func (c *CachedConflict) Consume(consumer func(conflict *Conflict), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer. It automatically releases the object when the consumer finishes and returns true of there was at least one object that was consumed.

func (*CachedConflict) Retain

func (c *CachedConflict) Retain() *CachedConflict

Retain marks this CachedObject to still be in use by the program.

func (*CachedConflict) String

func (c *CachedConflict) String() string

String returns a human readable version of the CachedConflict.

func (*CachedConflict) Unwrap

func (c *CachedConflict) Unwrap() *Conflict

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedConflictMember

type CachedConflictMember struct {
	objectstorage.CachedObject
}

CachedConflictMember is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedConflictMember) Consume

func (c *CachedConflictMember) Consume(consumer func(conflictMember *ConflictMember), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer. It automatically releases the object when the consumer finishes and returns true of there was at least one object that was consumed.

func (*CachedConflictMember) Retain

Retain marks this CachedObject to still be in use by the program.

func (*CachedConflictMember) String

func (c *CachedConflictMember) String() string

String returns a human readable version of the CachedConflictMember.

func (*CachedConflictMember) Unwrap

func (c *CachedConflictMember) Unwrap() *ConflictMember

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedConflictMembers

type CachedConflictMembers []*CachedConflictMember

CachedConflictMembers represents a collection of CachedConflictMember objects.

func (CachedConflictMembers) Consume

func (c CachedConflictMembers) Consume(consumer func(conflictMember *ConflictMember), forceRelease ...bool) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

func (CachedConflictMembers) Release

func (c CachedConflictMembers) Release(force ...bool)

Release is a utility function that allows us to release all CachedObjects in the collection.

func (CachedConflictMembers) String

func (c CachedConflictMembers) String() string

String returns a human readable version of the CachedConflictMembers.

func (CachedConflictMembers) Unwrap

func (c CachedConflictMembers) Unwrap() (unwrappedConflictMembers []*ConflictMember)

Unwrap is the type-casted equivalent of Get. It returns a slice of unwrapped objects with the object being nil if it does not exist.

type CachedConsumer

type CachedConsumer struct {
	objectstorage.CachedObject
}

CachedConsumer is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedConsumer) Consume

func (c *CachedConsumer) Consume(consumer func(consumer *Consumer), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedConsumer) Retain

func (c *CachedConsumer) Retain() *CachedConsumer

Retain marks the CachedObject to still be in use by the program.

func (*CachedConsumer) String

func (c *CachedConsumer) String() string

String returns a human readable version of the CachedConsumer.

func (*CachedConsumer) Unwrap

func (c *CachedConsumer) Unwrap() *Consumer

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedConsumers

type CachedConsumers []*CachedConsumer

CachedConsumers represents a collection of CachedConsumer objects.

func (CachedConsumers) Consume

func (c CachedConsumers) Consume(consumer func(consumer *Consumer), forceRelease ...bool) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

func (CachedConsumers) Release

func (c CachedConsumers) Release(force ...bool)

Release is a utility function that allows us to release all CachedObjects in the collection.

func (CachedConsumers) String

func (c CachedConsumers) String() string

String returns a human readable version of the CachedConsumers.

func (CachedConsumers) Unwrap

func (c CachedConsumers) Unwrap() (unwrappedConsumers []*Consumer)

Unwrap is the type-casted equivalent of Get. It returns a slice of unwrapped objects with the object being nil if it does not exist.

type CachedOutput

type CachedOutput struct {
	objectstorage.CachedObject
}

CachedOutput is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedOutput) Consume

func (c *CachedOutput) Consume(consumer func(output Output), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedOutput) Retain

func (c *CachedOutput) Retain() *CachedOutput

Retain marks the CachedObject to still be in use by the program.

func (*CachedOutput) String

func (c *CachedOutput) String() string

String returns a human readable version of the CachedOutput.

func (*CachedOutput) Unwrap

func (c *CachedOutput) Unwrap() Output

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedOutputMetadata

type CachedOutputMetadata struct {
	objectstorage.CachedObject
}

CachedOutputMetadata is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedOutputMetadata) Consume

func (c *CachedOutputMetadata) Consume(consumer func(outputMetadata *OutputMetadata), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedOutputMetadata) Retain

Retain marks the CachedObject to still be in use by the program.

func (*CachedOutputMetadata) String

func (c *CachedOutputMetadata) String() string

String returns a human readable version of the CachedOutputMetadata.

func (*CachedOutputMetadata) Unwrap

func (c *CachedOutputMetadata) Unwrap() *OutputMetadata

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedOutputs

type CachedOutputs []*CachedOutput

CachedOutputs represents a collection of CachedOutput objects.

func (CachedOutputs) Consume

func (c CachedOutputs) Consume(consumer func(output Output), forceRelease ...bool) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

func (CachedOutputs) Release

func (c CachedOutputs) Release(force ...bool)

Release is a utility function that allows us to release all CachedObjects in the collection.

func (CachedOutputs) String

func (c CachedOutputs) String() string

String returns a human readable version of the CachedOutputs.

func (CachedOutputs) Unwrap

func (c CachedOutputs) Unwrap() (unwrappedOutputs Outputs)

Unwrap is the type-casted equivalent of Get. It returns a slice of unwrapped objects with the object being nil if it does not exist.

type CachedOutputsMetadata

type CachedOutputsMetadata []*CachedOutputMetadata

CachedOutputsMetadata represents a collection of CachedOutputMetadata objects.

func (CachedOutputsMetadata) Consume

func (c CachedOutputsMetadata) Consume(consumer func(consumer *OutputMetadata), forceRelease ...bool) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

func (CachedOutputsMetadata) Release

func (c CachedOutputsMetadata) Release(force ...bool)

Release is a utility function that allows us to release all CachedObjects in the collection.

func (CachedOutputsMetadata) String

func (c CachedOutputsMetadata) String() string

String returns a human readable version of the CachedOutputsMetadata.

func (CachedOutputsMetadata) Unwrap

func (c CachedOutputsMetadata) Unwrap() (unwrappedOutputs []*OutputMetadata)

Unwrap is the type-casted equivalent of Get. It returns a slice of unwrapped objects with the object being nil if it does not exist.

type CachedTransaction

type CachedTransaction struct {
	objectstorage.CachedObject
}

CachedTransaction is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedTransaction) Consume

func (c *CachedTransaction) Consume(consumer func(transaction *Transaction), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedTransaction) Retain

func (c *CachedTransaction) Retain() *CachedTransaction

Retain marks the CachedObject to still be in use by the program.

func (*CachedTransaction) String

func (c *CachedTransaction) String() string

String returns a human readable version of the CachedTransaction.

func (*CachedTransaction) Unwrap

func (c *CachedTransaction) Unwrap() *Transaction

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedTransactionMetadata

type CachedTransactionMetadata struct {
	objectstorage.CachedObject
}

CachedTransactionMetadata is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedTransactionMetadata) Consume

func (c *CachedTransactionMetadata) Consume(consumer func(transactionMetadata *TransactionMetadata), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedTransactionMetadata) Retain

Retain marks the CachedObject to still be in use by the program.

func (*CachedTransactionMetadata) String

func (c *CachedTransactionMetadata) String() string

String returns a human readable version of the CachedTransactionMetadata.

func (*CachedTransactionMetadata) Unwrap

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type ChildBranch

type ChildBranch struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

ChildBranch represents the relationship between a Branch and its children. Since a Branch can have a potentially unbounded amount of child Branches, we store this as a separate k/v pair instead of a marshaled list of children inside the Branch.

func ChildBranchFromBytes

func ChildBranchFromBytes(bytes []byte) (childBranch *ChildBranch, consumedBytes int, err error)

ChildBranchFromBytes unmarshals a ChildBranch from a sequence of bytes.

func ChildBranchFromMarshalUtil

func ChildBranchFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (childBranch *ChildBranch, err error)

ChildBranchFromMarshalUtil unmarshals an ChildBranch using a MarshalUtil (for easier unmarshaling).

func NewChildBranch

func NewChildBranch(parentBranchID BranchID, childBranchID BranchID, childBranchType BranchType) *ChildBranch

NewChildBranch is the constructor of the ChildBranch reference.

func (*ChildBranch) Bytes

func (c *ChildBranch) Bytes() (marshaledChildBranch []byte)

Bytes returns a marshaled version of the ChildBranch.

func (*ChildBranch) ChildBranchID

func (c *ChildBranch) ChildBranchID() (childBranchID BranchID)

ChildBranchID returns the BranchID of the child Branch in the BranchDAG.

func (*ChildBranch) ChildBranchType

func (c *ChildBranch) ChildBranchType() BranchType

ChildBranchType returns the BranchType of the child Branch in the BranchDAG.

func (*ChildBranch) ObjectStorageKey

func (c *ChildBranch) ObjectStorageKey() (objectStorageKey []byte)

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*ChildBranch) ObjectStorageValue

func (c *ChildBranch) ObjectStorageValue() (objectStorageValue []byte)

ObjectStorageValue marshals the AggregatedBranch into a sequence of bytes that are used as the value part in the object storage.

func (*ChildBranch) ParentBranchID

func (c *ChildBranch) ParentBranchID() (parentBranchID BranchID)

ParentBranchID returns the BranchID of the parent Branch in the BranchDAG.

func (*ChildBranch) String

func (c *ChildBranch) String() (humanReadableChildBranch string)

String returns a human readable version of the ChildBranch.

func (*ChildBranch) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type Color

type Color [ColorLength]byte

Color represents a marker that is associated to a token balance and that can give tokens a certain "meaning".

func ColorFromBase58EncodedString

func ColorFromBase58EncodedString(base58String string) (color Color, err error)

ColorFromBase58EncodedString creates a Color from a base58 encoded string.

func ColorFromBytes

func ColorFromBytes(colorBytes []byte) (color Color, consumedBytes int, err error)

ColorFromBytes unmarshals a Color from a sequence of bytes.

func ColorFromMarshalUtil

func ColorFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (color Color, err error)

ColorFromMarshalUtil unmarshals a Color using a MarshalUtil (for easier unmarshaling).

func (Color) Base58

func (c Color) Base58() string

Base58 returns a base58 encoded version of the Color.

func (Color) Bytes

func (c Color) Bytes() []byte

Bytes marshals the Color into a sequence of bytes.

func (Color) Compare

func (c Color) Compare(otherColor Color) int

Compare offers a comparator for Colors which returns -1 if otherColor is bigger, 1 if it is smaller and 0 if they are the same.

func (Color) String

func (c Color) String() string

String creates a human readable string of the Color.

type ColoredBalances

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

ColoredBalances represents a collection of balances associated to their respective Color that maintains a deterministic order of the present Colors.

func ColoredBalancesFromBytes

func ColoredBalancesFromBytes(bytes []byte) (coloredBalances *ColoredBalances, consumedBytes int, err error)

ColoredBalancesFromBytes unmarshals ColoredBalances from a sequence of bytes.

func ColoredBalancesFromMarshalUtil

func ColoredBalancesFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (coloredBalances *ColoredBalances, err error)

ColoredBalancesFromMarshalUtil unmarshals ColoredBalances using a MarshalUtil (for easier unmarshaling).

func NewColoredBalances

func NewColoredBalances(balances map[Color]uint64) (coloredBalances *ColoredBalances)

NewColoredBalances returns a new deterministically ordered collection of ColoredBalances.

func (*ColoredBalances) Bytes

func (c *ColoredBalances) Bytes() []byte

Bytes returns a marshaled version of the ColoredBalances.

func (*ColoredBalances) Clone

func (c *ColoredBalances) Clone() *ColoredBalances

Clone returns a copy of the ColoredBalances.

func (*ColoredBalances) ForEach

func (c *ColoredBalances) ForEach(consumer func(color Color, balance uint64) bool)

ForEach calls the consumer for each element in the collection and aborts the iteration if the consumer returns false.

func (*ColoredBalances) Get

func (c *ColoredBalances) Get(color Color) (uint64, bool)

Get returns the balance of the given Color and a boolean value indicating if the requested Color existed.

func (*ColoredBalances) Map

func (c *ColoredBalances) Map() (balances map[Color]uint64)

Map returns a vanilla golang map (unordered) containing the existing balances. Since the ColoredBalances are immutable to ensure the deterministic ordering, this method can be used to retrieve a copy of the current values prior to some modification (like setting the updated colors of a minting transaction) which can then be used to create a new ColoredBalances object.

func (*ColoredBalances) Size

func (c *ColoredBalances) Size() int

Size returns the amount of individual balances in the ColoredBalances.

func (*ColoredBalances) String

func (c *ColoredBalances) String() string

String returns a human readable version of the ColoredBalances.

type Conflict

type Conflict struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

Conflict represents a set of Branches that are conflicting with each other.

func ConflictFromBytes

func ConflictFromBytes(bytes []byte) (conflict *Conflict, consumedBytes int, err error)

ConflictFromBytes unmarshals a Conflict from a sequence of bytes.

func ConflictFromMarshalUtil

func ConflictFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (conflict *Conflict, err error)

ConflictFromMarshalUtil unmarshals a Conflict using a MarshalUtil (for easier unmarshaling).

func NewConflict

func NewConflict(conflictID ConflictID) *Conflict

NewConflict is the constructor for new Conflicts.

func (*Conflict) Bytes

func (c *Conflict) Bytes() []byte

Bytes returns a marshaled version of the Conflict.

func (*Conflict) DecreaseMemberCount

func (c *Conflict) DecreaseMemberCount(optionalDelta ...int) (newMemberCount int)

DecreaseMemberCount decreases the MemberCount of this Conflict.

func (*Conflict) ID

func (c *Conflict) ID() ConflictID

ID returns the identifier of this Conflict.

func (*Conflict) IncreaseMemberCount

func (c *Conflict) IncreaseMemberCount(optionalDelta ...int) (newMemberCount int)

IncreaseMemberCount increase the MemberCount of this Conflict.

func (*Conflict) MemberCount

func (c *Conflict) MemberCount() int

MemberCount returns the amount of Branches that are part of this Conflict.

func (*Conflict) ObjectStorageKey

func (c *Conflict) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*Conflict) ObjectStorageValue

func (c *Conflict) ObjectStorageValue() []byte

ObjectStorageValue marshals the Conflict into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.

func (*Conflict) String

func (c *Conflict) String() string

String returns a human readable version of the Conflict.

func (*Conflict) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type ConflictBranch

type ConflictBranch struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

ConflictBranch represents a container for Transactions and Outputs representing a certain perception of the ledger state.

func ConflictBranchFromBytes

func ConflictBranchFromBytes(bytes []byte) (conflictBranch *ConflictBranch, consumedBytes int, err error)

ConflictBranchFromBytes unmarshals an ConflictBranch from a sequence of bytes.

func ConflictBranchFromMarshalUtil

func ConflictBranchFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (conflictBranch *ConflictBranch, err error)

ConflictBranchFromMarshalUtil unmarshals an ConflictBranch using a MarshalUtil (for easier unmarshaling).

func NewConflictBranch

func NewConflictBranch(id BranchID, parents BranchIDs, conflicts ConflictIDs) *ConflictBranch

NewConflictBranch creates a new ConflictBranch from the given details.

func (*ConflictBranch) AddConflict

func (c *ConflictBranch) AddConflict(conflictID ConflictID) (added bool)

AddConflict registers the membership of the ConflictBranch in the given Conflict.

func (*ConflictBranch) Bytes

func (c *ConflictBranch) Bytes() []byte

Bytes returns a marshaled version of the Branch.

func (*ConflictBranch) Conflicts

func (c *ConflictBranch) Conflicts() (conflicts ConflictIDs)

Conflicts returns the Conflicts that the ConflictBranch is part of.

func (*ConflictBranch) Finalized

func (c *ConflictBranch) Finalized() bool

Finalized returns true if the decision whether it is liked has been finalized.

func (*ConflictBranch) ID

func (c *ConflictBranch) ID() BranchID

ID returns the identifier of the Branch.

func (*ConflictBranch) InclusionState

func (c *ConflictBranch) InclusionState() (inclusionState InclusionState)

InclusionState returns the InclusionState of the Branch which encodes if the Branch has been included in the ledger state.

func (*ConflictBranch) Liked

func (c *ConflictBranch) Liked() bool

Liked returns true if the branch is "liked within it's scope" (ignoring monotonicity).

func (*ConflictBranch) MonotonicallyLiked

func (c *ConflictBranch) MonotonicallyLiked() bool

MonotonicallyLiked returns true if the branch is monotonically liked (all parents are also liked).

func (*ConflictBranch) ObjectStorageKey

func (c *ConflictBranch) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*ConflictBranch) ObjectStorageValue

func (c *ConflictBranch) ObjectStorageValue() []byte

ObjectStorageValue marshals the ConflictBranch into a sequence of bytes that are used as the value part in the object storage.

func (*ConflictBranch) Parents

func (c *ConflictBranch) Parents() BranchIDs

Parents returns the BranchIDs of the Branches parents in the BranchDAG.

func (*ConflictBranch) SetParents

func (c *ConflictBranch) SetParents(parentBranches BranchIDs) (modified bool)

SetParents updates the parents of the ConflictBranch.

func (*ConflictBranch) String

func (c *ConflictBranch) String() string

String returns a human readable version of the Branch.

func (*ConflictBranch) Type

func (c *ConflictBranch) Type() BranchType

Type returns the type of the Branch.

func (*ConflictBranch) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type ConflictID

type ConflictID [ConflictIDLength]byte

ConflictID is the data type that represents the identifier of a Conflict.

func ConflictIDFromBase58

func ConflictIDFromBase58(base58String string) (conflictID ConflictID, err error)

ConflictIDFromBase58 creates a ConflictID from a base58 encoded string.

func ConflictIDFromBytes

func ConflictIDFromBytes(bytes []byte) (conflictID ConflictID, consumedBytes int, err error)

ConflictIDFromBytes unmarshals a ConflictID from a sequence of bytes.

func ConflictIDFromMarshalUtil

func ConflictIDFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (conflictID ConflictID, err error)

ConflictIDFromMarshalUtil unmarshals a ConflictID using a MarshalUtil (for easier unmarshaling).

func ConflictIDFromRandomness added in v0.5.7

func ConflictIDFromRandomness() (conflictID ConflictID)

ConflictIDFromRandomness returns a random ConflictID which can for example be used for unit tests.

func NewConflictID

func NewConflictID(outputID OutputID) (conflictID ConflictID)

NewConflictID creates a new ConflictID from an OutputID.

func (ConflictID) Base58

func (c ConflictID) Base58() string

Base58 returns a base58 encoded version of the ConflictID.

func (ConflictID) Bytes

func (c ConflictID) Bytes() []byte

Bytes returns a marshaled version of the ConflictID.

func (ConflictID) OutputID added in v0.5.3

func (c ConflictID) OutputID() (outputID OutputID)

OutputID returns the OutputID that the ConflictID represents.

func (ConflictID) String

func (c ConflictID) String() string

String returns a human readable version of the ConflictID.

type ConflictIDs

type ConflictIDs map[ConflictID]types.Empty

ConflictIDs represents a collection of ConflictIDs.

func ConflictIDsFromBytes

func ConflictIDsFromBytes(bytes []byte) (conflictIDs ConflictIDs, consumedBytes int, err error)

ConflictIDsFromBytes unmarshals a collection of ConflictIDs from a sequence of bytes.

func ConflictIDsFromMarshalUtil

func ConflictIDsFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (conflictIDs ConflictIDs, err error)

ConflictIDsFromMarshalUtil unmarshals a collection of ConflictIDs using a MarshalUtil (for easier unmarshaling).

func NewConflictIDs

func NewConflictIDs(optionalConflictIDs ...ConflictID) (conflictIDs ConflictIDs)

NewConflictIDs creates a new collection of ConflictIDs from the given list of ConflictIDs.

func (ConflictIDs) Bytes

func (c ConflictIDs) Bytes() []byte

Bytes returns a marshaled version of the ConflictIDs.

func (ConflictIDs) Clone

func (c ConflictIDs) Clone() (clonedConflictIDs ConflictIDs)

Clone creates a copy of the ConflictIDs.

func (ConflictIDs) Slice

func (c ConflictIDs) Slice() (list []ConflictID)

Slice returns a slice of ConflictIDs.

func (ConflictIDs) String

func (c ConflictIDs) String() string

String returns a human readable version of the ConflictIDs.

type ConflictMember

type ConflictMember struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

ConflictMember represents the relationship between a Conflict and its Branches. Since an Output can have a potentially unbounded amount of conflicting Consumers, we store the membership of the Branches in the corresponding Conflicts as a separate k/v pair instead of a marshaled list of members inside the Branch.

func ConflictMemberFromBytes

func ConflictMemberFromBytes(bytes []byte) (conflictMember *ConflictMember, consumedBytes int, err error)

ConflictMemberFromBytes unmarshals a ConflictMember from a sequence of bytes.

func ConflictMemberFromMarshalUtil

func ConflictMemberFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (conflictMember *ConflictMember, err error)

ConflictMemberFromMarshalUtil unmarshals an ConflictMember using a MarshalUtil (for easier unmarshaling).

func NewConflictMember

func NewConflictMember(conflictID ConflictID, branchID BranchID) *ConflictMember

NewConflictMember is the constructor of the ConflictMember reference.

func (*ConflictMember) BranchID

func (c *ConflictMember) BranchID() BranchID

BranchID returns the identifier of the Branch that this ConflictMember references.

func (*ConflictMember) Bytes

func (c *ConflictMember) Bytes() []byte

Bytes returns a marshaled version of this ConflictMember.

func (*ConflictMember) ConflictID

func (c *ConflictMember) ConflictID() ConflictID

ConflictID returns the identifier of the Conflict that this ConflictMember belongs to.

func (*ConflictMember) ObjectStorageKey

func (c *ConflictMember) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*ConflictMember) ObjectStorageValue

func (c *ConflictMember) ObjectStorageValue() []byte

ObjectStorageValue marshals the Output into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.

func (*ConflictMember) String

func (c *ConflictMember) String() string

String returns a human readable version of this ConflictMember.

func (*ConflictMember) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type Consumer

type Consumer struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

Consumer represents the relationship between an Output and its spending Transactions. Since an Output can have a potentially unbounded amount of spending Transactions, we store this as a separate k/v pair instead of a marshaled list of spending Transactions inside the Output.

func ConsumerFromBytes

func ConsumerFromBytes(bytes []byte) (consumer *Consumer, consumedBytes int, err error)

ConsumerFromBytes unmarshals a Consumer from a sequence of bytes.

func ConsumerFromMarshalUtil

func ConsumerFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (consumer *Consumer, err error)

ConsumerFromMarshalUtil unmarshals an Consumer using a MarshalUtil (for easier unmarshaling).

func NewConsumer

func NewConsumer(consumedInput OutputID, transactionID TransactionID, valid types.TriBool) *Consumer

NewConsumer creates a Consumer object from the given information.

func (*Consumer) Bytes

func (c *Consumer) Bytes() []byte

Bytes marshals the Consumer into a sequence of bytes.

func (*Consumer) ConsumedInput

func (c *Consumer) ConsumedInput() OutputID

ConsumedInput returns the OutputID of the consumed Input.

func (*Consumer) ObjectStorageKey

func (c *Consumer) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*Consumer) ObjectStorageValue

func (c *Consumer) ObjectStorageValue() []byte

ObjectStorageValue marshals the Consumer into a sequence of bytes that are used as the value part in the object storage.

func (*Consumer) SetValid

func (c *Consumer) SetValid(valid types.TriBool) (updated bool)

SetValid updates the valid flag of the Consumer and returns true if the value was changed.

func (*Consumer) String

func (c *Consumer) String() (humanReadableConsumer string)

String returns a human readable version of the Consumer.

func (*Consumer) TransactionID

func (c *Consumer) TransactionID() TransactionID

TransactionID returns the TransactionID of the consuming Transaction.

func (*Consumer) Update

func (c *Consumer) Update(other objectstorage.StorableObject)

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

func (*Consumer) Valid

func (c *Consumer) Valid() (valid types.TriBool)

Valid returns a flag that indicates if the spending Transaction is valid or not.

type ED25519Address

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

ED25519Address represents an Address that is secured by the ED25519 signature scheme.

func ED25519AddressFromBase58EncodedString

func ED25519AddressFromBase58EncodedString(base58String string) (address *ED25519Address, err error)

ED25519AddressFromBase58EncodedString creates an ED25519Address from a base58 encoded string.

func ED25519AddressFromBytes

func ED25519AddressFromBytes(bytes []byte) (address *ED25519Address, consumedBytes int, err error)

ED25519AddressFromBytes unmarshals an ED25519Address from a sequence of bytes.

func ED25519AddressFromMarshalUtil

func ED25519AddressFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (address *ED25519Address, err error)

ED25519AddressFromMarshalUtil is a method that parses an ED25519Address from the given MarshalUtil.

func NewED25519Address

func NewED25519Address(publicKey ed25519.PublicKey) *ED25519Address

NewED25519Address creates a new ED25519Address from the given public key.

func (*ED25519Address) Array added in v0.4.0

func (e *ED25519Address) Array() (array [AddressLength]byte)

Array returns an array of bytes that contains the marshaled version of the Address.

func (*ED25519Address) Base58

func (e *ED25519Address) Base58() string

Base58 returns a base58 encoded version of the address.

func (*ED25519Address) Bytes

func (e *ED25519Address) Bytes() []byte

Bytes returns a marshaled version of the Address.

func (*ED25519Address) Clone

func (e *ED25519Address) Clone() Address

Clone creates a copy of the Address.

func (*ED25519Address) Digest

func (e *ED25519Address) Digest() []byte

Digest returns the hashed version of the Addresses public key.

func (*ED25519Address) Equals added in v0.6.0

func (e *ED25519Address) Equals(other Address) bool

Equals returns true if the two Addresses are equal.

func (*ED25519Address) String

func (e *ED25519Address) String() string

String returns a human readable version of the addresses for debug purposes.

func (*ED25519Address) Type

func (e *ED25519Address) Type() AddressType

Type returns the AddressType of the Address.

type ED25519Signature

type ED25519Signature struct {
	PublicKey ed25519.PublicKey
	Signature ed25519.Signature
}

ED25519Signature represents a Signature created with the ed25519 signature scheme.

func ED25519SignatureFromBase58EncodedString

func ED25519SignatureFromBase58EncodedString(base58String string) (signature *ED25519Signature, err error)

ED25519SignatureFromBase58EncodedString creates an ED25519Signature from a base58 encoded string.

func ED25519SignatureFromBytes

func ED25519SignatureFromBytes(bytes []byte) (signature *ED25519Signature, consumedBytes int, err error)

ED25519SignatureFromBytes unmarshals a ED25519Signature from a sequence of bytes.

func ED25519SignatureFromMarshalUtil

func ED25519SignatureFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (signature *ED25519Signature, err error)

ED25519SignatureFromMarshalUtil unmarshals a ED25519Signature using a MarshalUtil (for easier unmarshaling).

func NewED25519Signature

func NewED25519Signature(publicKey ed25519.PublicKey, signature ed25519.Signature) *ED25519Signature

NewED25519Signature is the constructor of an ED25519Signature.

func (*ED25519Signature) AddressSignatureValid

func (e *ED25519Signature) AddressSignatureValid(address Address, data []byte) bool

AddressSignatureValid returns true if the Signature signs the given Address.

func (*ED25519Signature) Base58

func (e *ED25519Signature) Base58() string

Base58 returns a base58 encoded version of the Signature.

func (*ED25519Signature) Bytes

func (e *ED25519Signature) Bytes() []byte

Bytes returns a marshaled version of the Signature.

func (*ED25519Signature) SignatureValid

func (e *ED25519Signature) SignatureValid(data []byte) bool

SignatureValid returns true if the Signature signs the given data.

func (*ED25519Signature) String

func (e *ED25519Signature) String() string

String returns a human readable version of the Signature.

func (*ED25519Signature) Type

func (e *ED25519Signature) Type() SignatureType

Type returns the SignatureType of this Signature.

type ExtendedLockedOutput added in v0.6.0

type ExtendedLockedOutput struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

ExtendedLockedOutput is an Extension of SigLockedColoredOutput. If extended options not enabled, it behaves as SigLockedColoredOutput. In addition it has options: - fallback address and fallback timeout - can be unlocked by AliasUnlockBlock (if address is of AliasAddress type) - can be time locked until deadline - data payload for arbitrary metadata (size limits apply)

func ExtendedOutputFromBytes added in v0.6.0

func ExtendedOutputFromBytes(data []byte) (output *ExtendedLockedOutput, consumedBytes int, err error)

ExtendedOutputFromBytes unmarshals a ExtendedLockedOutput from a sequence of bytes.

func ExtendedOutputFromMarshalUtil added in v0.6.0

func ExtendedOutputFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (output *ExtendedLockedOutput, err error)

ExtendedOutputFromMarshalUtil unmarshals a ExtendedLockedOutput using a MarshalUtil (for easier unmarshaling).

func NewExtendedLockedOutput added in v0.6.0

func NewExtendedLockedOutput(balances map[Color]uint64, address Address) *ExtendedLockedOutput

NewExtendedLockedOutput is the constructor for a ExtendedLockedOutput.

func (*ExtendedLockedOutput) Address added in v0.6.0

func (o *ExtendedLockedOutput) Address() Address

Address returns the Address that the Output is associated to.

func (*ExtendedLockedOutput) Balances added in v0.6.0

func (o *ExtendedLockedOutput) Balances() *ColoredBalances

Balances returns the funds that are associated with the Output.

func (*ExtendedLockedOutput) Bytes added in v0.6.0

func (o *ExtendedLockedOutput) Bytes() []byte

Bytes returns a marshaled version of the Output.

func (*ExtendedLockedOutput) Clone added in v0.6.0

func (o *ExtendedLockedOutput) Clone() Output

Clone creates a copy of the Output.

func (*ExtendedLockedOutput) Compare added in v0.6.0

func (o *ExtendedLockedOutput) Compare(other Output) int

Compare offers a comparator for Outputs which returns -1 if the other Output is bigger, 1 if it is smaller and 0 if they are the same.

func (*ExtendedLockedOutput) FallbackAddress added in v0.6.0

func (o *ExtendedLockedOutput) FallbackAddress() (addy Address)

FallbackAddress returns the fallback address that the Output is associated to.

func (*ExtendedLockedOutput) FallbackOptions added in v0.6.0

func (o *ExtendedLockedOutput) FallbackOptions() (Address, time.Time)

FallbackOptions returns fallback options of the output. The address is nil if fallback options are not set

func (*ExtendedLockedOutput) GetPayload added in v0.6.0

func (o *ExtendedLockedOutput) GetPayload() []byte

GetPayload return a data payload associated with the output

func (*ExtendedLockedOutput) ID added in v0.6.0

ID returns the identifier of the Output that is used to address the Output in the UTXODAG.

func (*ExtendedLockedOutput) Input added in v0.6.0

func (o *ExtendedLockedOutput) Input() Input

Input returns an Input that references the Output.

func (*ExtendedLockedOutput) ObjectStorageKey added in v0.6.0

func (o *ExtendedLockedOutput) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*ExtendedLockedOutput) ObjectStorageValue added in v0.6.0

func (o *ExtendedLockedOutput) ObjectStorageValue() []byte

ObjectStorageValue marshals the Output into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.

func (*ExtendedLockedOutput) SetID added in v0.6.0

func (o *ExtendedLockedOutput) SetID(outputID OutputID) Output

SetID allows to set the identifier of the Output. We offer a setter for the property since Outputs that are created to become part of a transaction usually do not have an identifier, yet as their identifier depends on the TransactionID that is only determinable after the Transaction has been fully constructed. The ID is therefore only accessed when the Output is supposed to be persisted by the node.

func (*ExtendedLockedOutput) SetPayload added in v0.6.0

func (o *ExtendedLockedOutput) SetPayload(data []byte) error

SetPayload sets the payload field of the output.

func (*ExtendedLockedOutput) String added in v0.6.0

func (o *ExtendedLockedOutput) String() string

String returns a human readable version of the Output.

func (*ExtendedLockedOutput) TimeLock added in v0.6.0

func (o *ExtendedLockedOutput) TimeLock() time.Time

TimeLock is a time after which output can be unlocked

func (*ExtendedLockedOutput) TimeLockedNow added in v0.6.0

func (o *ExtendedLockedOutput) TimeLockedNow(nowis time.Time) bool

TimeLockedNow checks if output is unlocked for the specific moment

func (*ExtendedLockedOutput) Type added in v0.6.0

func (o *ExtendedLockedOutput) Type() OutputType

Type returns the type of the Output which allows us to generically handle Outputs of different types.

func (*ExtendedLockedOutput) UnlockAddressNow added in v0.6.0

func (o *ExtendedLockedOutput) UnlockAddressNow(nowis time.Time) Address

UnlockAddressNow return unlock address which is valid for the specific moment of time

func (*ExtendedLockedOutput) UnlockValid added in v0.6.0

func (o *ExtendedLockedOutput) UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (unlockValid bool, err error)

UnlockValid determines if the given Transaction and the corresponding UnlockBlock are allowed to spend the Output.

func (*ExtendedLockedOutput) Update added in v0.6.0

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

func (*ExtendedLockedOutput) UpdateMintingColor added in v0.6.0

func (o *ExtendedLockedOutput) UpdateMintingColor() Output

UpdateMintingColor replaces the ColorMint in the balances of the Output with the hash of the OutputID. It returns a copy of the original Output with the modified balances.

func (*ExtendedLockedOutput) WithFallbackOptions added in v0.6.0

func (o *ExtendedLockedOutput) WithFallbackOptions(addr Address, deadline time.Time) *ExtendedLockedOutput

WithFallbackOptions adds fallback options to the output and returns the updated version.

func (*ExtendedLockedOutput) WithTimeLock added in v0.6.0

func (o *ExtendedLockedOutput) WithTimeLock(timelock time.Time) *ExtendedLockedOutput

WithTimeLock adds timelock to the output and returns the updated version.

type IUTXODAG added in v0.7.4

type IUTXODAG interface {
	// Events returns all events of the UTXODAG
	Events() *UTXODAGEvents
	// Shutdown shuts down the UTXODAG and persists its state.
	Shutdown()
	// CheckTransaction contains fast checks that have to be performed before booking a Transaction.
	CheckTransaction(transaction *Transaction) (err error)
	// BookTransaction books a Transaction into the ledger state.
	BookTransaction(transaction *Transaction) (targetBranch BranchID, err error)
	// InclusionState returns the InclusionState of the Transaction with the given TransactionID which can either be
	// Pending, Confirmed or Rejected.
	InclusionState(transactionID TransactionID) (inclusionState InclusionState, err error)
	// CachedTransaction retrieves the Transaction with the given TransactionID from the object storage.
	CachedTransaction(transactionID TransactionID) (cachedTransaction *CachedTransaction)
	// Transaction returns a specific transaction, consumed.
	Transaction(transactionID TransactionID) (transaction *Transaction)
	// Transactions returns all the transactions, consumed.
	Transactions() (transactions map[TransactionID]*Transaction)
	// CachedTransactionMetadata retrieves the TransactionMetadata with the given TransactionID from the object storage.
	CachedTransactionMetadata(transactionID TransactionID) (cachedTransactionMetadata *CachedTransactionMetadata)
	// CachedOutput retrieves the Output with the given OutputID from the object storage.
	CachedOutput(outputID OutputID) (cachedOutput *CachedOutput)
	// CachedOutputMetadata retrieves the OutputMetadata with the given OutputID from the object storage.
	CachedOutputMetadata(outputID OutputID) (cachedOutput *CachedOutputMetadata)
	// CachedConsumers retrieves the Consumers of the given OutputID from the object storage.
	CachedConsumers(outputID OutputID) (cachedConsumers CachedConsumers)
	// LoadSnapshot creates a set of outputs in the UTXO-DAG, that are forming the genesis for future transactions.
	LoadSnapshot(snapshot *Snapshot)
	// CachedAddressOutputMapping retrieves the outputs for the given address.
	CachedAddressOutputMapping(address Address) (cachedAddressOutputMappings CachedAddressOutputMappings)
	// SetTransactionConfirmed marks a Transaction (and all Transactions in its past cone) as confirmed. It also marks the
	// conflicting Transactions to be rejected.
	SetTransactionConfirmed(transactionID TransactionID) (err error)
	// ConsumedOutputs returns the consumed (cached)Outputs of the given Transaction.
	ConsumedOutputs(transaction *Transaction) (cachedInputs CachedOutputs)
	// ManageStoreAddressOutputMapping mangages how to store the address-output mapping dependent on which type of output it is.
	ManageStoreAddressOutputMapping(output Output)
	// StoreAddressOutputMapping stores the address-output mapping.
	StoreAddressOutputMapping(address Address, outputID OutputID)
}

IUTXODAG is the interface for UTXODAG which is the core of the ledger state that is formed by Transactions consuming Inputs and creating Outputs. It represents all the methods that helps to keep track of the balances and the different perceptions of potential conflicts.

type InclusionState

type InclusionState uint8

InclusionState represents a type that encodes if a Transaction or Branch has been included in the ledger state.

const (
	// Pending represents the state of Transactions and Branches that have not been assigned a final state regarding
	// their inclusion in the ledger state.
	Pending InclusionState = iota

	// Confirmed represents the state of Transactions and Branches that have been accepted to be part of the ledger
	// state.
	Confirmed

	// Rejected represents the state of Transactions and Branches that have been rejected to be part of the ledger
	// state.
	Rejected
)

func InclusionStateFromBytes

func InclusionStateFromBytes(inclusionStateBytes []byte) (inclusionState InclusionState, consumedBytes int, err error)

InclusionStateFromBytes unmarshals an InclusionState from a sequence of bytes.

func InclusionStateFromMarshalUtil

func InclusionStateFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (inclusionState InclusionState, err error)

InclusionStateFromMarshalUtil unmarshals an InclusionState using a MarshalUtil (for easier unmarshaling).

func (InclusionState) Bytes

func (i InclusionState) Bytes() []byte

Bytes returns a marshaled version of the InclusionState.

func (InclusionState) String

func (i InclusionState) String() string

String returns a human readable version of the InclusionState.

type Input

type Input interface {
	// Type returns the type of the Input.
	Type() InputType

	// Bytes returns a marshaled version of the Input.
	Bytes() []byte

	// String returns a human readable version of the Input.
	String() string

	// Base58 returns the base58 encoded input.
	Base58() string

	// Compare offers a comparator for Inputs which returns -1 if other Input is bigger, 1 if it is smaller and 0 if they
	// are the same.
	Compare(other Input) int
}

Input is a generic interface for different kinds of Inputs.

func InputFromBytes

func InputFromBytes(inputBytes []byte) (input Input, consumedBytes int, err error)

InputFromBytes unmarshals an Input from a sequence of bytes.

func InputFromMarshalUtil

func InputFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (input Input, err error)

InputFromMarshalUtil unmarshals an Input using a MarshalUtil (for easier unmarshaling).

type InputType

type InputType uint8

InputType represents the type of an Input.

func (InputType) String

func (i InputType) String() string

String returns a human readable representation of the InputType.

type Inputs

type Inputs []Input

Inputs represents a collection of Inputs that ensures a deterministic order.

func InputsFromBytes

func InputsFromBytes(inputBytes []byte) (inputs Inputs, consumedBytes int, err error)

InputsFromBytes unmarshals a collection of Inputs from a sequence of bytes.

func InputsFromMarshalUtil

func InputsFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (inputs Inputs, err error)

InputsFromMarshalUtil unmarshals a collection of Inputs using a MarshalUtil (for easier unmarshaling).

func NewInputs

func NewInputs(optionalInputs ...Input) (inputs Inputs)

NewInputs returns a deterministically ordered collection of Inputs removing existing duplicates.

func (Inputs) Bytes

func (i Inputs) Bytes() []byte

Bytes returns a marshaled version of the Inputs.

func (Inputs) Clone

func (i Inputs) Clone() (clonedInputs Inputs)

Clone creates a copy of the Inputs.

func (Inputs) String

func (i Inputs) String() string

String returns a human readable version of the Inputs.

func (Inputs) Strings added in v0.5.3

func (i Inputs) Strings() (result []string)

Strings returns the Inputs in the form []transactionID:index.

type Output

type Output interface {
	// ID returns the identifier of the Output that is used to address the Output in the UTXODAG.
	ID() OutputID

	// SetID allows to set the identifier of the Output. We offer a setter for the property since Outputs that are
	// created to become part of a transaction usually do not have an identifier, yet as their identifier depends on
	// the TransactionID that is only determinable after the Transaction has been fully constructed. The ID is therefore
	// only accessed when the Output is supposed to be persisted.
	SetID(outputID OutputID) Output

	// Type returns the OutputType which allows us to generically handle Outputs of different types.
	Type() OutputType

	// Balances returns the funds that are associated with the Output.
	Balances() *ColoredBalances

	// Address returns the address that is associated to the output.
	Address() Address

	// UnlockValid determines if the given Transaction and the corresponding UnlockBlock are allowed to spend the
	// Output.
	UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (bool, error)

	// UpdateMintingColor replaces the ColorMint in the balances of the Output with the hash of the OutputID. It returns a
	// copy of the original Output with the modified balances.
	UpdateMintingColor() Output

	// Input returns an Input that references the Output.
	Input() Input

	// Clone creates a copy of the Output.
	Clone() Output

	// Bytes returns a marshaled version of the Output.
	Bytes() []byte

	// String returns a human readable version of the Output for debug purposes.
	String() string

	// Compare offers a comparator for Outputs which returns -1 if the other Output is bigger, 1 if it is smaller and 0
	// if they are the same.
	Compare(other Output) int

	// StorableObject makes Outputs storable in the ObjectStorage.
	objectstorage.StorableObject
}

Output is a generic interface for the different types of Outputs (with different unlock behaviors).

func OutputFromBytes

func OutputFromBytes(bytes []byte) (output Output, consumedBytes int, err error)

OutputFromBytes unmarshals an Output from a sequence of bytes.

func OutputFromMarshalUtil

func OutputFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (output Output, err error)

OutputFromMarshalUtil unmarshals an Output using a MarshalUtil (for easier unmarshaling).

type OutputID

type OutputID [OutputIDLength]byte

OutputID is the data type that represents the identifier of an Output (which consists of a TransactionID and the index of the Output in the Transaction that created it).

var EmptyOutputID OutputID

EmptyOutputID represents the zero-value of an OutputID.

func NewOutputID

func NewOutputID(transactionID TransactionID, outputIndex uint16) (outputID OutputID)

NewOutputID is the constructor for the OutputID.

func OutputIDFromBase58

func OutputIDFromBase58(base58String string) (outputID OutputID, err error)

OutputIDFromBase58 creates an OutputID from a base58 encoded string.

func OutputIDFromBytes

func OutputIDFromBytes(bytes []byte) (outputID OutputID, consumedBytes int, err error)

OutputIDFromBytes unmarshals an OutputID from a sequence of bytes.

func OutputIDFromMarshalUtil

func OutputIDFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (outputID OutputID, err error)

OutputIDFromMarshalUtil unmarshals an OutputID using a MarshalUtil (for easier unmarshaling).

func (OutputID) Base58

func (o OutputID) Base58() string

Base58 returns a base58 encoded version of the OutputID.

func (OutputID) Bytes

func (o OutputID) Bytes() []byte

Bytes marshals the OutputID into a sequence of bytes.

func (OutputID) OutputIndex

func (o OutputID) OutputIndex() uint16

OutputIndex returns the Output index part of an OutputID.

func (OutputID) String

func (o OutputID) String() string

String creates a human readable version of the OutputID.

func (OutputID) TransactionID

func (o OutputID) TransactionID() (transactionID TransactionID)

TransactionID returns the TransactionID part of an OutputID.

type OutputMetadata

type OutputMetadata struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

OutputMetadata contains additional Output information that are derived from the local perception of the node.

func NewOutputMetadata

func NewOutputMetadata(outputID OutputID) *OutputMetadata

NewOutputMetadata creates a new empty OutputMetadata object.

func OutputMetadataFromBytes

func OutputMetadataFromBytes(bytes []byte) (outputMetadata *OutputMetadata, consumedBytes int, err error)

OutputMetadataFromBytes unmarshals an OutputMetadata object from a sequence of bytes.

func OutputMetadataFromMarshalUtil

func OutputMetadataFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (outputMetadata *OutputMetadata, err error)

OutputMetadataFromMarshalUtil unmarshals an OutputMetadata object using a MarshalUtil (for easier unmarshaling).

func (*OutputMetadata) BranchID

func (o *OutputMetadata) BranchID() BranchID

BranchID returns the identifier of the Branch that the Output was booked in.

func (*OutputMetadata) Bytes

func (o *OutputMetadata) Bytes() []byte

Bytes marshals the OutputMetadata into a sequence of bytes.

func (*OutputMetadata) ConfirmedConsumer added in v0.6.2

func (o *OutputMetadata) ConfirmedConsumer() TransactionID

ConfirmedConsumer returns the consumer that spent the transaction if the consumer is confirmed already

func (*OutputMetadata) ConsumerCount

func (o *OutputMetadata) ConsumerCount() int

ConsumerCount returns the number of transactions that have spent the Output.

func (*OutputMetadata) Finalized

func (o *OutputMetadata) Finalized() (finalized bool)

Finalized returns a boolean flag that indicates if the Transaction has been finalized regarding its decision of being included in the ledger state.

func (*OutputMetadata) FirstConsumer

func (o *OutputMetadata) FirstConsumer() TransactionID

FirstConsumer returns the first TransactionID that ever spent the Output.

func (*OutputMetadata) ID

func (o *OutputMetadata) ID() OutputID

ID returns the OutputID of the Output that the OutputMetadata belongs to.

func (*OutputMetadata) ObjectStorageKey

func (o *OutputMetadata) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*OutputMetadata) ObjectStorageValue

func (o *OutputMetadata) ObjectStorageValue() []byte

ObjectStorageValue marshals the OutputMetadata into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.

func (*OutputMetadata) RegisterConsumer

func (o *OutputMetadata) RegisterConsumer(consumer TransactionID) (previousConsumerCount int)

RegisterConsumer increases the consumer count of an Output and stores the first Consumer that was ever registered. It returns the previous consumer count.

func (*OutputMetadata) SetBranchID

func (o *OutputMetadata) SetBranchID(branchID BranchID) (modified bool)

SetBranchID sets the identifier of the Branch that the Output was booked in.

func (*OutputMetadata) SetConfirmedConsumer added in v0.6.2

func (o *OutputMetadata) SetConfirmedConsumer(confirmedConsumer TransactionID) (modified bool)

SetConfirmedConsumer updates the confirmedConsumer of the output.

func (*OutputMetadata) SetFinalized

func (o *OutputMetadata) SetFinalized(finalized bool) (modified bool)

SetFinalized updates the finalized flag of the Transaction. It returns true if the lazy booked flag was modified.

func (*OutputMetadata) SetSolid

func (o *OutputMetadata) SetSolid(solid bool) (modified bool)

SetSolid updates the solid flag of the Output. It returns true if the solid flag was modified and updates the solidification time if the Output was marked as solid.

func (*OutputMetadata) Solid

func (o *OutputMetadata) Solid() bool

Solid returns true if the Output has been marked as solid.

func (*OutputMetadata) SolidificationTime

func (o *OutputMetadata) SolidificationTime() time.Time

SolidificationTime returns the time when the Output was marked as solid.

func (*OutputMetadata) String

func (o *OutputMetadata) String() string

String returns a human readable version of the OutputMetadata.

func (*OutputMetadata) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type OutputType

type OutputType uint8

OutputType represents the type of an Output. Outputs of different types can have different unlock rules and allow for some relatively basic smart contract logic.

const (
	// SigLockedSingleOutputType represents an Output holding vanilla IOTA tokens that gets unlocked by a signature.
	SigLockedSingleOutputType OutputType = iota

	// SigLockedColoredOutputType represents an Output that holds colored coins that gets unlocked by a signature.
	SigLockedColoredOutputType

	// AliasOutputType represents an Output which makes a chain with optional governance
	AliasOutputType

	// ExtendedLockedOutputType represents an Output which extends SigLockedColoredOutput with alias locking and fallback
	ExtendedLockedOutputType
)

func OutputTypeFromString added in v0.6.0

func OutputTypeFromString(ot string) (OutputType, error)

OutputTypeFromString returns the output type from a string.

func (OutputType) String

func (o OutputType) String() string

String returns a human readable representation of the OutputType.

type Outputs

type Outputs []Output

Outputs represents a list of Outputs that can be used in a Transaction.

func NewOutputs

func NewOutputs(optionalOutputs ...Output) (outputs Outputs)

NewOutputs returns a deterministically ordered collection of Outputs. It removes duplicates in the parameters and sorts the Outputs to ensure syntactical correctness.

func OutputsFromBytes

func OutputsFromBytes(outputBytes []byte) (outputs Outputs, consumedBytes int, err error)

OutputsFromBytes unmarshals a collection of Outputs from a sequence of bytes.

func OutputsFromMarshalUtil

func OutputsFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (outputs Outputs, err error)

OutputsFromMarshalUtil unmarshals a collection of Outputs using a MarshalUtil (for easier unmarshaling).

func (Outputs) ByID

func (o Outputs) ByID() (outputsByID OutputsByID)

ByID returns a map of Outputs where the key is the OutputID.

func (Outputs) Bytes

func (o Outputs) Bytes() []byte

Bytes returns a marshaled version of the Outputs.

func (Outputs) Clone

func (o Outputs) Clone() (clonedOutputs Outputs)

Clone creates a copy of the Outputs.

func (Outputs) Filter added in v0.5.3

func (o Outputs) Filter(condition func(output Output) bool) (filteredOutputs Outputs)

Filter removes all elements from the Outputs that do not pass the given condition.

func (Outputs) Inputs

func (o Outputs) Inputs() Inputs

Inputs returns the Inputs that reference the Outputs.

func (Outputs) String

func (o Outputs) String() string

String returns a human readable version of the Outputs.

func (Outputs) Strings added in v0.5.3

func (o Outputs) Strings() (result []string)

Strings returns the Outputs in the form []transactionID:index.

type OutputsByID

type OutputsByID map[OutputID]Output

OutputsByID represents a map of Outputs where every Output is stored with its corresponding OutputID as the key.

func NewOutputsByID

func NewOutputsByID(optionalOutputs ...Output) (outputsByID OutputsByID)

NewOutputsByID returns a map of Outputs where every Output is stored with its corresponding OutputID as the key.

func (OutputsByID) Clone

func (o OutputsByID) Clone() (clonedOutputs OutputsByID)

Clone creates a copy of the OutputsByID.

func (OutputsByID) Inputs

func (o OutputsByID) Inputs() Inputs

Inputs returns the Inputs that reference the Outputs.

func (OutputsByID) Outputs

func (o OutputsByID) Outputs() Outputs

Outputs returns a list of Outputs from the OutputsByID.

func (OutputsByID) String

func (o OutputsByID) String() string

String returns a human readable version of the OutputsByID.

type OutputsMetadata

type OutputsMetadata []*OutputMetadata

OutputsMetadata represents a list of OutputMetadata objects.

func (OutputsMetadata) ByID

func (o OutputsMetadata) ByID() (outputsMetadataByID OutputsMetadataByID)

ByID returns a map of OutputsMetadata where the key is the OutputID.

func (OutputsMetadata) ConflictIDs

func (o OutputsMetadata) ConflictIDs() (conflictIDs ConflictIDs)

ConflictIDs returns the ConflictIDs that are the equivalent of the OutputIDs in the list.

func (OutputsMetadata) OutputIDs

func (o OutputsMetadata) OutputIDs() (outputIDs []OutputID)

OutputIDs returns the OutputIDs of the Outputs in the list.

func (OutputsMetadata) String

func (o OutputsMetadata) String() string

String returns a human readable version of the OutputsMetadata.

type OutputsMetadataByID

type OutputsMetadataByID map[OutputID]*OutputMetadata

OutputsMetadataByID represents a map of OutputMetadatas where every OutputMetadata is stored with its corresponding OutputID as the key.

func (OutputsMetadataByID) ConflictIDs

func (o OutputsMetadataByID) ConflictIDs() (conflictIDs ConflictIDs)

ConflictIDs turns the list of OutputMetadata objects into their corresponding ConflictIDs.

func (OutputsMetadataByID) Filter

func (o OutputsMetadataByID) Filter(outputIDsToInclude []OutputID) (intersectionOfInputs OutputsMetadataByID)

Filter returns the OutputsMetadataByID that are sharing a set membership with the given Inputs.

func (OutputsMetadataByID) IDs

func (o OutputsMetadataByID) IDs() (outputIDs []OutputID)

IDs returns the OutputIDs that are used as keys in the collection.

func (OutputsMetadataByID) String

func (o OutputsMetadataByID) String() string

String returns a human readable version of the OutputsMetadataByID.

type Record added in v0.6.2

type Record struct {
	Essence        *TransactionEssence
	UnlockBlocks   UnlockBlocks
	UnspentOutputs []bool
}

Record defines a record of the snapshot.

type ReferenceUnlockBlock

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

ReferenceUnlockBlock defines an UnlockBlock which references a previous UnlockBlock (which must not be another ReferenceUnlockBlock).

func NewReferenceUnlockBlock

func NewReferenceUnlockBlock(referencedIndex uint16) *ReferenceUnlockBlock

NewReferenceUnlockBlock is the constructor for ReferenceUnlockBlocks.

func ReferenceUnlockBlockFromBytes

func ReferenceUnlockBlockFromBytes(bytes []byte) (unlockBlock *ReferenceUnlockBlock, consumedBytes int, err error)

ReferenceUnlockBlockFromBytes unmarshals a ReferenceUnlockBlock from a sequence of bytes.

func ReferenceUnlockBlockFromMarshalUtil

func ReferenceUnlockBlockFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (unlockBlock *ReferenceUnlockBlock, err error)

ReferenceUnlockBlockFromMarshalUtil unmarshals a ReferenceUnlockBlock using a MarshalUtil (for easier unmarshaling).

func (*ReferenceUnlockBlock) Bytes

func (r *ReferenceUnlockBlock) Bytes() []byte

Bytes returns a marshaled version of the UnlockBlock.

func (*ReferenceUnlockBlock) ReferencedIndex

func (r *ReferenceUnlockBlock) ReferencedIndex() uint16

ReferencedIndex returns the index of the referenced UnlockBlock.

func (*ReferenceUnlockBlock) String

func (r *ReferenceUnlockBlock) String() string

String returns a human readable version of the UnlockBlock.

func (*ReferenceUnlockBlock) Type

Type returns the UnlockBlockType of the UnlockBlock.

type SigLockedColoredOutput

type SigLockedColoredOutput struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

SigLockedColoredOutput is an Output that holds colored balances and that can be unlocked by providing a signature for an Address.

func NewSigLockedColoredOutput

func NewSigLockedColoredOutput(balances *ColoredBalances, address Address) *SigLockedColoredOutput

NewSigLockedColoredOutput is the constructor for a SigLockedColoredOutput.

func SigLockedColoredOutputFromBytes

func SigLockedColoredOutputFromBytes(bytes []byte) (output *SigLockedColoredOutput, consumedBytes int, err error)

SigLockedColoredOutputFromBytes unmarshals a SigLockedColoredOutput from a sequence of bytes.

func SigLockedColoredOutputFromMarshalUtil

func SigLockedColoredOutputFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (output *SigLockedColoredOutput, err error)

SigLockedColoredOutputFromMarshalUtil unmarshals a SigLockedColoredOutput using a MarshalUtil (for easier unmarshaling).

func (*SigLockedColoredOutput) Address

func (s *SigLockedColoredOutput) Address() Address

Address returns the Address that the Output is associated to.

func (*SigLockedColoredOutput) Balances

func (s *SigLockedColoredOutput) Balances() *ColoredBalances

Balances returns the funds that are associated with the Output.

func (*SigLockedColoredOutput) Bytes

func (s *SigLockedColoredOutput) Bytes() []byte

Bytes returns a marshaled version of the Output.

func (*SigLockedColoredOutput) Clone

func (s *SigLockedColoredOutput) Clone() Output

Clone creates a copy of the Output.

func (*SigLockedColoredOutput) Compare

func (s *SigLockedColoredOutput) Compare(other Output) int

Compare offers a comparator for Outputs which returns -1 if the other Output is bigger, 1 if it is smaller and 0 if they are the same.

func (*SigLockedColoredOutput) ID

ID returns the identifier of the Output that is used to address the Output in the UTXODAG.

func (*SigLockedColoredOutput) Input

func (s *SigLockedColoredOutput) Input() Input

Input returns an Input that references the Output.

func (*SigLockedColoredOutput) ObjectStorageKey

func (s *SigLockedColoredOutput) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*SigLockedColoredOutput) ObjectStorageValue

func (s *SigLockedColoredOutput) ObjectStorageValue() []byte

ObjectStorageValue marshals the Output into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.

func (*SigLockedColoredOutput) SetID

func (s *SigLockedColoredOutput) SetID(outputID OutputID) Output

SetID allows to set the identifier of the Output. We offer a setter for the property since Outputs that are created to become part of a transaction usually do not have an identifier, yet as their identifier depends on the TransactionID that is only determinable after the Transaction has been fully constructed. The ID is therefore only accessed when the Output is supposed to be persisted by the node.

func (*SigLockedColoredOutput) String

func (s *SigLockedColoredOutput) String() string

String returns a human readable version of the Output.

func (*SigLockedColoredOutput) Type

Type returns the type of the Output which allows us to generically handle Outputs of different types.

func (*SigLockedColoredOutput) UnlockValid

func (s *SigLockedColoredOutput) UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (unlockValid bool, err error)

UnlockValid determines if the given Transaction and the corresponding UnlockBlock are allowed to spend the Output.

func (*SigLockedColoredOutput) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

func (*SigLockedColoredOutput) UpdateMintingColor added in v0.4.0

func (s *SigLockedColoredOutput) UpdateMintingColor() (updatedOutput Output)

UpdateMintingColor replaces the ColorMint in the balances of the Output with the hash of the OutputID. It returns a copy of the original Output with the modified balances.

type SigLockedSingleOutput

type SigLockedSingleOutput struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

SigLockedSingleOutput is an Output that holds exactly one uncolored balance and that can be unlocked by providing a signature for an Address.

func NewSigLockedSingleOutput

func NewSigLockedSingleOutput(balance uint64, address Address) *SigLockedSingleOutput

NewSigLockedSingleOutput is the constructor for a SigLockedSingleOutput.

func SigLockedSingleOutputFromBytes

func SigLockedSingleOutputFromBytes(bytes []byte) (output *SigLockedSingleOutput, consumedBytes int, err error)

SigLockedSingleOutputFromBytes unmarshals a SigLockedSingleOutput from a sequence of bytes.

func SigLockedSingleOutputFromMarshalUtil

func SigLockedSingleOutputFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (output *SigLockedSingleOutput, err error)

SigLockedSingleOutputFromMarshalUtil unmarshals a SigLockedSingleOutput using a MarshalUtil (for easier unmarshaling).

func (*SigLockedSingleOutput) Address

func (s *SigLockedSingleOutput) Address() Address

Address returns the Address that the Output is associated to.

func (*SigLockedSingleOutput) Balances

func (s *SigLockedSingleOutput) Balances() *ColoredBalances

Balances returns the funds that are associated with the Output.

func (*SigLockedSingleOutput) Bytes

func (s *SigLockedSingleOutput) Bytes() []byte

Bytes returns a marshaled version of the Output.

func (*SigLockedSingleOutput) Clone

func (s *SigLockedSingleOutput) Clone() Output

Clone creates a copy of the Output.

func (*SigLockedSingleOutput) Compare

func (s *SigLockedSingleOutput) Compare(other Output) int

Compare offers a comparator for Outputs which returns -1 if the other Output is bigger, 1 if it is smaller and 0 if they are the same.

func (*SigLockedSingleOutput) ID

ID returns the identifier of the Output that is used to address the Output in the UTXODAG.

func (*SigLockedSingleOutput) Input

func (s *SigLockedSingleOutput) Input() Input

Input returns an Input that references the Output.

func (*SigLockedSingleOutput) ObjectStorageKey

func (s *SigLockedSingleOutput) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*SigLockedSingleOutput) ObjectStorageValue

func (s *SigLockedSingleOutput) ObjectStorageValue() []byte

ObjectStorageValue marshals the Output into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.

func (*SigLockedSingleOutput) SetID

func (s *SigLockedSingleOutput) SetID(outputID OutputID) Output

SetID allows to set the identifier of the Output. We offer a setter for the property since Outputs that are created to become part of a transaction usually do not have an identifier, yet as their identifier depends on the TransactionID that is only determinable after the Transaction has been fully constructed. The ID is therefore only accessed when the Output is supposed to be persisted by the node.

func (*SigLockedSingleOutput) String

func (s *SigLockedSingleOutput) String() string

String returns a human readable version of the Output.

func (*SigLockedSingleOutput) Type

Type returns the type of the Output which allows us to generically handle Outputs of different types.

func (*SigLockedSingleOutput) UnlockValid

func (s *SigLockedSingleOutput) UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (unlockValid bool, err error)

UnlockValid determines if the given Transaction and the corresponding UnlockBlock are allowed to spend the Output.

func (*SigLockedSingleOutput) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

func (*SigLockedSingleOutput) UpdateMintingColor added in v0.6.0

func (s *SigLockedSingleOutput) UpdateMintingColor() Output

UpdateMintingColor does nothing for SigLockedSingleOutput

type Signature

type Signature interface {
	// Type returns the SignatureType of this Signature.
	Type() SignatureType

	// SignatureValid returns true if the Signature signs the given data.
	SignatureValid(data []byte) bool

	// AddressSignatureValid returns true if the Signature signs the given Address.
	AddressSignatureValid(address Address, data []byte) bool

	// Bytes returns a marshaled version of the Signature.
	Bytes() []byte

	// Base58 returns a base58 encoded version of the Signature.
	Base58() string

	// String returns a human readable version of the Signature.
	String() string
}

Signature is an interface for the different kinds of Signatures that are supported by the ledger state.

func SignatureFromBase58EncodedString

func SignatureFromBase58EncodedString(base58String string) (signature Signature, err error)

SignatureFromBase58EncodedString creates a Signature from a base58 encoded string.

func SignatureFromBytes

func SignatureFromBytes(bytes []byte) (signature Signature, consumedBytes int, err error)

SignatureFromBytes unmarshals a Signature from a sequence of bytes.

func SignatureFromMarshalUtil

func SignatureFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (signature Signature, err error)

SignatureFromMarshalUtil unmarshals a Signature using a MarshalUtil (for easier unmarshaling).

type SignatureType

type SignatureType uint8

SignatureType represents the type of the signature scheme.

const (
	// ED25519SignatureType represents an ED25519 Signature.
	ED25519SignatureType SignatureType = iota

	// BLSSignatureType represents a BLS Signature.
	BLSSignatureType
)

func (SignatureType) String

func (s SignatureType) String() string

String returns a human readable representation of the SignatureType.

type SignatureUnlockBlock

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

SignatureUnlockBlock represents an UnlockBlock that contains a Signature for an Address.

func NewSignatureUnlockBlock

func NewSignatureUnlockBlock(signature Signature) *SignatureUnlockBlock

NewSignatureUnlockBlock is the constructor for SignatureUnlockBlock objects.

func SignatureUnlockBlockFromBytes

func SignatureUnlockBlockFromBytes(bytes []byte) (unlockBlock *SignatureUnlockBlock, consumedBytes int, err error)

SignatureUnlockBlockFromBytes unmarshals a SignatureUnlockBlock from a sequence of bytes.

func SignatureUnlockBlockFromMarshalUtil

func SignatureUnlockBlockFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (unlockBlock *SignatureUnlockBlock, err error)

SignatureUnlockBlockFromMarshalUtil unmarshals a SignatureUnlockBlock using a MarshalUtil (for easier unmarshaling).

func (*SignatureUnlockBlock) AddressSignatureValid

func (s *SignatureUnlockBlock) AddressSignatureValid(address Address, signedData []byte) bool

AddressSignatureValid returns true if the UnlockBlock correctly signs the given Address.

func (*SignatureUnlockBlock) Bytes

func (s *SignatureUnlockBlock) Bytes() []byte

Bytes returns a marshaled version of the UnlockBlock.

func (*SignatureUnlockBlock) Signature added in v0.6.0

func (s *SignatureUnlockBlock) Signature() Signature

Signature return the signature itself

func (*SignatureUnlockBlock) String

func (s *SignatureUnlockBlock) String() string

String returns a human readable version of the UnlockBlock.

func (*SignatureUnlockBlock) Type

Type returns the UnlockBlockType of the UnlockBlock.

type Snapshot added in v0.4.0

type Snapshot struct {
	Transactions     map[TransactionID]Record
	AccessManaByNode map[identity.ID]AccessMana
}

Snapshot defines a snapshot of the ledger state.

func (*Snapshot) ReadFrom added in v0.4.0

func (s *Snapshot) ReadFrom(reader io.Reader) (int64, error)

ReadFrom reads the snapshot bytes from the given reader. This function overrides existing content of the snapshot.

func (*Snapshot) WriteTo added in v0.4.0

func (s *Snapshot) WriteTo(writer io.Writer) (int64, error)

WriteTo writes the snapshot data to the given writer.

type Transaction

type Transaction struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

Transaction represents a payload that executes a value transfer in the ledger state.

func NewTransaction

func NewTransaction(essence *TransactionEssence, unlockBlocks UnlockBlocks) (transaction *Transaction)

NewTransaction creates a new Transaction from the given details.

func TransactionFromBytes

func TransactionFromBytes(bytes []byte) (transaction *Transaction, consumedBytes int, err error)

TransactionFromBytes unmarshals a Transaction from a sequence of bytes.

func TransactionFromMarshalUtil

func TransactionFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (transaction *Transaction, err error)

TransactionFromMarshalUtil unmarshals a Transaction using a MarshalUtil (for easier unmarshaling).

func (*Transaction) Bytes

func (t *Transaction) Bytes() []byte

Bytes returns a marshaled version of the Transaction.

func (*Transaction) Essence

func (t *Transaction) Essence() *TransactionEssence

Essence returns the TransactionEssence of the Transaction.

func (*Transaction) ID

func (t *Transaction) ID() TransactionID

ID returns the identifier of the Transaction. Since calculating the TransactionID is a resource intensive operation we calculate this value lazy and use double checked locking.

func (*Transaction) ObjectStorageKey

func (t *Transaction) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*Transaction) ObjectStorageValue

func (t *Transaction) ObjectStorageValue() []byte

ObjectStorageValue marshals the Transaction into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.

func (*Transaction) ReferencedTransactionIDs

func (t *Transaction) ReferencedTransactionIDs() (referencedTransactionIDs TransactionIDs)

ReferencedTransactionIDs returns a set of TransactionIDs whose Outputs were used as Inputs in this Transaction.

func (*Transaction) String

func (t *Transaction) String() string

String returns a human readable version of the Transaction.

func (*Transaction) Type

func (t *Transaction) Type() payload.Type

Type returns the Type of the Payload.

func (*Transaction) UnlockBlocks

func (t *Transaction) UnlockBlocks() UnlockBlocks

UnlockBlocks returns the UnlockBlocks of the Transaction.

func (*Transaction) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type TransactionEssence

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

TransactionEssence contains the transfer related information of the Transaction (without the unlocking details).

func NewTransactionEssence

func NewTransactionEssence(
	version TransactionEssenceVersion,
	timestamp time.Time,
	accessPledgeID identity.ID,
	consensusPledgeID identity.ID,
	inputs Inputs,
	outputs Outputs,
) *TransactionEssence

NewTransactionEssence creates a new TransactionEssence from the given details.

func TransactionEssenceFromBytes

func TransactionEssenceFromBytes(bytes []byte) (transactionEssence *TransactionEssence, consumedBytes int, err error)

TransactionEssenceFromBytes unmarshals a TransactionEssence from a sequence of bytes.

func TransactionEssenceFromMarshalUtil

func TransactionEssenceFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (transactionEssence *TransactionEssence, err error)

TransactionEssenceFromMarshalUtil unmarshals a TransactionEssence using a MarshalUtil (for easier unmarshaling).

func (*TransactionEssence) AccessPledgeID

func (t *TransactionEssence) AccessPledgeID() identity.ID

AccessPledgeID returns the access mana pledge nodeID of the TransactionEssence.

func (*TransactionEssence) Bytes

func (t *TransactionEssence) Bytes() []byte

Bytes returns a marshaled version of the TransactionEssence.

func (*TransactionEssence) ConsensusPledgeID

func (t *TransactionEssence) ConsensusPledgeID() identity.ID

ConsensusPledgeID returns the consensus mana pledge nodeID of the TransactionEssence.

func (*TransactionEssence) Inputs

func (t *TransactionEssence) Inputs() Inputs

Inputs returns the Inputs of the TransactionEssence.

func (*TransactionEssence) Outputs

func (t *TransactionEssence) Outputs() Outputs

Outputs returns the Outputs of the TransactionEssence.

func (*TransactionEssence) Payload

func (t *TransactionEssence) Payload() payload.Payload

Payload returns the optional Payload of the TransactionEssence.

func (*TransactionEssence) SetPayload added in v0.4.0

func (t *TransactionEssence) SetPayload(p payload.Payload)

SetPayload set the optional Payload of the TransactionEssence.

func (*TransactionEssence) String

func (t *TransactionEssence) String() string

String returns a human readable version of the TransactionEssence.

func (*TransactionEssence) Timestamp

func (t *TransactionEssence) Timestamp() time.Time

Timestamp returns the timestamp of the TransactionEssence.

func (*TransactionEssence) Version added in v0.4.0

Version returns the Version of the TransactionEssence.

type TransactionEssenceVersion

type TransactionEssenceVersion uint8

TransactionEssenceVersion represents a version number for the TransactionEssence which can be used to ensure backward compatibility if the structure ever needs to get changed.

func TransactionEssenceVersionFromBytes

func TransactionEssenceVersionFromBytes(bytes []byte) (version TransactionEssenceVersion, consumedBytes int, err error)

TransactionEssenceVersionFromBytes unmarshals a TransactionEssenceVersion from a sequence of bytes.

func TransactionEssenceVersionFromMarshalUtil

func TransactionEssenceVersionFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (version TransactionEssenceVersion, err error)

TransactionEssenceVersionFromMarshalUtil unmarshals a TransactionEssenceVersion using a MarshalUtil (for easier unmarshaling).

func (TransactionEssenceVersion) Bytes

func (t TransactionEssenceVersion) Bytes() []byte

Bytes returns a marshaled version of the TransactionEssenceVersion.

func (TransactionEssenceVersion) Compare

Compare offers a comparator for TransactionEssenceVersions which returns -1 if the other TransactionEssenceVersion is bigger, 1 if it is smaller and 0 if they are the same.

func (TransactionEssenceVersion) String

func (t TransactionEssenceVersion) String() string

String returns a human readable version of the TransactionEssenceVersion.

type TransactionID

type TransactionID [TransactionIDLength]byte

TransactionID is the type that represents the identifier of a Transaction.

var GenesisTransactionID TransactionID

GenesisTransactionID represents the identifier of the genesis Transaction.

func TransactionIDFromBase58

func TransactionIDFromBase58(base58String string) (transactionID TransactionID, err error)

TransactionIDFromBase58 creates a TransactionID from a base58 encoded string.

func TransactionIDFromBytes

func TransactionIDFromBytes(bytes []byte) (transactionID TransactionID, consumedBytes int, err error)

TransactionIDFromBytes unmarshals a TransactionID from a sequence of bytes.

func TransactionIDFromMarshalUtil

func TransactionIDFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (transactionID TransactionID, err error)

TransactionIDFromMarshalUtil unmarshals a TransactionID using a MarshalUtil (for easier unmarshaling).

func TransactionIDFromRandomness

func TransactionIDFromRandomness() (transactionID TransactionID, err error)

TransactionIDFromRandomness returns a random TransactionID which can for example be used in unit tests.

func (TransactionID) Base58

func (i TransactionID) Base58() string

Base58 returns a base58 encoded version of the TransactionID.

func (TransactionID) Bytes

func (i TransactionID) Bytes() []byte

Bytes returns a marshaled version of the TransactionID.

func (TransactionID) String

func (i TransactionID) String() string

String creates a human readable version of the TransactionID.

type TransactionIDs

type TransactionIDs map[TransactionID]types.Empty

TransactionIDs represents a collection of TransactionIDs.

func (TransactionIDs) Base58s added in v0.5.7

func (t TransactionIDs) Base58s() (transactionIDs []string)

Base58s returns a slice of base58 encoded versions of the contained TransactionIDs.

func (TransactionIDs) Clone added in v0.4.1

func (t TransactionIDs) Clone() (transactionIDs TransactionIDs)

Clone returns a copy of the collection of TransactionIDs.

func (TransactionIDs) String added in v0.5.7

func (t TransactionIDs) String() (result string)

String returns a human readable version of the TransactionIDs.

type TransactionMetadata

type TransactionMetadata struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

TransactionMetadata contains additional information about a Transaction that is derived from the local perception of a node.

func NewTransactionMetadata

func NewTransactionMetadata(transactionID TransactionID) *TransactionMetadata

NewTransactionMetadata creates a new empty TransactionMetadata object.

func TransactionMetadataFromBytes

func TransactionMetadataFromBytes(bytes []byte) (transactionMetadata *TransactionMetadata, consumedBytes int, err error)

TransactionMetadataFromBytes unmarshals an TransactionMetadata object from a sequence of bytes.

func TransactionMetadataFromMarshalUtil

func TransactionMetadataFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (transactionMetadata *TransactionMetadata, err error)

TransactionMetadataFromMarshalUtil unmarshals an TransactionMetadata object using a MarshalUtil (for easier unmarshaling).

func (*TransactionMetadata) BranchID

func (t *TransactionMetadata) BranchID() BranchID

BranchID returns the identifier of the Branch that the Transaction was booked in.

func (*TransactionMetadata) Bytes

func (t *TransactionMetadata) Bytes() []byte

Bytes marshals the TransactionMetadata into a sequence of bytes.

func (*TransactionMetadata) Finalized

func (t *TransactionMetadata) Finalized() (finalized bool)

Finalized returns a boolean flag that indicates if the Transaction has been finalized regarding its decision of being included in the ledger state.

func (*TransactionMetadata) ID

ID returns the TransactionID of the Transaction that the TransactionMetadata belongs to.

func (*TransactionMetadata) LazyBooked

func (t *TransactionMetadata) LazyBooked() (lazyBooked bool)

LazyBooked returns a boolean flag that indicates if the Transaction has been analyzed regarding the conflicting status of its consumed Branches.

func (*TransactionMetadata) ObjectStorageKey

func (t *TransactionMetadata) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*TransactionMetadata) ObjectStorageValue

func (t *TransactionMetadata) ObjectStorageValue() []byte

ObjectStorageValue marshals the TransactionMetadata into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.

func (*TransactionMetadata) SetBranchID

func (t *TransactionMetadata) SetBranchID(branchID BranchID) (modified bool)

SetBranchID sets the identifier of the Branch that the Transaction was booked in.

func (*TransactionMetadata) SetFinalized

func (t *TransactionMetadata) SetFinalized(finalized bool) (modified bool)

SetFinalized updates the finalized flag of the Transaction. It returns true if the value was modified.

func (*TransactionMetadata) SetLazyBooked

func (t *TransactionMetadata) SetLazyBooked(lazyBooked bool) (modified bool)

SetLazyBooked updates the lazy booked flag of the Output. It returns true if the value was modified.

func (*TransactionMetadata) SetSolid

func (t *TransactionMetadata) SetSolid(solid bool) (modified bool)

SetSolid updates the solid flag of the Transaction. It returns true if the solid flag was modified and updates the solidification time if the Transaction was marked as solid.

func (*TransactionMetadata) Solid

func (t *TransactionMetadata) Solid() bool

Solid returns true if the Transaction has been marked as solid.

func (*TransactionMetadata) SolidificationTime

func (t *TransactionMetadata) SolidificationTime() time.Time

SolidificationTime returns the time when the Transaction was marked as solid.

func (*TransactionMetadata) String

func (t *TransactionMetadata) String() string

String returns a human readable version of the TransactionMetadata.

func (*TransactionMetadata) Update

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type UTXODAG

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

UTXODAG represents the DAG that is formed by Transactions consuming Inputs and creating Outputs. It forms the core of the ledger state and keeps track of the balances and the different perceptions of potential conflicts.

func NewUTXODAG

func NewUTXODAG(store kvstore.KVStore, cacheProvider *database.CacheTimeProvider, branchDAG *BranchDAG) (utxoDAG *UTXODAG)

NewUTXODAG create a new UTXODAG from the given details.

func (*UTXODAG) BookTransaction

func (u *UTXODAG) BookTransaction(transaction *Transaction) (targetBranch BranchID, err error)

BookTransaction books a Transaction into the ledger state.

func (*UTXODAG) CachedAddressOutputMapping added in v0.6.2

func (u *UTXODAG) CachedAddressOutputMapping(address Address) (cachedAddressOutputMappings CachedAddressOutputMappings)

CachedAddressOutputMapping retrieves the outputs for the given address.

func (*UTXODAG) CachedConsumers added in v0.6.2

func (u *UTXODAG) CachedConsumers(outputID OutputID) (cachedConsumers CachedConsumers)

CachedConsumers retrieves the Consumers of the given OutputID from the object storage.

func (*UTXODAG) CachedOutput added in v0.6.2

func (u *UTXODAG) CachedOutput(outputID OutputID) (cachedOutput *CachedOutput)

CachedOutput retrieves the Output with the given OutputID from the object storage.

func (*UTXODAG) CachedOutputMetadata added in v0.6.2

func (u *UTXODAG) CachedOutputMetadata(outputID OutputID) (cachedOutput *CachedOutputMetadata)

CachedOutputMetadata retrieves the OutputMetadata with the given OutputID from the object storage.

func (*UTXODAG) CachedTransaction added in v0.6.2

func (u *UTXODAG) CachedTransaction(transactionID TransactionID) (cachedTransaction *CachedTransaction)

CachedTransaction retrieves the Transaction with the given TransactionID from the object storage.

func (*UTXODAG) CachedTransactionMetadata added in v0.6.2

func (u *UTXODAG) CachedTransactionMetadata(transactionID TransactionID) (cachedTransactionMetadata *CachedTransactionMetadata)

CachedTransactionMetadata retrieves the TransactionMetadata with the given TransactionID from the object storage.

func (*UTXODAG) CheckTransaction

func (u *UTXODAG) CheckTransaction(transaction *Transaction) (err error)

CheckTransaction contains fast checks that have to be performed before booking a Transaction.

func (*UTXODAG) ConsumedOutputs added in v0.4.1

func (u *UTXODAG) ConsumedOutputs(transaction *Transaction) (cachedInputs CachedOutputs)

ConsumedOutputs returns the consumed (cached)Outputs of the given Transaction.

func (*UTXODAG) Events

func (u *UTXODAG) Events() *UTXODAGEvents

Events returns all events of the UTXODAG

func (*UTXODAG) InclusionState

func (u *UTXODAG) InclusionState(transactionID TransactionID) (inclusionState InclusionState, err error)

InclusionState returns the InclusionState of the Transaction with the given TransactionID which can either be Pending, Confirmed or Rejected.

func (*UTXODAG) LoadSnapshot

func (u *UTXODAG) LoadSnapshot(snapshot *Snapshot)

LoadSnapshot creates a set of outputs in the UTXO-DAG, that are forming the genesis for future transactions.

func (*UTXODAG) ManageStoreAddressOutputMapping added in v0.6.2

func (u *UTXODAG) ManageStoreAddressOutputMapping(output Output)

ManageStoreAddressOutputMapping mangages how to store the address-output mapping dependent on which type of output it is.

func (*UTXODAG) SetTransactionConfirmed added in v0.5.8

func (u *UTXODAG) SetTransactionConfirmed(transactionID TransactionID) (err error)

SetTransactionConfirmed marks a Transaction (and all Transactions in its past cone) as confirmed. It also marks the conflicting Transactions to be rejected.

func (*UTXODAG) Shutdown

func (u *UTXODAG) Shutdown()

Shutdown shuts down the UTXODAG and persists its state.

func (*UTXODAG) StoreAddressOutputMapping added in v0.4.0

func (u *UTXODAG) StoreAddressOutputMapping(address Address, outputID OutputID)

StoreAddressOutputMapping stores the address-output mapping.

func (*UTXODAG) Transaction

func (u *UTXODAG) Transaction(transactionID TransactionID) (transaction *Transaction)

Transaction returns a specific transaction, consumed.

func (*UTXODAG) Transactions added in v0.6.2

func (u *UTXODAG) Transactions() (transactions map[TransactionID]*Transaction)

Transactions returns all the transactions, consumed.

type UTXODAGEvents

type UTXODAGEvents struct {
	// TransactionBranchIDUpdated gets triggered when the BranchID of a Transaction is changed after the initial booking.
	TransactionBranchIDUpdated *events.Event
	// Fired when a transaction gets confirmed.
	TransactionConfirmed *events.Event
}

UTXODAGEvents is a container for all of the UTXODAG related events.

type UTXOInput

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

UTXOInput represents a reference to an Output in the UTXODAG.

func NewUTXOInput

func NewUTXOInput(referencedOutputID OutputID) *UTXOInput

NewUTXOInput is the constructor for UTXOInputs.

func UTXOInputFromMarshalUtil

func UTXOInputFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (input *UTXOInput, err error)

UTXOInputFromMarshalUtil unmarshals a UTXOInput using a MarshalUtil (for easier unmarshaling).

func (*UTXOInput) Base58 added in v0.4.0

func (u *UTXOInput) Base58() string

Base58 returns the base58 encoded referenced output ID of this input.

func (*UTXOInput) Bytes

func (u *UTXOInput) Bytes() []byte

Bytes returns a marshaled version of the Input.

func (*UTXOInput) Compare

func (u *UTXOInput) Compare(other Input) int

Compare offers a comparator for Inputs which returns -1 if other Input is bigger, 1 if it is smaller and 0 if they are the same.

func (*UTXOInput) ReferencedOutputID

func (u *UTXOInput) ReferencedOutputID() OutputID

ReferencedOutputID returns the OutputID that this Input references.

func (*UTXOInput) String

func (u *UTXOInput) String() string

String returns a human readable version of the Input.

func (*UTXOInput) Type

func (u *UTXOInput) Type() InputType

Type returns the type of the Input.

type UnlockBlock

type UnlockBlock interface {
	// Type returns the UnlockBlockType of the UnlockBlock.
	Type() UnlockBlockType

	// Bytes returns a marshaled version of the UnlockBlock.
	Bytes() []byte

	// String returns a human readable version of the UnlockBlock.
	String() string
}

UnlockBlock represents a generic interface to address the different kinds of unlock information that are required to authorize the spending of different Output types.

func UnlockBlockFromBytes

func UnlockBlockFromBytes(bytes []byte) (unlockBlock UnlockBlock, consumedBytes int, err error)

UnlockBlockFromBytes unmarshals an UnlockBlock from a sequence of bytes.

func UnlockBlockFromMarshalUtil

func UnlockBlockFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (unlockBlock UnlockBlock, err error)

UnlockBlockFromMarshalUtil unmarshals an UnlockBlock using a MarshalUtil (for easier unmarshaling).

type UnlockBlockType

type UnlockBlockType uint8

UnlockBlockType represents the type of the UnlockBlock. Different types of UnlockBlocks can unlock different types of Outputs.

const (
	// SignatureUnlockBlockType represents the type of a SignatureUnlockBlock.
	SignatureUnlockBlockType UnlockBlockType = iota

	// ReferenceUnlockBlockType represents the type of a ReferenceUnlockBlock.
	ReferenceUnlockBlockType

	// AliasUnlockBlockType represents the type of a AliasUnlockBlock
	AliasUnlockBlockType
)

func (UnlockBlockType) String

func (a UnlockBlockType) String() string

String returns a human readable representation of the UnlockBlockType.

type UnlockBlocks

type UnlockBlocks []UnlockBlock

UnlockBlocks is slice of UnlockBlocks that offers additional methods for easier marshaling and unmarshaling.

func UnlockBlocksFromBytes

func UnlockBlocksFromBytes(bytes []byte) (unlockBlocks UnlockBlocks, consumedBytes int, err error)

UnlockBlocksFromBytes unmarshals UnlockBlocks from a sequence of bytes.

func UnlockBlocksFromMarshalUtil

func UnlockBlocksFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (unlockBlocks UnlockBlocks, err error)

UnlockBlocksFromMarshalUtil unmarshals UnlockBlocks using a MarshalUtil (for easier unmarshaling).

func (UnlockBlocks) Bytes

func (u UnlockBlocks) Bytes() []byte

Bytes returns a marshaled version of the UnlockBlocks.

func (UnlockBlocks) String

func (u UnlockBlocks) String() string

String returns a human readable version of the UnlockBlocks.

type UnlockGraph added in v0.6.0

type UnlockGraph struct {
	// Vertices are the unlock blocks themselves, identified by their index
	// uint16 is enough
	Vertices []uint16
	// maps unlockBlock to referenced unlocked block
	// each vertex has at most 1 referenced unlock block, so one outgoing edge
	Edges map[uint16]uint16
}

UnlockGraph builds a graph from the references of the unlock blocks with the aim of detecting cycles.

func NewUnlockGraph added in v0.6.0

func NewUnlockGraph(blocks UnlockBlocks) (*UnlockGraph, error)

NewUnlockGraph creates a new UnlockGraph and checks semantic validity of the unlock block references.

func (*UnlockGraph) IsCycleDetected added in v0.6.0

func (g *UnlockGraph) IsCycleDetected() bool

IsCycleDetected checks if a cycle is detected by checking the dfs paths from every node.

Directories

Path Synopsis
Package utxodb mocks Value Tangle ledger by implementing fully synchronous in-memory database of GoShimmer value transactions.
Package utxodb mocks Value Tangle ledger by implementing fully synchronous in-memory database of GoShimmer value transactions.
Package utxoutil is used to build value transaction Package utxoutil contains number of utility functions useful while manipulating outputs and constructing transactions.
Package utxoutil is used to build value transaction Package utxoutil contains number of utility functions useful while manipulating outputs and constructing transactions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL