ledgerstate

package
v0.8.14 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: Apache-2.0, BSD-2-Clause Imports: 40 Imported by: 0

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, Digest2 length = 32).

View Source
const AliasAddressDigestSize = 32

AliasAddressDigestSize defines the length of the alias address Digest2 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 Branch DAG).
	MasterBranchID = BranchID{1}
)
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")
)

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 object storage.

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 Transaction.

Functions

func AliasInitialStateValid added in v0.7.5

func AliasInitialStateValid(inputs Outputs, transaction *Transaction) bool

AliasInitialStateValid is an internal utility function that checks if aliases are created by the transaction with valid initial states. Initial state of an alias is valid, if and only if:

  • there is no "chained" alias with the same ID on the input side
  • the alias itself has the origin flag set, and state index is 0.

func BranchIDEventHandler added in v0.8.0

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

BranchIDEventHandler is an event handler for an event with a BranchID.

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, value []byte) (output objectstorage.StorableObject, err error)

OutputFromObjectStorage restores an Output 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 SetOutputID added in v0.8.13

func SetOutputID(essence *TransactionEssence, transactionID TransactionID)

SetOutputID assigns TransactionID to all outputs in TransactionEssence

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 TransactionBranchIDUpdatedByForkEventHandler added in v0.8.0

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

TransactionBranchIDUpdatedByForkEventHandler is an event handler for an event with a TransactionBranchIDUpdatedByForkEvent.

func TransactionIDEventHandler added in v0.8.0

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

TransactionIDEventHandler is an event handler for an event with a TransactionID.

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 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 {
	// 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 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) FromBytes added in v0.8.10

func (a *AddressOutputMapping) FromBytes(data []byte) (addressOutputMapping *AddressOutputMapping, err error)

FromBytes unmarshals a AddressOutputMapping from a sequence of bytes.

func (*AddressOutputMapping) FromObjectStorage added in v0.8.10

func (a *AddressOutputMapping) FromObjectStorage(key, _ []byte) (objectstorage.StorableObject, error)

FromObjectStorage creates an TransactionMetadata from sequences of key and 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.

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 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 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 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) Decode added in v0.8.13

func (a *AliasOutput) Decode(data []byte) (bytesRead int, err error)

Decode returns bytes serialized form.

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) Encode added in v0.8.13

func (a *AliasOutput) Encode() ([]byte, error)

Decode returns deserializes object from bytes.

func (*AliasOutput) FromBytes added in v0.8.10

func (a *AliasOutput) FromBytes(data []byte) (output *AliasOutput, err error)

FromBytes unmarshals a ExtendedLockedOutput from a sequence of bytes.

func (*AliasOutput) FromMarshalUtil added in v0.8.10

func (a *AliasOutput) FromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (output *AliasOutput, err error)

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

func (*AliasOutput) FromObjectStorage added in v0.8.10

func (a *AliasOutput) FromObjectStorage(key, value []byte) (objectstorage.StorableObject, error)

FromObjectStorage creates an AliasOutput from sequences of key and bytes.

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 returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

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) 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 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 Address.

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 ArithmeticBranchIDs added in v0.8.6

type ArithmeticBranchIDs map[BranchID]int

ArithmeticBranchIDs represents an arithmetic collection of BranchIDs that allows us to add and subtract them from each other.

func NewArithmeticBranchIDs added in v0.8.6

func NewArithmeticBranchIDs(optionalBranchIDs ...BranchIDs) (newArithmeticBranchIDs ArithmeticBranchIDs)

NewArithmeticBranchIDs returns a new ArithmeticBranchIDs object.

func (ArithmeticBranchIDs) Add added in v0.8.6

func (a ArithmeticBranchIDs) Add(branchIDs BranchIDs)

Add adds all BranchIDs to the collection.

func (ArithmeticBranchIDs) BranchIDs added in v0.8.6

func (a ArithmeticBranchIDs) BranchIDs() (branchIDs BranchIDs)

BranchIDs returns the BranchIDs represented by this collection.

func (ArithmeticBranchIDs) String added in v0.8.6

func (a ArithmeticBranchIDs) String() string

String returns a human-readable version of the ArithmeticBranchIDs.

func (ArithmeticBranchIDs) Subtract added in v0.8.6

func (a ArithmeticBranchIDs) Subtract(branchIDs BranchIDs)

Subtract subtracts all BranchIDs from the collection.

type BLSAddress

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

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

func BLSAddressFromBytes

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

BLSAddressFromBytes unmarshals an BLSAddress from a sequence of bytes.

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 `serix:"0"`
}

BLSSignature represents a Signature created with the BLS signature scheme.

func BLSSignatureFromBytes

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

BLSSignatureFromBytes unmarshals a BLSSignature from a sequence of bytes.

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 struct {
	// contains filtered or unexported fields
}

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

func NewBranch added in v0.8.10

func NewBranch(id BranchID, parents BranchIDs, conflicts ConflictIDs) *Branch

NewBranch creates a new Branch from the given details.

func (*Branch) AddConflict added in v0.8.10

func (b *Branch) AddConflict(conflictID ConflictID) (added bool)

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

func (*Branch) Bytes

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

Bytes returns a marshaled version of the Branch.

func (*Branch) Conflicts added in v0.8.10

func (b *Branch) Conflicts() (conflicts ConflictIDs)

Conflicts returns the Conflicts that the Branch is part of.

func (*Branch) FromBytes added in v0.8.10

func (b *Branch) FromBytes(data []byte) (branch *Branch, err error)

FromBytes unmarshals an Branch from a sequence of bytes.

func (*Branch) FromObjectStorage added in v0.8.10

func (b *Branch) FromObjectStorage(key, value []byte) (conflictBranch objectstorage.StorableObject, err error)

FromObjectStorage creates an Branch from sequences of key and bytes.

func (*Branch) ID

func (b *Branch) ID() BranchID

ID returns the identifier of the Branch.

func (*Branch) InclusionState

func (b *Branch) InclusionState() (inclusionState InclusionState)

InclusionState returns the InclusionState of the Branch.

func (*Branch) ObjectStorageKey added in v0.8.10

func (b *Branch) 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 (*Branch) ObjectStorageValue added in v0.8.10

func (b *Branch) ObjectStorageValue() []byte

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

func (*Branch) Parents

func (b *Branch) Parents() BranchIDs

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

func (*Branch) SetParents added in v0.8.10

func (b *Branch) SetParents(parentBranches BranchIDs) (modified bool)

SetParents updates the parents of the Branch.

func (*Branch) String

func (b *Branch) String() string

String returns a human-readable version of the Branch.

type BranchDAG

type BranchDAG struct {
	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(ledgerstate *Ledgerstate) (newBranchDAG *BranchDAG)

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

func (*BranchDAG) AddBranchParent added in v0.8.10

func (b *BranchDAG) AddBranchParent(branchID, newParentBranchID BranchID) (err error)

AddBranchParent changes the parents of a Branch (also updating the references of the ChildBranches).

func (*BranchDAG) Branch

func (b *BranchDAG) Branch(branchID BranchID, computeIfAbsentCallback ...func() *Branch) (cachedBranch *objectstorage.CachedObject[*Branch])

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

func (*BranchDAG) ChildBranches

func (b *BranchDAG) ChildBranches(branchID BranchID) (cachedChildBranches objectstorage.CachedObjects[*ChildBranch])

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

func (*BranchDAG) Conflict

func (b *BranchDAG) Conflict(conflictID ConflictID) *objectstorage.CachedObject[*Conflict]

Conflict loads a Conflict from the object storage.

func (*BranchDAG) ConflictMembers

func (b *BranchDAG) ConflictMembers(conflictID ConflictID) (cachedConflictMembers objectstorage.CachedObjects[*ConflictMember])

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

func (*BranchDAG) CreateBranch added in v0.8.10

func (b *BranchDAG) CreateBranch(branchID BranchID, parentBranchIDs BranchIDs, conflictIDs ConflictIDs) (cachedBranch *objectstorage.CachedObject[*Branch], newBranchCreated bool, err error)

CreateBranch retrieves the Branch that corresponds to the given details. It automatically creates and updates the Branch 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 the branches and executes consumer.

func (*BranchDAG) ForEachConflictingBranchID added in v0.5.7

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

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

func (*BranchDAG) ForEachConnectedConflictingBranchID added in v0.8.6

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

ForEachConnectedConflictingBranchID executes the callback for each Branch that is connected through a chain of intersecting ConflictSets.

func (*BranchDAG) InclusionState added in v0.5.7

func (b *BranchDAG) InclusionState(branchIDs BranchIDs) (inclusionState InclusionState)

InclusionState returns the InclusionState of the given BranchIDs.

func (*BranchDAG) Prune

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

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

func (*BranchDAG) ResolvePendingBranchIDs added in v0.8.10

func (b *BranchDAG) ResolvePendingBranchIDs(branchIDs BranchIDs) (pendingBranchIDs BranchIDs, err error)

ResolvePendingBranchIDs returns the BranchIDs of the pending and rejected Branches that are addressed by the given BranchIDs.

func (*BranchDAG) SetBranchConfirmed added in v0.5.8

func (b *BranchDAG) SetBranchConfirmed(branchID BranchID) (modified bool)

SetBranchConfirmed sets the InclusionState of the given Branch to be Confirmed.

func (*BranchDAG) Shutdown

func (b *BranchDAG) Shutdown()

Shutdown shuts down the BranchDAG and persists its state.

type BranchDAGEvents

type BranchDAGEvents struct {
	// BranchCreated gets triggered when a new Branch is created.
	BranchCreated *events.Event

	// BranchParentsUpdated gets triggered whenever a Branch's parents are updated.
	BranchParentsUpdated *events.Event
}

type BranchID

type BranchID [BranchIDLength]byte

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

func BranchIDFromBase58

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

BranchIDFromBase58 creates a BranchID from a base58 encoded string.

func BranchIDFromBytes

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

BranchIDFromBytes unmarshals a BranchID from a sequence of bytes.

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 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) AddAll added in v0.8.0

func (b BranchIDs) AddAll(branchIDs BranchIDs) BranchIDs

AddAll adds all BranchIDs to the collection and returns the collection to enable chaining.

func (BranchIDs) Base58 added in v0.8.6

func (b BranchIDs) Base58() (result []string)

Base58 returns a slice of base58 BranchIDs.

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) Equals added in v0.8.10

func (b BranchIDs) Equals(o BranchIDs) bool

Equals returns whether the BranchIDs and other BranchIDs are equal.

func (BranchIDs) Intersect added in v0.8.0

func (b BranchIDs) Intersect(branchIDs BranchIDs) (res BranchIDs)

Intersect removes all BranchIDs from the collection that are not contained in the argument collection. It returns the collection to enable chaining.

func (BranchIDs) Is added in v0.8.10

func (b BranchIDs) Is(targetBranch BranchID) (is bool)

Is checks if the given target BranchID is the only BranchID within 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.

func (BranchIDs) Subtract added in v0.8.0

func (b BranchIDs) Subtract(other BranchIDs) BranchIDs

Subtract removes all other from the collection and returns the collection to enable chaining.

type BranchParentUpdate added in v0.8.6

type BranchParentUpdate struct {
	ID         BranchID
	NewParents BranchIDs
}

BranchParentUpdate contains the new branch parents of a branch.

type ChildBranch

type ChildBranch struct {
	// 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 NewChildBranch

func NewChildBranch(parentBranchID, childBranchID BranchID) *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) FromBytes added in v0.8.10

func (c *ChildBranch) FromBytes(data []byte) (childBranch *ChildBranch, err error)

FromBytes unmarshals a ChildBranch from a sequence of bytes.

func (*ChildBranch) FromObjectStorage added in v0.8.10

func (c *ChildBranch) FromObjectStorage(key, value []byte) (childBranch objectstorage.StorableObject, err error)

FromObjectStorage creates an ChildBranch from sequences of key and bytes.

func (*ChildBranch) ObjectStorageKey

func (c *ChildBranch) 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() []byte

ObjectStorageValue marshals the Branch 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.

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(data []byte) (color Color, consumedBytes int, err error)

ColorFromBytes unmarshals a Color from a sequence of bytes.

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 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 Marker.

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 {
	// contains filtered or unexported fields
}

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

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) FromBytes added in v0.8.10

func (c *Conflict) FromBytes(data []byte) (conflict *Conflict, err error)

FromBytes unmarshals a Conflict from a sequence of bytes.

func (*Conflict) FromObjectStorage added in v0.8.10

func (c *Conflict) FromObjectStorage(key, value []byte) (conflict objectstorage.StorableObject, err error)

FromObjectStorage creates a Conflict from sequences of key and bytes.

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 that are used as the value part in the object storage.

func (*Conflict) String

func (c *Conflict) String() string

String returns a human readable version of the Conflict.

type ConflictID

type ConflictID [ConflictIDLength]byte

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

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 NewConflictIDs

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

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

func (ConflictIDs) Add added in v0.8.0

func (c ConflictIDs) Add(conflictID ConflictID) ConflictIDs

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

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 {
	// 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 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) FromBytes added in v0.8.10

func (c *ConflictMember) FromBytes(data []byte) (conflictMember *ConflictMember, err error)

FromBytes unmarshals a ConflictMember from a sequence of bytes.

func (*ConflictMember) FromObjectStorage added in v0.8.10

func (c *ConflictMember) FromObjectStorage(key, value []byte) (conflictMember objectstorage.StorableObject, err error)

FromObjectStorage creates an ConflictMember from sequences of key and bytes.

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.

type Consumer

type Consumer struct {
	// 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 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) FromBytes added in v0.8.10

func (c *Consumer) FromBytes(data []byte) (consumer *Consumer, err error)

FromBytes creates an Consumer from sequences of bytes.

func (*Consumer) FromObjectStorage added in v0.8.10

func (c *Consumer) FromObjectStorage(key, value []byte) (objectstorage.StorableObject, error)

FromObjectStorage creates an Consumer from sequences of key and bytes.

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) 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 ED25519AddressFromBytes

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

ED25519AddressFromBytes unmarshals an ED25519Address from a sequence of bytes.

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 `serix:"0"`
	Signature ed25519.Signature `serix:"1"`
}

ED25519Signature represents a Signature created with the ed25519 signature scheme.

func ED25519SignatureFromBytes

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

ED25519SignatureFromBytes unmarshals a ED25519Signature from a sequence of bytes.

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 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) Decode added in v0.8.13

func (o *ExtendedLockedOutput) Decode(data []byte) (bytesRead int, err error)

Decode returns deserializes object from bytes.

func (*ExtendedLockedOutput) Encode added in v0.8.13

func (o *ExtendedLockedOutput) Encode() ([]byte, error)

Encode returns a binary-encoded version of the Output.

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) FromBytes added in v0.8.10

func (o *ExtendedLockedOutput) FromBytes(data []byte) (output *ExtendedLockedOutput, err error)

FromBytes unmarshals a ExtendedLockedOutput from a sequence of bytes.

func (*ExtendedLockedOutput) FromMarshalUtil added in v0.8.10

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

FromMarshalUtil unmarshals a ExtendedLockedOutput using a MarshalUtil (for easier unmarshalling).

func (*ExtendedLockedOutput) FromObjectStorage added in v0.8.10

func (o *ExtendedLockedOutput) FromObjectStorage(key, value []byte) (objectstorage.StorableObject, error)

FromObjectStorage creates an ExtendedLockedOutput from sequences of key and bytes.

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) 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)
	// CachedTransaction retrieves the Transaction with the given TransactionID from the object storage.
	CachedTransaction(transactionID TransactionID) (cachedTransaction *objectstorage.CachedObject[*Transaction])
	// 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 *objectstorage.CachedObject[*TransactionMetadata])
	// CachedOutput retrieves the Output with the given OutputID from the object storage.
	CachedOutput(outputID OutputID) (cachedOutput *objectstorage.CachedObject[Output])
	// CachedOutputMetadata retrieves the OutputMetadata with the given OutputID from the object storage.
	CachedOutputMetadata(outputID OutputID) (cachedOutput *objectstorage.CachedObject[*OutputMetadata])
	// CachedConsumers retrieves the Consumers of the given OutputID from the object storage.
	CachedConsumers(outputID OutputID) (cachedConsumers *objectstorage.CachedObjects[*Consumer])
	// LoadSnapshot creates a set of outputs in the UTXODAG, that are forming the genesis for future transactions.
	LoadSnapshot(snapshot *Snapshot)
	// CachedAddressOutputMapping retrieves the outputs for the given address.
	CachedAddressOutputMapping(address Address) (cachedAddressOutputMappings *objectstorage.CachedObject[*AddressOutputMapping])
	// ConsumedOutputs returns the consumed (cached)Outputs of the given Transaction.
	ConsumedOutputs(transaction *Transaction) (cachedInputs *objectstorage.CachedObjects[Output])
	// ManageStoreAddressOutputMapping manages 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)
	// TransactionGradeOfFinality returns the GradeOfFinality of the Transaction with the given TransactionID.
	TransactionGradeOfFinality(transactionID TransactionID) (gradeOfFinality gof.GradeOfFinality, err error)
	// BranchGradeOfFinality returns the GradeOfFinality of the Branch with the given BranchID.
	BranchGradeOfFinality(branchID BranchID) (gradeOfFinality gof.GradeOfFinality, err error)
	// ConflictingTransactions returns the TransactionIDs that are conflicting with the given Transaction.
	ConflictingTransactions(transaction *Transaction) (conflictingTransactions TransactionIDs)
}

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 the confirmation status of elements in the ledger.

const (
	// Pending represents elements that have neither been confirmed nor rejected.
	Pending InclusionState = iota

	// Confirmed represents elements that have been confirmed and will stay part of the ledger state forever.
	Confirmed

	// Rejected represents elements that have been rejected and will not be included in the ledger state.
	Rejected
)

func (InclusionState) String

func (i InclusionState) String() string

String returns a human-readable representation 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.

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 NewInputs

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

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

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 Ledgerstate added in v0.8.6

type Ledgerstate struct {
	Options *Options

	*UTXODAG
	*BranchDAG
}

Ledgerstate is a data structure that follows the principles of the quadruple entry accounting.

func New added in v0.8.6

func New(options ...Option) (ledgerstate *Ledgerstate)

New is the constructor for the Ledgerstate.

func (*Ledgerstate) Configure added in v0.8.6

func (l *Ledgerstate) Configure(options ...Option)

Configure modifies the configuration of the Ledgerstate.

func (*Ledgerstate) Shutdown added in v0.8.6

func (l *Ledgerstate) Shutdown()

Shutdown marks the Ledgerstate as stopped, so it will not accept any new Transactions.

type Option added in v0.8.6

type Option func(*Options)

Option represents the return type of optional parameters that can be handed into the constructor of the Ledgerstate to configure its behavior.

func CacheTimeProvider added in v0.8.6

func CacheTimeProvider(cacheTimeProvider *database.CacheTimeProvider) Option

CacheTimeProvider is an Option for the Tangle that allows to override hard coded cache time.

func LazyBookingEnabled added in v0.8.6

func LazyBookingEnabled(enabled bool) Option

LazyBookingEnabled is an Option for the Ledgerstate that allows to specify if the ledger state should lazy book Conflicts that look like they have been decided already.

func Store added in v0.8.6

func Store(store kvstore.KVStore) Option

Store is an Option for the Ledgerstate that allows to specify which storage layer is supposed to be used to persist data.

type Options added in v0.8.6

type Options struct {
	Store              kvstore.KVStore
	CacheTimeProvider  *database.CacheTimeProvider
	LazyBookingEnabled bool
}

Options is a container for all configurable parameters of the Ledgerstate.

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(data []byte) (output Output, err error)

OutputFromBytes restores an Output that was stored in the ObjectStorage.

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(data []byte) (outputID OutputID, consumedBytes int, err error)

OutputIDFromBytes unmarshals an OutputID from a sequence of bytes.

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 {
	// 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 (*OutputMetadata) AddBranchID added in v0.8.10

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

AddBranchID adds an identifier of the Branch that the Output was booked in.

func (*OutputMetadata) BranchIDs added in v0.8.10

func (o *OutputMetadata) BranchIDs() BranchIDs

BranchIDs returns the identifiers of the Branches 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) ConsumerCount

func (o *OutputMetadata) ConsumerCount() int

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

func (*OutputMetadata) FromBytes added in v0.8.10

func (o *OutputMetadata) FromBytes(data []byte) (outputMetadata *OutputMetadata, err error)

FromBytes unmarshals a AddressOutputMapping from a sequence of bytes.

func (*OutputMetadata) FromObjectStorage added in v0.8.10

func (o *OutputMetadata) FromObjectStorage(key, value []byte) (objectstorage.StorableObject, error)

FromObjectStorage creates an OutputMetadata from sequences of key and bytes.

func (*OutputMetadata) GradeOfFinality added in v0.8.0

func (o *OutputMetadata) GradeOfFinality() gof.GradeOfFinality

GradeOfFinality returns the grade of finality.

func (*OutputMetadata) GradeOfFinalityTime added in v0.8.0

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

GradeOfFinalityTime returns the time the Output's gradeOfFinality was set.

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 Branch into a sequence of bytes that are used as the value part in the object storage.

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) SetBranchIDs added in v0.8.10

func (o *OutputMetadata) SetBranchIDs(branchIDs BranchIDs) (modified bool)

SetBranchIDs sets the identifiers of the Branches that the Output was booked in.

func (*OutputMetadata) SetGradeOfFinality added in v0.8.0

func (o *OutputMetadata) SetGradeOfFinality(gradeOfFinality gof.GradeOfFinality) (modified bool)

SetGradeOfFinality updates the grade of finality. It returns true if it 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.

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 (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) SpentOutputsMetadata added in v0.8.6

func (o OutputsMetadata) SpentOutputsMetadata() (spentOutputsMetadata OutputsMetadata)

SpentOutputsMetadata returns the spent elements of the list of OutputsMetadata objects.

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 (*ReferenceUnlockBlock) Bytes

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

Bytes returns a marshaled version of the Address.

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 {
	// 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 (*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) FromBytes added in v0.8.10

func (s *SigLockedColoredOutput) FromBytes(data []byte) (sigLockedColoredOutput *SigLockedColoredOutput, err error)

FromBytes creates an SigLockedColoredOutput from sequence of bytes.

func (*SigLockedColoredOutput) FromObjectStorage added in v0.8.10

func (s *SigLockedColoredOutput) FromObjectStorage(key, value []byte) (sigLockedColoredOutput objectstorage.StorableObject, err error)

FromObjectStorage creates an SigLockedColoredOutput from sequences of key and bytes.

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) 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 {
	// 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 (*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) FromBytes added in v0.8.10

func (s *SigLockedSingleOutput) FromBytes(data []byte) (sigLockedSingleOutput *SigLockedSingleOutput, err error)

FromBytes creates an SigLockedSingleOutput from sequence of bytes.

func (*SigLockedSingleOutput) FromObjectStorage added in v0.8.10

func (s *SigLockedSingleOutput) FromObjectStorage(key, value []byte) (sigLockedSingleOutput objectstorage.StorableObject, err error)

FromObjectStorage creates an SigLockedSingleOutput from sequences of key and bytes.

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) 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(data []byte) (signature Signature, consumedBytes int, err error)

SignatureFromBytes unmarshals a Signature from a sequence of bytes.

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 (*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 {
	// 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 (*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) FromBytes added in v0.8.10

func (t *Transaction) FromBytes(data []byte) (*Transaction, error)

FromBytes unmarshals a Transaction from a sequence of bytes.

func (*Transaction) FromObjectStorage added in v0.8.10

func (t *Transaction) FromObjectStorage(key, value []byte) (objectstorage.StorableObject, error)

FromObjectStorage creates an Transaction from sequences of key and bytes.

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 that are used as the value part in the object storage.

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.

type TransactionBranchIDUpdatedByForkEvent added in v0.8.0

type TransactionBranchIDUpdatedByForkEvent struct {
	TransactionID  TransactionID
	ForkedBranchID BranchID
}

TransactionBranchIDUpdatedByForkEvent is an event that gets triggered, whenever the BranchID of a Transaction is changed.

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(data []byte) (transactionEssence *TransactionEssence, consumedBytes int, err error)

TransactionEssenceFromBytes unmarshals a TransactionEssence from a sequence of bytes.

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 (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 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 {
	// 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 (*TransactionMetadata) AddBranchID added in v0.8.10

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

AddBranchID adds an identifier of the Branch that the Transaction was booked in.

func (*TransactionMetadata) BranchIDs added in v0.8.10

func (t *TransactionMetadata) BranchIDs() BranchIDs

BranchIDs returns the identifiers of the Branches 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) FromBytes added in v0.8.10

func (t *TransactionMetadata) FromBytes(data []byte) (*TransactionMetadata, error)

FromBytes creates an TransactionMetadata from sequences of key and bytes.

func (*TransactionMetadata) FromObjectStorage added in v0.8.10

func (t *TransactionMetadata) FromObjectStorage(key, value []byte) (objectstorage.StorableObject, error)

FromObjectStorage creates an TransactionMetadata from sequences of key and bytes.

func (*TransactionMetadata) GradeOfFinality added in v0.8.0

func (t *TransactionMetadata) GradeOfFinality() gof.GradeOfFinality

GradeOfFinality returns the grade of finality.

func (*TransactionMetadata) GradeOfFinalityTime added in v0.8.0

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

GradeOfFinalityTime returns the time when the Transaction's gradeOfFinality was set.

func (*TransactionMetadata) ID

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

func (*TransactionMetadata) IsConflicting added in v0.8.6

func (t *TransactionMetadata) IsConflicting() bool

IsConflicting returns true if the Transaction is conflicting with another Transaction (has its own Branch).

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 that are used as the value part in the object storage.

func (*TransactionMetadata) SetBranchIDs added in v0.8.10

func (t *TransactionMetadata) SetBranchIDs(branchIDs BranchIDs) (modified bool)

SetBranchIDs sets the identifiers of the Branches that the Transaction was booked in.

func (*TransactionMetadata) SetGradeOfFinality added in v0.8.0

func (t *TransactionMetadata) SetGradeOfFinality(gradeOfFinality gof.GradeOfFinality) (modified bool)

SetGradeOfFinality updates the grade of finality. It returns true if it 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.

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(ledgerstate *Ledgerstate) (utxoDAG *UTXODAG)

NewUTXODAG create a new UTXODAG from the given details.

func (*UTXODAG) BookTransaction

func (u *UTXODAG) BookTransaction(transaction *Transaction) (targetBranchIDs BranchIDs, err error)

BookTransaction books a Transaction into the ledger state.

func (*UTXODAG) BranchGradeOfFinality added in v0.8.0

func (u *UTXODAG) BranchGradeOfFinality(branchID BranchID) (gradeOfFinality gof.GradeOfFinality, err error)

BranchGradeOfFinality returns the GradeOfFinality of the Branch with the given BranchID.

func (*UTXODAG) CachedAddressOutputMapping added in v0.6.2

func (u *UTXODAG) CachedAddressOutputMapping(address Address) (cachedAddressOutputMappings objectstorage.CachedObjects[*AddressOutputMapping])

CachedAddressOutputMapping retrieves the outputs for the given address.

func (*UTXODAG) CachedConsumers added in v0.6.2

func (u *UTXODAG) CachedConsumers(outputID OutputID) (cachedConsumers objectstorage.CachedObjects[*Consumer])

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 *objectstorage.CachedObject[Output])

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 *objectstorage.CachedObject[*OutputMetadata])

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 *objectstorage.CachedObject[*Transaction])

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 *objectstorage.CachedObject[*TransactionMetadata])

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) ConflictingTransactions added in v0.8.0

func (u *UTXODAG) ConflictingTransactions(transaction *Transaction) (conflictingTransactions TransactionIDs)

ConflictingTransactions returns the TransactionIDs that are conflicting with the given Transaction.

func (*UTXODAG) ConsumedOutputs added in v0.4.1

func (u *UTXODAG) ConsumedOutputs(transaction *Transaction) (cachedInputs objectstorage.CachedObjects[Output])

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) LoadSnapshot

func (u *UTXODAG) LoadSnapshot(snapshot *Snapshot)

LoadSnapshot creates a set of outputs in the UTXODAG, that are forming the genesis for future transactions.

func (*UTXODAG) ManageStoreAddressOutputMapping added in v0.6.2

func (u *UTXODAG) ManageStoreAddressOutputMapping(output Output)

ManageStoreAddressOutputMapping manages how to store the address-output mapping dependent on which type of output it is.

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) TransactionBranchIDs added in v0.8.6

func (u *UTXODAG) TransactionBranchIDs(transactionID TransactionID) (branchIDs BranchIDs, err error)

TransactionBranchIDs returns the BranchIDs of the given Transaction.

func (*UTXODAG) TransactionGradeOfFinality added in v0.8.0

func (u *UTXODAG) TransactionGradeOfFinality(transactionID TransactionID) (gradeOfFinality gof.GradeOfFinality, err error)

TransactionGradeOfFinality returns the GradeOfFinality of the Transaction with the given TransactionID.

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 {
	// TransactionBranchIDUpdatedByFork gets triggered when the BranchID of a Transaction is changed after the initial booking.
	TransactionBranchIDUpdatedByFork *events.Event
}

UTXODAGEvents is a container for all 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 (*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 Address.

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.

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
)

region UnlockBlockType. //////////////////////////////////////////////////////////////////////////////////////////////

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 (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
y or Y : Canonical URL