flow

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: AGPL-3.0 Imports: 27 Imported by: 241

Documentation

Overview

(c) 2019 Dapper Labs - ALL RIGHTS RESERVED

Index

Constants

View Source
const (
	ServiceEventSetup  = "setup"
	ServiceEventCommit = "commit"
)
View Source
const (
	// AddressLength is the size of an account address in bytes.
	// (n) is the size of an account address in bits.
	AddressLength = (linearCodeN + 7) >> 3
)
View Source
const DefaultAuctionWindow = 50000

DefaultAuctionWindow defines the length of the auction window at the beginning of an epoch, during which nodes can bid for seats in the committee. Valid epoch events such as setup and commit can only be submitted after this window has passed.

View Source
const DefaultGracePeriod = 25000

DefaultGracePeriod defines the minimum number of views before the final view of an epoch where we need to have an epoch setup and an epoch commit event. This is in order to give all nodes the chance to have the information before entering the next epoch.

View Source
const DefaultMaxGasLimit = 9999

DefaultMaxGasLimit is the default maximum value for the transaction gas limit.

View Source
const DefaultMaxTxSizeLimit = 1500000

DefaultMaxTxSizeLimit is the default maximum transaction byte size. (1.5MB)

View Source
const DefaultTransactionExpiry = 10 * 60

DefaultTransactionExpiry is the default expiry for transactions, measured in blocks. Equivalent to 10 minutes for a 1-second block time.

View Source
const DefaultTransactionExpiryBuffer = 30

DefaultTransactionExpiryBuffer is the default buffer time between a transaction being ingested by a collection node and being included in a collection and block.

View Source
const DefaultValueLogGCFrequency = 10 * 60

DefaultValueLogGCFrequency is the default frequency in blocks that we call the badger value log GC. Equivalent to 10 mins for a 1 second block time

View Source
const DomainTagLength = 32

Variables

View Source
var EmptyAddress = Address{}

EmptyAddress is the default value of a variable of type Address

View Source
var GenesisTime = time.Date(2018, time.December, 19, 22, 32, 30, 42, time.UTC)

GenesisTime defines the timestamp of the genesis block.

View Source
var TransactionDomainTag = paddedDomainTag("FLOW-V0.0-transaction")

TransactionDomainTag is the prefix of all signed transaction payloads.

A domain tag is encoded as UTF-8 bytes, right padded to a total length of 32 bytes.

View Source
var UserDomainTag = paddedDomainTag("FLOW-V0.0-user")

UserDomainTag is the prefix of all signed user space payloads.

A domain tag is encoded as UTF-8 bytes, right padded to a total length of 32 bytes.

View Source
var (
	// ZeroID is the lowest value in the 32-byte ID space.
	ZeroID = Identifier{}
)

Functions

func CheckConcatSum

func CheckConcatSum(sum Identifier, fps ...Identifier) bool

func CheckMerkleRoot

func CheckMerkleRoot(root Identifier, ids ...Identifier) bool

func CompatibleAlgorithms

func CompatibleAlgorithms(sigAlgo crypto.SigningAlgorithm, hashAlgo hash.HashingAlgorithm) bool

CompatibleAlgorithms returns true if the signature and hash algorithms are compatible.

func EncodeAccountPrivateKey

func EncodeAccountPrivateKey(a AccountPrivateKey) ([]byte, error)

func EncodeAccountPublicKey

func EncodeAccountPublicKey(a AccountPublicKey) ([]byte, error)

func EncodeRuntimeAccountPublicKey

func EncodeRuntimeAccountPublicKey(a AccountPublicKey) ([]byte, error)

Types

type Account

type Account struct {
	Address   Address
	Balance   uint64
	Keys      []AccountPublicKey
	Contracts map[string][]byte
}

Account represents an account on the Flow network.

An account can be an externally owned account or a contract account with code.

type AccountPrivateKey

type AccountPrivateKey struct {
	PrivateKey crypto.PrivateKey
	SignAlgo   crypto.SigningAlgorithm
	HashAlgo   hash.HashingAlgorithm
}

AccountPrivateKey is a private key associated with an account.

func DecodeAccountPrivateKey

func DecodeAccountPrivateKey(b []byte) (AccountPrivateKey, error)

func (AccountPrivateKey) MarshalJSON

func (a AccountPrivateKey) MarshalJSON() ([]byte, error)

func (AccountPrivateKey) PublicKey

func (a AccountPrivateKey) PublicKey(weight int) AccountPublicKey

PublicKey returns a weighted public key.

type AccountPublicKey

type AccountPublicKey struct {
	Index     int
	PublicKey crypto.PublicKey
	SignAlgo  crypto.SigningAlgorithm
	HashAlgo  hash.HashingAlgorithm
	SeqNumber uint64
	Weight    int
	Revoked   bool
}

AccountPublicKey is a public key associated with an account.

An account public key contains the public key, signing and hashing algorithms, and a key weight.

func DecodeAccountPublicKey

func DecodeAccountPublicKey(b []byte, index uint64) (AccountPublicKey, error)

func DecodeRuntimeAccountPublicKey

func DecodeRuntimeAccountPublicKey(b []byte, seqNumber uint64) (AccountPublicKey, error)

DecodeRuntimeAccountPublicKey decode bytes into AccountPublicKey but it is designed to accept byte-format used by Cadence runtime (currently same as SDK, but we don't want to keep explicit dependency on SDK)

func (AccountPublicKey) MarshalJSON

func (a AccountPublicKey) MarshalJSON() ([]byte, error)

func (*AccountPublicKey) UnmarshalJSON

func (a *AccountPublicKey) UnmarshalJSON(data []byte) error

func (AccountPublicKey) Validate

func (a AccountPublicKey) Validate() error

Validate returns an error if this account key is invalid.

An account key can be invalid for the following reasons: - It specifies an incompatible signature/hash algorithm pairing - (TODO) It specifies a negative key weight

type Address

type Address [AddressLength]byte

Address represents the 8 byte address of an account.

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress returns Address with value b.

If b is larger than 8, b will be cropped from the left. If b is smaller than 8, b will be appended by zeroes at the front.

func HexToAddress

func HexToAddress(h string) Address

HexToAddress converts a hex string to an Address.

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes returns the byte representation of the address.

func (Address) Hex

func (a Address) Hex() string

Hex returns the hex string representation of the address.

func (Address) HexWithPrefix

func (a Address) HexWithPrefix() string

HexWithPrefix returns the hex string representation of the address, including the 0x prefix.

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (Address) Short

func (a Address) Short() string

Short returns the string representation of the address with leading zeros removed.

func (Address) String

func (a Address) String() string

String returns the string representation of the address.

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(data []byte) error

type AddressGenerator

type AddressGenerator interface {
	NextAddress() (Address, error)
	CurrentAddress() Address
	Bytes() []byte
}

type AggregatedSignature added in v0.9.6

type AggregatedSignature struct {
	// List of signatures
	VerifierSignatures []crypto.Signature
	// List of signer identifiers
	SignerIDs []Identifier
}

AggregatedSignature contains a set of of signatures from verifiers attesting to the validity of an execution result chunk. TODO: this will be replaced with BLS aggregation

func (*AggregatedSignature) Add added in v0.11.0

func (a *AggregatedSignature) Add(signerID Identifier, signature crypto.Signature)

Add appends a signature. ATTENTION: it does not check for duplicates

func (*AggregatedSignature) BySigner added in v0.11.0

func (a *AggregatedSignature) BySigner(signerID Identifier) (*crypto.Signature, bool)

BySigner returns a signer's signature if it exists

func (*AggregatedSignature) Len added in v0.11.0

func (a *AggregatedSignature) Len() int

Len returns the number of signatures in the AggregatedSignature

type AssignmentList

type AssignmentList [][]Identifier

AssignmentList is a list of identifier lists. Each list of identifiers lists the identities that are part of the given cluster.

type Attestation

type Attestation struct {
	BlockID           Identifier // ID of the block included the collection
	ExecutionResultID Identifier // ID of the execution result
	ChunkIndex        uint64     // index of the approved chunk
}

Attestation confirms correctness of a chunk of an exec result

func (Attestation) ID

func (a Attestation) ID() Identifier

ID generates a unique identifier using attestation

type Batch

type Batch struct {
	BlockIDs []Identifier
}

Batch is a set of block IDs we want to request.

type Block

type Block struct {
	Header  *Header
	Payload *Payload
}

Block (currently) includes the header, the payload hashes as well as the payload contents.

func Genesis

func Genesis(chainID ChainID) *Block

func (Block) Checksum

func (b Block) Checksum() Identifier

Checksum returns the checksum of the header.

func (Block) ID

func (b Block) ID() Identifier

ID returns the ID of the header.

func (*Block) SetPayload

func (b *Block) SetPayload(payload Payload)

SetPayload sets the payload and updates the payload hash.

func (Block) Valid

func (b Block) Valid() bool

Valid will check whether the block is valid bottom-up.

type BlockEvents

type BlockEvents struct {
	BlockID        Identifier
	BlockHeight    uint64
	BlockTimestamp time.Time
	Events         []Event
}

BlockEvents contains events emitted in a single block.

type Chain

type Chain interface {
	NewAddressGenerator() AddressGenerator
	AddressAtIndex(index uint64) (Address, error)
	ServiceAddress() Address
	BytesToAddressGenerator(b []byte) AddressGenerator
	IsValid(Address) bool
	IndexFromAddress(address Address) (uint64, error)
	String() string
	// contains filtered or unexported methods
}

Chain is the interface for address generation implementations.

type ChainID

type ChainID string

A ChainID is a unique identifier for a specific Flow network instance.

Chain IDs are used used to prevent replay attacks and to support network-specific address generation.

const Emulator ChainID = "flow-emulator"

Emulator is the chain ID for the emulated node chain.

const Mainnet ChainID = "flow-mainnet"

Mainnet is the chain ID for the mainnet node chain.

const MonotonicEmulator ChainID = "flow-emulator-monotonic"

MonotonicEmulator is the chain ID for the emulated node chain with monotonic address generation.

const Testnet ChainID = "flow-testnet"

Testnet is the chain ID for the testnet node chain.

func (ChainID) Chain

func (c ChainID) Chain() Chain

Chain returns the Chain corresponding to the string input

func (ChainID) String

func (c ChainID) String() string

type Chunk

type Chunk struct {
	ChunkBody

	Index uint64 // chunk index inside the ER (starts from zero)
	// EndState inferred from next chunk or from the ER
	EndState StateCommitment
}

func (*Chunk) Checksum

func (ch *Chunk) Checksum() Identifier

Checksum provides a cryptographic commitment for a chunk content

func (*Chunk) ID

func (ch *Chunk) ID() Identifier

ID returns a unique id for this entity

type ChunkBody

type ChunkBody struct {
	CollectionIndex uint

	// execution info
	StartState      StateCommitment // start state when starting executing this chunk
	EventCollection Identifier      // Events generated by executing results
	BlockID         Identifier      // Block id of the execution result this chunk belongs to

	// Computation consumption info
	TotalComputationUsed uint64 // total amount of computation used by running all txs in this chunk
	NumberOfTransactions uint64 // number of transactions inside the collection
}

type ChunkDataPack

type ChunkDataPack struct {
	ChunkID      Identifier
	StartState   StateCommitment
	Proof        StorageProof
	CollectionID Identifier
}

ChunkDataPack holds all register touches (any read, or write) note that we have to capture a read proof for each write before updating the registers

func (*ChunkDataPack) Checksum

func (c *ChunkDataPack) Checksum() Identifier

Checksum returns the checksum of the chunk data pack.

func (*ChunkDataPack) ID

func (c *ChunkDataPack) ID() Identifier

ID returns the unique identifier for the concrete view, which is the ID of the chunk the view is for.

type ChunkList

type ChunkList []*Chunk

Note that this is the basic version of the List, we need to substitute it with something like Merkel tree at some point

func (ChunkList) ByChecksum

func (cl ChunkList) ByChecksum(cs Identifier) (*Chunk, bool)

ByChecksum returns an entity from the list by entity fingerprint

func (ChunkList) ByIndex

func (cl ChunkList) ByIndex(i uint64) (*Chunk, bool)

ByIndex returns an entity from the list by index if requested chunk is within range of list, it returns chunk and true if requested chunk is out of the range, it returns nil and false boolean return value indicates whether requested chunk is within range

func (ChunkList) Fingerprint

func (cl ChunkList) Fingerprint() Identifier

func (*ChunkList) Insert

func (cl *ChunkList) Insert(ch *Chunk)

func (ChunkList) Items

func (cl ChunkList) Items() []*Chunk

func (ChunkList) Len

func (cl ChunkList) Len() int

Len returns the number of Chunks in the list. It is also part of the sort interface that makes ChunkList sortable

func (ChunkList) Less

func (cl ChunkList) Less(i, j int) bool

Less returns true if element i in the ChunkList is less than j based on its chunk ID. Otherwise it returns true. It satisfies the sort.Interface making the ChunkList sortable.

func (ChunkList) Swap

func (cl ChunkList) Swap(i, j int)

Swap swaps the element i and j in the ChunkList. It satisfies the sort.Interface making the ChunkList sortable.

type ClusterList

type ClusterList []IdentityList

ClusterList is a list of identity lists. Each `IdentityList` represents the nodes assigned to a specific cluster.

func NewClusterList

func NewClusterList(assignments AssignmentList, collectors IdentityList) (ClusterList, error)

NewClusterList creates a new cluster list based on the given cluster assignment and the provided list of identities.

func (ClusterList) ByIndex

func (cl ClusterList) ByIndex(index uint) (IdentityList, bool)

ByIndex retrieves the list of identities that are part of the given cluster.

func (ClusterList) ByNodeID

func (cl ClusterList) ByNodeID(nodeID Identifier) (IdentityList, uint, bool)

ByNodeID select the cluster that the node with the given ID is part of.

Nodes will be divided into equally sized clusters as far as possible. The last return value will indicate if the look up was successful

func (ClusterList) ByTxID

func (cl ClusterList) ByTxID(txID Identifier) (IdentityList, bool)

ByTxID selects the cluster that should receive the transaction with the given transaction ID.

For evenly distributed transaction IDs, this will evenly distribute transactions between clusters.

func (ClusterList) IndexOf

func (cl ClusterList) IndexOf(cluster IdentityList) (uint, bool)

IndexOf returns the index of the given cluster.

type Collection

type Collection struct {
	Transactions []*TransactionBody
}

Collection is set of transactions.

func CollectionFromTransactions

func CollectionFromTransactions(transactions []*Transaction) Collection

CollectionFromTransactions creates a new collection from the list of transactions.

func (Collection) Checksum

func (c Collection) Checksum() Identifier

func (Collection) Fingerprint

func (c Collection) Fingerprint() []byte

func (*Collection) Guarantee

func (c *Collection) Guarantee() CollectionGuarantee

Guarantee returns a collection guarantee for this collection.

func (Collection) ID

func (c Collection) ID() Identifier

func (Collection) Len

func (c Collection) Len() int

func (Collection) Light

func (c Collection) Light() LightCollection

Light returns the light, reference-only version of the collection.

type CollectionGuarantee

type CollectionGuarantee struct {
	CollectionID     Identifier       // ID of the collection being guaranteed
	ReferenceBlockID Identifier       // defines expiry of the collection
	SignerIDs        []Identifier     // list of guarantors
	Signature        crypto.Signature // guarantor signatures
}

CollectionGuarantee is a signed hash for a collection, which is used to announce collections to consensus nodes.

func (*CollectionGuarantee) Checksum

func (cg *CollectionGuarantee) Checksum() Identifier

Checksum returns a checksum of the collection guarantee including the signatures.

func (*CollectionGuarantee) ID

ID returns the fingerprint of the collection guarantee.

type CollectionList

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

Note that this is the basic version of the List, we need to substitute it with something like Merkle tree at some point

func (*CollectionList) ByChecksum

func (cl *CollectionList) ByChecksum(cs Identifier) (*Collection, bool)

ByChecksum returns an entity from the list by entity fingerprint

func (*CollectionList) ByIndex

func (cl *CollectionList) ByIndex(i uint64) *Collection

ByIndex returns an entity from the list by index

func (*CollectionList) ByIndexWithProof

func (cl *CollectionList) ByIndexWithProof(i uint64) (*Collection, Proof)

ByIndexWithProof returns an entity from the list by index and proof of membership

func (*CollectionList) Fingerprint

func (cl *CollectionList) Fingerprint() Identifier

func (*CollectionList) Insert

func (cl *CollectionList) Insert(ch *Collection)

func (*CollectionList) Items

func (cl *CollectionList) Items() []*Collection

type DKGParticipant

type DKGParticipant struct {
	Index    uint
	KeyShare crypto.PublicKey
}

func (DKGParticipant) EncodeRLP

func (part DKGParticipant) EncodeRLP(w io.Writer) error

func (DKGParticipant) MarshalJSON

func (part DKGParticipant) MarshalJSON() ([]byte, error)

func (DKGParticipant) MarshalMsgpack

func (part DKGParticipant) MarshalMsgpack() ([]byte, error)

func (*DKGParticipant) UnmarshalJSON

func (part *DKGParticipant) UnmarshalJSON(b []byte) error

func (*DKGParticipant) UnmarshalMsgpack

func (part *DKGParticipant) UnmarshalMsgpack(b []byte) error

type Entity

type Entity interface {

	// ID returns a unique id for this entity using a hash of the immutable
	// fields of the entity.
	ID() Identifier

	// Checksum returns a unique checksum for the entity, including the mutable
	// data such as signatures.
	Checksum() Identifier
}

Entity defines how flow entities should be defined Entities are flat data structures holding multiple data fields. Entities don't includes nested entities, they only include pointers to other entities. for example they keep an slice of entity commits instead of keeping an slice of entity object itself. This simplifies storage, signature and validation of entities.

type EntityList

type EntityList interface {
	EntitySet

	// HasIndex checks if the list has an entity at the given index.
	HasIndex(i uint) bool

	// ByIndex returns an entity from the list by index
	ByIndex(i uint) (Entity, bool)

	// ByIndexWithProof returns an entity from the list by index and proof of membership
	ByIndexWithProof(i uint) (Entity, Proof, bool)
}

EntityList is a list of entities of the same type

type EntitySet

type EntitySet interface {

	// Insert adds an entity to the data structure.
	Insert(Entity) bool

	// Remove removes an entity from the data structure.
	Remove(Entity) bool

	// Items returns all items of the collection.
	Items() []Entity

	// Size returns the number of entities in the data structure.
	Size() uint

	// Fingerprint returns a unique identifier for all entities of the data
	// structure.
	Fingerprint() Identifier

	// ByID returns the entity with the given fingerprint.
	ByID(id Identifier) (Entity, bool)

	// if the set has an specific member providing proof of membership
	ByIDWithProof(id Identifier) (bool, Proof, error)
}

EntitySet holds a set of entities (order doesn't matter)

type EpochCommit

type EpochCommit struct {
	Counter         uint64                        // the number of the epoch
	ClusterQCs      []*QuorumCertificate          // quorum certificates for each cluster
	DKGGroupKey     crypto.PublicKey              // group key from DKG
	DKGParticipants map[Identifier]DKGParticipant // public keys for DKG participants
}

EpochCommit is a service event emitted when epoch setup has been completed. When an EpochCommit event is emitted, the network is ready to transition to the epoch.

func (*EpochCommit) EncodeRLP

func (commit *EpochCommit) EncodeRLP(w io.Writer) error

EncodeRLP encodes the commit as RLP. The RLP encoding needs to be handled differently from JSON/msgpack, because it does not handle custom encoders within map types.

func (*EpochCommit) ID

func (commit *EpochCommit) ID() Identifier

ID returns the hash of the event contents.

func (*EpochCommit) MarshalJSON

func (commit *EpochCommit) MarshalJSON() ([]byte, error)

func (*EpochCommit) MarshalMsgpack

func (commit *EpochCommit) MarshalMsgpack() ([]byte, error)

func (*EpochCommit) ServiceEvent

func (commit *EpochCommit) ServiceEvent() ServiceEvent

func (*EpochCommit) UnmarshalJSON

func (commit *EpochCommit) UnmarshalJSON(b []byte) error

func (*EpochCommit) UnmarshalMsgpack

func (commit *EpochCommit) UnmarshalMsgpack(b []byte) error

type EpochPhase

type EpochPhase int

EpochPhase represents a phase of the Epoch Preparation Protocol. The phase of an epoch is resolved based on a block reference and is fork-dependent. An epoch begins in the staking phase, then transitions to the setup phase in the block containing the EpochSetup service event, then to the committed phase in the block containing the EpochCommit service event. |<-- EpochPhaseStaking -->|<-- EpochPhaseSetup -->|<-- EpochPhaseCommitted -->|<-- EpochPhaseStaking -->... |<------------------------------- Epoch N ------------------------------------>|<-- Epoch N + 1 --...

const (
	EpochPhaseUndefined EpochPhase = iota
	EpochPhaseStaking
	EpochPhaseSetup
	EpochPhaseCommitted
)

func (EpochPhase) String

func (p EpochPhase) String() string

type EpochSetup

type EpochSetup struct {
	Counter      uint64         // the number of the epoch
	FinalView    uint64         // the final view of the epoch
	Participants IdentityList   // all participants of the epoch
	Assignments  AssignmentList // cluster assignment for the epoch
	RandomSource []byte         // source of randomness for epoch-specific setup tasks
}

EpochSetup is a service event emitted when the network is ready to set up for the upcoming epoch. It contains the participants in the epoch, the length, the cluster assignment, and the seed for leader selection.

func (*EpochSetup) ID

func (setup *EpochSetup) ID() Identifier

ID returns the hash of the event contents.

func (*EpochSetup) ServiceEvent

func (setup *EpochSetup) ServiceEvent() ServiceEvent

type EpochStatus

type EpochStatus struct {
	FirstBlockID Identifier // ID of the first block in current epoch
	CurrentEpoch EventIDs   // EpochSetup and EpochCommit events for the current epoch
	NextEpoch    EventIDs   // EpochSetup and EpochCommit events for the next epoch
}

EpochStatus represents the status of the current and next epoch with respect to a reference block. Concretely, it contains the IDs for all relevant service events emitted as of the reference block. Events not yet emitted are represented by ZeroID.

func NewEpochStatus

func NewEpochStatus(firstBlockID, currentSetup, currentCommit, nextSetup, nextCommit Identifier) (*EpochStatus, error)

func (*EpochStatus) Phase

func (es *EpochStatus) Phase() (EpochPhase, error)

Phase returns the phase for the CURRENT epoch, given this epoch status.

type Event

type Event struct {
	// Type is the qualified event type.
	Type EventType
	// TransactionID is the ID of the transaction this event was emitted from.
	TransactionID Identifier
	// TransactionIndex defines the index of the transaction this event was emitted from within the block.
	// The first transaction has index 0, the second has index 1, and so on.
	TransactionIndex uint32
	// EventIndex defines the ordering of events in a transaction.
	// The first event emitted has index 0, the second has index 1, and so on.
	EventIndex uint32
	// Payload contains the encoded event data.
	Payload []byte
}

func (*Event) Body

func (e *Event) Body() interface{}

Body returns the body of the execution receipt.

func (Event) Encode

func (e Event) Encode() []byte

Encode returns the canonical encoding of this event, containing only the fields necessary to uniquely identify it.

func (Event) Fingerprint

func (e Event) Fingerprint() []byte

func (Event) ID

func (e Event) ID() Identifier

ID returns a canonical identifier that is guaranteed to be unique.

func (Event) String

func (e Event) String() string

String returns the string representation of this event.

type EventIDs

type EventIDs struct {
	// SetupID is the ID of the EpochSetup event for the respective Epoch
	SetupID Identifier
	// CommitID is the ID of the EpochCommit event for the respective Epoch
	CommitID Identifier
}

EventIDs is a container for IDs of epoch service events.

type EventType

type EventType string
const (
	EventAccountCreated EventType = "flow.AccountCreated"
	EventAccountUpdated EventType = "flow.AccountUpdated"
	EventEpochSetup     EventType = "flow.EpochSetup"
	EventEpochCommit    EventType = "flow.EpochCommit"
)

List of built-in event types.

type ExecutedTransaction

type ExecutedTransaction struct {
	Tx         *Transaction
	GasSpent   uint64
	MaxGas     uint64
	StartState StateCommitment
	EndState   StateCommitment
}

ExecutedTransaction are generated by computer and pass to chunker

type ExecutionReceipt

type ExecutionReceipt struct {
	ExecutorID        Identifier
	ExecutionResult   ExecutionResult
	Spocks            []crypto.Signature
	ExecutorSignature crypto.Signature
}

func ExecutionReceiptFromMeta

func ExecutionReceiptFromMeta(meta ExecutionReceiptMeta, result ExecutionResult) *ExecutionReceipt

func (*ExecutionReceipt) Body

func (er *ExecutionReceipt) Body() interface{}

Body returns the body of the execution receipt.

func (*ExecutionReceipt) Checksum

func (er *ExecutionReceipt) Checksum() Identifier

Checksum returns a checksum for the execution receipt including the signatures.

func (*ExecutionReceipt) ID

func (er *ExecutionReceipt) ID() Identifier

ID returns the canonical ID of the execution receipt.

func (*ExecutionReceipt) Meta

Meta returns the receipt metadata for the receipt.

type ExecutionReceiptMeta

type ExecutionReceiptMeta struct {
	ExecutorID        Identifier
	ResultID          Identifier
	Spocks            []crypto.Signature
	ExecutorSignature crypto.Signature
}

ExecutionReceiptMeta contains the metadata the distinguishes an execution receipt from an execution result. This is used for storing results and receipts separately in a composable way.

type ExecutionResult

type ExecutionResult struct {
	ExecutionResultBody
	Signatures []crypto.Signature
}

ExecutionResult ...

func (ExecutionResult) Checksum

func (er ExecutionResult) Checksum() Identifier

Checksum ...

func (ExecutionResult) FinalStateCommitment added in v0.11.0

func (er ExecutionResult) FinalStateCommitment() (StateCommitment, bool)

FinalStateCommitment returns the Execution Result's commitment to the final execution state of the block, i.e. the last chunk's output state.

By protocol definition, each ExecutionReceipt must contain at least one chunk (system chunk). Convention: publishing an ExecutionReceipt without a final state commitment is a slashable protocol violation. TODO: change bool to error return with a sentinel error

func (ExecutionResult) ID

func (er ExecutionResult) ID() Identifier

ID returns the hash of the execution result body

func (ExecutionResult) InitialStateCommit added in v0.11.0

func (er ExecutionResult) InitialStateCommit() (StateCommitment, bool)

InitialStateCommit returns a commitment to the execution state used as input for computing the block the block, i.e. the leading chunk's input state.

By protocol definition, each ExecutionReceipt must contain at least one chunk (system chunk). Convention: publishing an ExecutionReceipt without an initial state commitment is a slashable protocol violation. TODO: change bool to error return with a sentinel error

type ExecutionResultBody

type ExecutionResultBody struct {
	PreviousResultID Identifier // commit of the previous ER
	BlockID          Identifier // commit of the current block
	Chunks           ChunkList
}

ExecutionResultBody ...

type Header struct {
	ChainID        ChainID    // ChainID is a chain-specific value to prevent replay attacks.
	ParentID       Identifier // ParentID is the ID of this block's parent.
	Height         uint64
	PayloadHash    Identifier       // PayloadHash is a hash of the payload of this block.
	Timestamp      time.Time        // Timestamp is the time at which this block was proposed. The proposing node can choose any time, so this should not be trusted as accurate.
	View           uint64           // View is the view number at which this block was proposed.
	ParentVoterIDs []Identifier     // list of voters who signed the parent block
	ParentVoterSig crypto.Signature // aggregated signature over the parent block
	ProposerID     Identifier       // proposer identifier for the block
	ProposerSig    crypto.Signature // signature of the proposer over the new block
}

Header contains all meta-data for a block, as well as a hash representing the combined payload of the entire block. It is what consensus nodes agree on after validating the contents against the payload hash.

func (Header) Body

func (h Header) Body() interface{}

Body returns the immutable part of the block header.

func (Header) Checksum

func (h Header) Checksum() Identifier

Checksum returns the checksum of the header.

func (Header) Fingerprint

func (h Header) Fingerprint() []byte

func (Header) ID

func (h Header) ID() Identifier

ID returns a unique ID to singularly identify the header and its block within the flow system.

func (Header) MarshalJSON

func (h Header) MarshalJSON() ([]byte, error)

MarshalJSON makes sure the timestamp is encoded in UTC.

func (Header) MarshalMsgpack

func (h Header) MarshalMsgpack() ([]byte, error)

MarshalMsgpack makes sure the timestamp is encoded in UTC.

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(data []byte) error

UnmarshalJSON makes sure the timestamp is decoded in UTC.

func (*Header) UnmarshalMsgpack

func (h *Header) UnmarshalMsgpack(data []byte) error

UnmarshalMsgpack makes sure the timestamp is decoded in UTC.

type Identifier

type Identifier [32]byte

Identifier represents a 32-byte unique identifier for an entity.

func ConcatSum

func ConcatSum(ids ...Identifier) Identifier

func GetIDs

func GetIDs(value interface{}) []Identifier

GetIDs gets the IDs for a slice of entities.

func HashToID

func HashToID(hash []byte) Identifier

func HexStringToIdentifier

func HexStringToIdentifier(hexString string) (Identifier, error)

HexStringToIdentifier converts a hex string to an identifier. The input must be 64 characters long and contain only valid hex characters.

func MakeID

func MakeID(entity interface{}) Identifier

MakeID creates an ID from a hash of encoded data. MakeID uses `model.Fingerprint() []byte` to get the byte representation of the entity, which uses RLP to encode the data. If the input defines its own canonical encoding by implementing Fingerprinter, it uses that instead. That allows removal of non-unique fields from structs or overwriting of the used encoder. We are using Fingerprint instead of the default encoding for two reasons: a) JSON (the default encoding) does not specify an order for the elements of arrays and objects, which could lead to different hashes depending on the JSON implementation and b) the Fingerprinter interface allows to exclude fields not needed in the pre-image of the hash that comprises the Identifier, which could be different from the encoding for sending entities in messages or for storing them.

func MerkleRoot

func MerkleRoot(ids ...Identifier) Identifier

func PublicKeyToID

func PublicKeyToID(pub crypto.PublicKey) (Identifier, error)

PublicKeyToID creates an ID from a public key.

func Sample

func Sample(size uint, ids ...Identifier) []Identifier

Sample returns random sample of length 'size' of the ids [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).

func (Identifier) Format

func (id Identifier) Format(state fmt.State, verb rune)

Format handles formatting of id for different verbs. This is called when formatting an identifier with fmt.

func (Identifier) MarshalText

func (id Identifier) MarshalText() ([]byte, error)

func (Identifier) String

func (id Identifier) String() string

String returns the hex string representation of the identifier.

func (*Identifier) UnmarshalText

func (id *Identifier) UnmarshalText(text []byte) error

type IdentifierList

type IdentifierList []Identifier

IdentifierList defines a sortable list of identifiers

func (IdentifierList) Len

func (il IdentifierList) Len() int

Len returns length of the IdentiferList in the number of stored identifiers. It satisfies the sort.Interface making the IdentifierList sortable.

func (IdentifierList) Less

func (il IdentifierList) Less(i, j int) bool

Less returns true if element i in the IdentifierList is less than j based on its identifier. Otherwise it returns true. It satisfies the sort.Interface making the IdentifierList sortable.

func (IdentifierList) Swap

func (il IdentifierList) Swap(i, j int)

Swap swaps the element i and j in the IdentifierList. It satisfies the sort.Interface making the IdentifierList sortable.

type Identity

type Identity struct {
	// NodeID uniquely identifies a particular node. A node's ID is fixed for
	// the duration of that node's participation in the network.
	NodeID  Identifier
	Address string
	Role    Role
	// Stake represents the node's *weight*. The stake (quantity of $FLOW held
	// in escrow during the node's participation) is strictly managed by the
	// service account. The protocol software strictly considers weight, which
	// represents how much voting power a given node has.
	//
	// NOTE: Nodes that are registered for an upcoming epoch, or that are in
	// the process of un-staking, have 0 weight.
	//
	// TODO: to be renamed to Weight
	Stake uint64
	// Ejected represents whether a node has been permanently removed from the
	// network. A node may be ejected for either:
	// * committing one protocol felony
	// * committing a series of protocol misdemeanours
	Ejected       bool
	StakingPubKey crypto.PublicKey
	NetworkPubKey crypto.PublicKey
}

Identity represents a node identity.

func ParseIdentity

func ParseIdentity(identity string) (*Identity, error)

ParseIdentity parses a string representation of an identity.

func (Identity) Checksum

func (iy Identity) Checksum() Identifier

Checksum returns a checksum for the identity including mutable attributes.

func (Identity) ID

func (iy Identity) ID() Identifier

ID returns a unique identifier for the identity.

func (Identity) MarshalJSON

func (iy Identity) MarshalJSON() ([]byte, error)

func (Identity) MarshalMsgpack

func (iy Identity) MarshalMsgpack() ([]byte, error)

func (Identity) String

func (iy Identity) String() string

String returns a string representation of the identity.

func (*Identity) UnmarshalJSON

func (iy *Identity) UnmarshalJSON(b []byte) error

func (*Identity) UnmarshalMsgpack

func (iy *Identity) UnmarshalMsgpack(b []byte) error

type IdentityFilter

type IdentityFilter func(*Identity) bool

IdentityFilter is a filter on identities.

type IdentityList

type IdentityList []*Identity

IdentityList is a list of nodes.

func (IdentityList) ByIndex

func (il IdentityList) ByIndex(index uint) (*Identity, bool)

ByIndex returns the node at the given index.

func (IdentityList) ByNodeID

func (il IdentityList) ByNodeID(nodeID Identifier) (*Identity, bool)

ByNodeID gets a node from the list by node ID.

func (IdentityList) Copy added in v0.12.0

func (il IdentityList) Copy() IdentityList

Copy returns a copy of the receiver. The resulting slice uses a different backing array, meaning appends and insert operations on either slice are guaranteed to only affect that slice.

Copy should be used when modifying an existing identity list by either appending new elements, re-ordering, or inserting new elements in an existing index.

func (IdentityList) Count

func (il IdentityList) Count() uint

Count returns the count of identities.

func (IdentityList) DeterministicSample

func (il IdentityList) DeterministicSample(size uint, seed int64) IdentityList

DeterministicSample returns deterministic random sample from the `IdentityList` using the given seed

func (IdentityList) Filter

func (il IdentityList) Filter(filter IdentityFilter) IdentityList

Filter will apply a filter to the identity list.

func (IdentityList) Fingerprint

func (il IdentityList) Fingerprint() Identifier

func (IdentityList) Lookup added in v0.12.0

func (il IdentityList) Lookup() map[Identifier]struct{}

func (IdentityList) Map added in v0.12.0

Map returns a new identity list with the map function f applied to a copy of each identity.

CAUTION: this relies on structure copy semantics. Map functions that modify an object referenced by the input Identity structure will modify identities in the source slice as well.

func (IdentityList) NodeIDs

func (il IdentityList) NodeIDs() []Identifier

NodeIDs returns the NodeIDs of the nodes in the list.

func (IdentityList) Order

func (il IdentityList) Order(less IdentityOrder) IdentityList

Order will sort the list using the given sort function.

func (IdentityList) Sample

func (il IdentityList) Sample(size uint) IdentityList

Sample returns simple random sample from the `IdentityList`

func (IdentityList) SamplePct

func (il IdentityList) SamplePct(pct float64) IdentityList

SamplePct returns a random sample from the receiver identity list. The sample contains `pct` percentage of the list. The sample is rounded up if `pct>0`, so this will always select at least one identity.

NOTE: The input must be between 0-1.

func (IdentityList) Selector

func (il IdentityList) Selector() IdentityFilter

Selector returns an identity filter function that selects only identities within this identity list.

func (IdentityList) StakingKeys

func (il IdentityList) StakingKeys() []crypto.PublicKey

StakingKeys returns a list of the staking public keys for the identities.

func (IdentityList) TotalStake

func (il IdentityList) TotalStake() uint64

TotalStake returns the total stake of all given identities.

func (IdentityList) Union added in v0.10.1

func (il IdentityList) Union(other IdentityList) IdentityList

Union returns a new identity list containing every identity that occurs in either `il`, or `other`, or both. There are no duplicates in the output, where duplicates are identities with the same node ID.

type IdentityMapFunc added in v0.12.0

type IdentityMapFunc func(Identity) Identity

IdentityMapFunc is a modifier function for map operations for identities. Identities are COPIED from the source slice.

type IdentityOrder

type IdentityOrder func(*Identity, *Identity) bool

IdentityOrder is a sort for identities.

type IncorporatedResult added in v0.11.0

type IncorporatedResult struct {
	// IncorporatedBlockID is the ID of the first block on its fork where a
	// receipt for this result was incorporated. Within a fork, multiple blocks
	// may contain receipts for the same result; only the first one is used to
	// compute the random beacon of the result's chunk assignment.
	IncorporatedBlockID Identifier

	// Result is the ExecutionResult contained in the ExecutionReceipt that was
	// incorporated in the payload of IncorporatedBlockID.
	Result *ExecutionResult
	// contains filtered or unexported fields
}

IncorporatedResult is a wrapper around an ExecutionResult which contains the ID of the first block on its fork in which it was incorporated.

func NewIncorporatedResult added in v0.11.0

func NewIncorporatedResult(incorporatedBlockID Identifier, result *ExecutionResult) *IncorporatedResult

func (*IncorporatedResult) AddSignature added in v0.11.0

func (ir *IncorporatedResult) AddSignature(chunkIndex uint64, signerID Identifier, signature crypto.Signature)

AddSignature adds a signature to the collection of AggregatedSignatures

func (*IncorporatedResult) Checksum added in v0.11.0

func (ir *IncorporatedResult) Checksum() Identifier

CheckSum implements flow.Entity.CheckSum for IncorporatedResult to make it capable of being stored directly in mempools and storage.

func (*IncorporatedResult) GetAggregatedSignatures added in v0.11.0

func (ir *IncorporatedResult) GetAggregatedSignatures() []AggregatedSignature

GetAggregatedSignatures returns all the aggregated signatures orderd by chunk index

func (*IncorporatedResult) GetSignature added in v0.11.0

func (ir *IncorporatedResult) GetSignature(chunkIndex uint64, signerID Identifier) (*crypto.Signature, bool)

GetSignature returns a signature by chunk index and signer ID.

func (*IncorporatedResult) ID added in v0.11.0

func (ir *IncorporatedResult) ID() Identifier

ID implements flow.Entity.ID for IncorporatedResult to make it capable of being stored directly in mempools and storage.

type IncorporatedResultSeal added in v0.11.0

type IncorporatedResultSeal struct {
	// IncorporatedResult is the incorporated result (result + ID of block where
	// it was incorporated) that the seal is for.
	IncorporatedResult *IncorporatedResult

	// Seal is a seal for the result contained in IncorporatedResult.
	Seal *Seal
}

IncorporatedResultSeal is a wrapper around a seal that keeps track of which IncorporatedResult the seal corresponds to. Sealing is a function of result And the ID of the block in which the result was incorporated, which is all contained in IncorporatedResult.

func (*IncorporatedResultSeal) Checksum added in v0.11.0

func (s *IncorporatedResultSeal) Checksum() Identifier

CheckSum implements flow.Entity.CheckSum for IncorporatedResultSeal to make it capable of being stored directly in mempools and storage.

func (*IncorporatedResultSeal) ID added in v0.11.0

ID implements flow.Entity.ID for IncorporatedResultSeal to make it capable of being stored directly in mempools and storage.

type Index

type Index struct {
	NodeIDs       []Identifier
	CollectionIDs []Identifier
	SealIDs       []Identifier
	ReceiptIDs    []Identifier
}

type LightCollection

type LightCollection struct {
	Transactions []Identifier
}

LightCollection is a collection containing references to the constituent transactions rather than full transaction bodies. It is used for indexing transactions by collection and for computing the collection fingerprint.

func (LightCollection) Checksum

func (lc LightCollection) Checksum() Identifier

func (LightCollection) Has

func (lc LightCollection) Has(txID Identifier) bool

func (LightCollection) ID

func (lc LightCollection) ID() Identifier

func (LightCollection) Len

func (lc LightCollection) Len() int

type MonotonicAddressGenerator

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

func (*MonotonicAddressGenerator) Bytes

func (gen *MonotonicAddressGenerator) Bytes() []byte

Bytes converts an address index into a slice of bytes

func (*MonotonicAddressGenerator) CurrentAddress

func (gen *MonotonicAddressGenerator) CurrentAddress() Address

CurrentAddress returns the address corresponding to the internal index.

func (*MonotonicAddressGenerator) NextAddress

func (gen *MonotonicAddressGenerator) NextAddress() (Address, error)

NextAddress increments the internal index and generates the new address corresponding to the new index.

type Payload

type Payload struct {
	Guarantees []*CollectionGuarantee
	Seals      []*Seal
	Receipts   []*ExecutionReceipt
}

Payload is the actual content of each block.

func EmptyPayload added in v0.12.0

func EmptyPayload() Payload

EmptyPayload returns an empty block payload.

func (Payload) Hash

func (p Payload) Hash() Identifier

Hash returns the root hash of the payload.

func (Payload) Index

func (p Payload) Index() *Index

Index returns the index for the payload.

type PendingBlock

type PendingBlock struct {
	OriginID Identifier
	Header   *Header
	Payload  *Payload
}

PendingBlock is a wrapper type representing a block that cannot yet be processed. The block header, payload, and sender ID are stored together while waiting for the block to become processable.

type Proof

type Proof []byte

Proof contains proof that an entity is part of a EntityList

type ProposalKey

type ProposalKey struct {
	Address        Address
	KeyIndex       uint64
	SequenceNumber uint64
}

A ProposalKey is the key that specifies the proposal key and sequence number for a transaction.

func (ProposalKey) ByteSize added in v0.11.0

func (p ProposalKey) ByteSize() int

ByteSize returns the byte size of the proposal key

type QuorumCertificate

type QuorumCertificate struct {
	View      uint64
	BlockID   Identifier
	SignerIDs []Identifier
	SigData   []byte
}

QuorumCertificate represents a quorum certificate for a block proposal as defined in the HotStuff algorithm. A quorum certificate is a collection of votes for a particular block proposal. Valid quorum certificates contain signatures from a super-majority of consensus committee members.

type Range

type Range struct {
	From uint64
	To   uint64
}

Range is a height range for which we want to request blocks.

type RegisterEntries added in v0.10.0

type RegisterEntries []RegisterEntry

handy container for sorting

func (RegisterEntries) IDs added in v0.10.0

func (d RegisterEntries) IDs() []RegisterID

func (RegisterEntries) Len added in v0.10.0

func (d RegisterEntries) Len() int

func (RegisterEntries) Less added in v0.10.0

func (d RegisterEntries) Less(i, j int) bool

func (RegisterEntries) Swap added in v0.10.0

func (d RegisterEntries) Swap(i, j int)

func (RegisterEntries) Values added in v0.10.0

func (d RegisterEntries) Values() []RegisterValue

type RegisterEntry added in v0.10.0

type RegisterEntry struct {
	Key   RegisterID
	Value RegisterValue
}

type RegisterID

type RegisterID struct {
	Owner      string
	Controller string
	Key        string
}

func NewRegisterID added in v0.10.0

func NewRegisterID(owner, controller, key string) RegisterID

func (*RegisterID) String added in v0.10.0

func (r *RegisterID) String() string

type RegisterValue

type RegisterValue = []byte

RegisterValue (value part of Register)

type ResultApproval

type ResultApproval struct {
	Body              ResultApprovalBody
	VerifierSignature crypto.Signature // signature over all above fields
}

ResultApproval includes an approval for a chunk, verified by a verification node

func (ResultApproval) Checksum

func (ra ResultApproval) Checksum() Identifier

Checksum generates checksum using the result approval full content

func (ResultApproval) ID

func (ra ResultApproval) ID() Identifier

ID generates a unique identifier using result approval body

type ResultApprovalBody

type ResultApprovalBody struct {
	Attestation
	ApproverID           Identifier       // node id generating this result approval
	AttestationSignature crypto.Signature // signature over attestation, this has been separated for BLS aggregation
	Spock                crypto.Signature // proof of re-computation, one per each chunk
}

ResultApprovalBody holds body part of a result approval

func (ResultApprovalBody) ID

func (rab ResultApprovalBody) ID() Identifier

ID generates a unique identifier using ResultApprovalBody

type Role

type Role uint8

Role represents a role in the flow system.

const (
	RoleCollection   Role = 1
	RoleConsensus    Role = 2
	RoleExecution    Role = 3
	RoleVerification Role = 4
	RoleAccess       Role = 5
)

Enumeration of the available flow node roles.

func ParseRole

func ParseRole(role string) (Role, error)

ParseRole will parse a role from string.

func Roles

func Roles() []Role

func (Role) MarshalText

func (r Role) MarshalText() ([]byte, error)

func (Role) String

func (r Role) String() string

String returns a string version of role.

func (*Role) UnmarshalText

func (r *Role) UnmarshalText(text []byte) error

type RoleList added in v0.12.0

type RoleList []Role

RoleList defines a slice of roles in flow system.

func (RoleList) Contains added in v0.12.0

func (r RoleList) Contains(role Role) bool

Contains returns true if RoleList contains the role, otherwise false.

func (RoleList) Union added in v0.12.0

func (r RoleList) Union(other RoleList) RoleList

Union returns a new role list containing every role that occurs in either `r`, or `other`, or both. There are no duplicate roles in the output,

type Seal

type Seal struct {
	BlockID                Identifier
	ResultID               Identifier
	FinalState             StateCommitment
	AggregatedApprovalSigs []AggregatedSignature // one AggregatedSignature per chunk
	ServiceEvents          []ServiceEvent
}

func (Seal) Body

func (s Seal) Body() interface{}

TODO need to include service events in hash, omitted for now as they are not encodable with RLP

func (Seal) Checksum

func (s Seal) Checksum() Identifier

func (Seal) ID

func (s Seal) ID() Identifier

type ServiceEvent

type ServiceEvent struct {
	Type  string
	Event interface{}
}

ServiceEvent represents a service event, which is a special event that when emitted from a service account smart contract, is propagated to the protocol and included in blocks. Service events typically cause changes to the protocol state. See EpochSetup and EpochCommit events in this package for examples.

This type represents a generic service event and primarily exists to simplify encoding and decoding.

func (*ServiceEvent) UnmarshalJSON

func (se *ServiceEvent) UnmarshalJSON(b []byte) error

type Spock

type Spock []byte

type StateCommitment

type StateCommitment = []byte

StateCommitment holds the root hash of the tree (Snapshot)

type StorageProof

type StorageProof = []byte

StorageProof (proof of a read or update to the state, Merkle path of some sort)

type Transaction

type Transaction struct {
	TransactionBody
	Status           TransactionStatus
	Events           []Event
	ComputationSpent uint64
	StartState       StateCommitment
	EndState         StateCommitment
}

Transaction is the smallest unit of task.

func (*Transaction) Checksum

func (tx *Transaction) Checksum() Identifier

Checksum provides a cryptographic commitment for a chunk content

func (*Transaction) PayloadMessage

func (tx *Transaction) PayloadMessage() []byte

func (*Transaction) String

func (tx *Transaction) String() string

type TransactionBody

type TransactionBody struct {

	// A reference to a previous block
	// A transaction is expired after specific number of blocks (defined by network) counting from this block
	// for example, if block reference is pointing to a block with height of X and network limit is 10,
	// a block with x+10 height is the last block that is allowed to include this transaction.
	// user can adjust this reference to older blocks if he/she wants to make tx expire faster
	ReferenceBlockID Identifier

	// the transaction script as UTF-8 encoded Cadence source code
	Script []byte

	// arguments passed to the Cadence transaction
	Arguments [][]byte

	// Max amount of computation which is allowed to be done during this transaction
	GasLimit uint64

	// Account key used to propose the transaction
	ProposalKey ProposalKey

	// Account that pays for this transaction fees
	Payer Address

	// A ordered (ascending) list of addresses that scripts will touch their assets (including payer address)
	// Accounts listed here all have to provide signatures
	// Each account might provide multiple signatures (sum of weight should be at least 1)
	// If code touches accounts that is not listed here, tx fails
	Authorizers []Address

	// List of account signatures excluding signature of the payer account
	PayloadSignatures []TransactionSignature

	// payer signature over the envelope (payload + payload signatures)
	EnvelopeSignatures []TransactionSignature
}

TransactionBody includes the main contents of a transaction

func NewTransactionBody

func NewTransactionBody() *TransactionBody

NewTransactionBody initializes and returns an empty transaction body

func (*TransactionBody) AddArgument

func (tb *TransactionBody) AddArgument(arg []byte) *TransactionBody

AddArgument adds an argument to the Cadence arguments list for this transaction.

func (*TransactionBody) AddAuthorizer

func (tb *TransactionBody) AddAuthorizer(address Address) *TransactionBody

AddAuthorizer adds an authorizer account to this transaction.

func (*TransactionBody) AddEnvelopeSignature

func (tb *TransactionBody) AddEnvelopeSignature(address Address, keyID uint64, sig []byte) *TransactionBody

AddEnvelopeSignature adds an envelope signature to the transaction for the given address and key ID.

func (*TransactionBody) AddPayloadSignature

func (tb *TransactionBody) AddPayloadSignature(address Address, keyID uint64, sig []byte) *TransactionBody

AddPayloadSignature adds a payload signature to the transaction for the given address and key ID.

func (TransactionBody) ByteSize added in v0.11.0

func (tb TransactionBody) ByteSize() uint

func (TransactionBody) Checksum

func (tb TransactionBody) Checksum() Identifier

func (*TransactionBody) EnvelopeMessage

func (tb *TransactionBody) EnvelopeMessage() []byte

EnvelopeMessage returns the signable message for transaction envelope.

This message is only signed by the payer account.

func (TransactionBody) Fingerprint

func (tb TransactionBody) Fingerprint() []byte

func (TransactionBody) ID

func (tb TransactionBody) ID() Identifier

func (*TransactionBody) MissingFields

func (tb *TransactionBody) MissingFields() []string

MissingFields checks if a transaction is missing any required fields and returns those that are missing.

func (*TransactionBody) PayloadMessage

func (tb *TransactionBody) PayloadMessage() []byte

func (*TransactionBody) SetArguments

func (tb *TransactionBody) SetArguments(args [][]byte) *TransactionBody

SetArguments sets the Cadence arguments list for this transaction.

func (*TransactionBody) SetGasLimit

func (tb *TransactionBody) SetGasLimit(limit uint64) *TransactionBody

SetGasLimit sets the gas limit for this transaction.

func (*TransactionBody) SetPayer

func (tb *TransactionBody) SetPayer(address Address) *TransactionBody

SetPayer sets the payer account for this transaction.

func (*TransactionBody) SetProposalKey

func (tb *TransactionBody) SetProposalKey(address Address, keyID uint64, sequenceNum uint64) *TransactionBody

SetProposalKey sets the proposal key and sequence number for this transaction.

The first two arguments specify the account key to be used, and the last argument is the sequence number being declared.

func (*TransactionBody) SetReferenceBlockID

func (tb *TransactionBody) SetReferenceBlockID(blockID Identifier) *TransactionBody

SetReferenceBlockID sets the reference block ID for this transaction.

func (*TransactionBody) SetScript

func (tb *TransactionBody) SetScript(script []byte) *TransactionBody

SetScript sets the Cadence script for this transaction.

func (*TransactionBody) SignEnvelope

func (tb *TransactionBody) SignEnvelope(address Address, keyID uint64, privateKey crypto.PrivateKey, hasher hash.Hasher) error

SignEnvelope signs the full transaction (payload + payload signatures) with the specified account key.

The resulting signature is combined with the account address and key ID before being added to the transaction.

This function returns an error if the signature cannot be generated.

func (*TransactionBody) SignPayload

func (tb *TransactionBody) SignPayload(address Address, keyID uint64, privateKey crypto.PrivateKey, hasher hash.Hasher) error

SignPayload signs the transaction payload with the specified account key.

The resulting signature is combined with the account address and key ID before being added to the transaction.

This function returns an error if the signature cannot be generated.

type TransactionField

type TransactionField int

TransactionField represents a required transaction field.

const (
	TransactionFieldUnknown TransactionField = iota
	TransactionFieldScript
	TransactionFieldRefBlockID
	TransactionFieldPayer
)

func (TransactionField) String

func (f TransactionField) String() string

String returns the string representation of a transaction field.

type TransactionResult

type TransactionResult struct {
	// TransactionID is the ID of the transaction this error was emitted from.
	TransactionID Identifier
	// ErrorMessage contains the error message of any error that may have occurred when the transaction was executed
	ErrorMessage string
}

TransactionResult contains the artifacts generated after executing a Cadence transaction.

func (*TransactionResult) Checksum

func (te *TransactionResult) Checksum() Identifier

func (TransactionResult) ID

ID returns a canonical identifier that is guaranteed to be unique.

func (TransactionResult) String

func (t TransactionResult) String() string

String returns the string representation of this error.

type TransactionSignature

type TransactionSignature struct {
	Address     Address
	SignerIndex int
	KeyIndex    uint64
	Signature   []byte
}

A TransactionSignature is a signature associated with a specific account key.

func (TransactionSignature) ByteSize added in v0.11.0

func (s TransactionSignature) ByteSize() int

ByteSize returns the byte size of the transaction signature

func (TransactionSignature) Fingerprint

func (s TransactionSignature) Fingerprint() []byte

func (TransactionSignature) String added in v0.12.0

func (s TransactionSignature) String() string

String returns the string representation of a transaction signature.

type TransactionStatus

type TransactionStatus int

TransactionStatus represents the status of a transaction.

const (
	// TransactionStatusUnknown indicates that the transaction status is not known.
	TransactionStatusUnknown TransactionStatus = iota
	// TransactionStatusPending is the status of a pending transaction.
	TransactionStatusPending
	// TransactionStatusFinalized is the status of a finalized transaction.
	TransactionStatusFinalized
	// TransactionStatusExecuted is the status of an executed transaction.
	TransactionStatusExecuted
	// TransactionStatusSealed is the status of a sealed transaction.
	TransactionStatusSealed
	// TransactionStatusExpired is the status of an expired transaction.
	TransactionStatusExpired
)

func (TransactionStatus) String

func (s TransactionStatus) String() string

String returns the string representation of a transaction status.

type TransactionTiming

type TransactionTiming struct {
	TransactionID Identifier
	Received      time.Time
	Finalized     time.Time
	Executed      time.Time
}

TransactionTiming is used to track the timing/durations of a transaction through the system

func (TransactionTiming) Checksum

func (t TransactionTiming) Checksum() Identifier

func (TransactionTiming) ID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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