utxo

package
v0.0.0-...-e1b380c Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

func NewEngine

func NewEngine(handler EngineHandler) *Engine

func (*Engine) AddOutput

func (engine *Engine) AddOutput(output *Output) error

func (*Engine) Submit

func (engine *Engine) Submit(transaction *Transaction) error

type EngineHandler

type EngineHandler interface {
	// Validate if output to consume and output to insert are sound with respect to the system
	Validate(transaction *Transaction, inputs []*Output, outputs []*Output) error
	// Request missing inputs. Transaction is provided to enqueue it again for evaluation once Input is retrieved
	Request(transaction *Transaction, input *Input) (*Output, error)
	// Transaction is submitted
	Submitted(inputs []*Output, outputs []*Output)
}

type Input

type Input struct {
	ID string
}

func NewInput

func NewInput(ID string) *Input

func NewInputFromOutput

func NewInputFromOutput(output *Output) *Input

func NewInputsFromOutputs

func NewInputsFromOutputs(outputs []*Output) []*Input

type Output

type Output struct {
	ID        string
	Owner     account.GenericAccount
	Payload   []byte
	Signature []byte
}

func NewOutput

func NewOutput(payload []byte, acc account.Account) (*Output, error)

func (*Output) String

func (output *Output) String() string

func (*Output) Verify

func (output *Output) Verify() error

type OutputStorage

type OutputStorage struct {
	Outputs map[string]*Output
}

func NewOutputStorage

func NewOutputStorage() *OutputStorage

func (*OutputStorage) AddOutput

func (storage *OutputStorage) AddOutput(output *Output) error

func (*OutputStorage) FindOutputFromInput

func (storage *OutputStorage) FindOutputFromInput(input *Input) (*Output, error)

func (*OutputStorage) String

func (storage *OutputStorage) String() string

type Transaction

type Transaction struct {
	Account   account.GenericAccount
	Inputs    []*Input
	Outputs   []*Output
	Signature []byte
}

func NewTransactionFromBytes

func NewTransactionFromBytes(data []byte) (*Transaction, error)

func (*Transaction) Deserialize

func (transaction *Transaction) Deserialize(data []byte) error

func (*Transaction) Serialize

func (transaction *Transaction) Serialize() ([]byte, error)

func (*Transaction) Sign

func (t *Transaction) Sign(acc account.Account) error

func (*Transaction) Verify

func (t *Transaction) Verify() (bool, error)

Jump to

Keyboard shortcuts

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