ledger

package
v0.0.0-...-8369a04 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTxConfirmed = errors.New("transaction confirmed")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Type         umi.AccountType
	Balance      uint64
	UpdatedAt    uint32
	InterestRate uint16

	TransactionCount uint64
	// contains filtered or unexported fields
}

func NewAccount

func NewAccount(structure *Structure) *Account

func (*Account) BalanceAt

func (account *Account) BalanceAt(timestamp uint32) uint64

func (*Account) DecreaseBalance

func (account *Account) DecreaseBalance(amount uint64, timestamp uint32) bool

func (*Account) IncreaseBalance

func (account *Account) IncreaseBalance(amount uint64, timestamp uint32)

func (*Account) SetInterestRate

func (account *Account) SetInterestRate(interest uint16, timestamp uint32)

func (*Account) SetType

func (account *Account) SetType(accountType umi.AccountType)

func (*Account) UpdateBalance

func (account *Account) UpdateBalance(timestamp uint32)

type Confirmer

type Confirmer struct {
	sync.RWMutex

	// Абсолютная высота транзакции в блокчейне. Удобно использовать для синхронизации.
	TransactionHeight uint64
	// Время создания блока. По этой временной метке считаются балансы.
	BlockTimestamp uint32
	// Высота блока в блокчейне.
	BlockHeight uint32
	// Хэш обрабатываемого блока. После коммита это будет LastBlockHash.
	BlockHash umi.Hash
	// Хэш последнего обработанного леджером блока. На случай если во время обаботки данные поменяются.
	PrevBlockHash umi.Hash
	// contains filtered or unexported fields
}

func NewConfirmer

func NewConfirmer(ledger *Ledger) *Confirmer

func (*Confirmer) Account

func (confirmer *Confirmer) Account(address umi.Address) (account *Account, ok bool)

func (*Confirmer) AppendBlock

func (confirmer *Confirmer) AppendBlock(block []byte) error

func (*Confirmer) AvailableBalance

func (confirmer *Confirmer) AvailableBalance(address umi.Address, account *Account) uint64

func (*Confirmer) Commit

func (confirmer *Confirmer) Commit() error

func (*Confirmer) ProcessBlock

func (confirmer *Confirmer) ProcessBlock(blockRaw []byte) error

func (*Confirmer) ResetState

func (confirmer *Confirmer) ResetState()

func (*Confirmer) SetBlockchain

func (confirmer *Confirmer) SetBlockchain(blockchain iBlockchain)

func (*Confirmer) Structure

func (confirmer *Confirmer) Structure(prefix umi.Prefix) (structure *Structure, ok bool)

type ConfirmerLegacy

type ConfirmerLegacy struct {
	Confirmer
}

func NewConfirmerLegacy

func NewConfirmerLegacy(ledger *Ledger) *ConfirmerLegacy

func (*ConfirmerLegacy) AppendBlockLegacy

func (confirmer *ConfirmerLegacy) AppendBlockLegacy(blockLegacyRaw []byte) error

func (*ConfirmerLegacy) ProcessActivateTransitLegacy

func (confirmer *ConfirmerLegacy) ProcessActivateTransitLegacy(transaction umi.Transaction) (umi.Transaction, error)

func (*ConfirmerLegacy) ProcessBlockLegacy

func (confirmer *ConfirmerLegacy) ProcessBlockLegacy(blockLegacyRaw []byte) (umi.Block, error)

func (*ConfirmerLegacy) ProcessBurnLegacy

func (confirmer *ConfirmerLegacy) ProcessBurnLegacy(transaction umi.Transaction) (umi.Transaction, error)

func (*ConfirmerLegacy) ProcessChangeFeeAddressLegacy

func (confirmer *ConfirmerLegacy) ProcessChangeFeeAddressLegacy(transaction umi.Transaction) (umi.Transaction, error)

func (*ConfirmerLegacy) ProcessChangeProfitAddressLegacy

func (confirmer *ConfirmerLegacy) ProcessChangeProfitAddressLegacy(
	transaction umi.Transaction) (umi.Transaction, error)

func (*ConfirmerLegacy) ProcessCreateStructureLegacy

func (confirmer *ConfirmerLegacy) ProcessCreateStructureLegacy(transaction umi.Transaction) (umi.Transaction, error)

func (*ConfirmerLegacy) ProcessDeactivateTransitLegacy

func (confirmer *ConfirmerLegacy) ProcessDeactivateTransitLegacy(transaction umi.Transaction) (umi.Transaction, error)

func (*ConfirmerLegacy) ProcessIssueLegacy

func (confirmer *ConfirmerLegacy) ProcessIssueLegacy(transaction umi.Transaction) (umi.Transaction, error)

func (*ConfirmerLegacy) ProcessMintNftWitnessLegacy

func (confirmer *ConfirmerLegacy) ProcessMintNftWitnessLegacy(transaction umi.Transaction) (umi.Transaction, error)

func (*ConfirmerLegacy) ProcessSendLegacy

func (confirmer *ConfirmerLegacy) ProcessSendLegacy(transaction umi.Transaction) (umi.Transaction, error)

func (*ConfirmerLegacy) ProcessUpdateStructureLegacy

func (confirmer *ConfirmerLegacy) ProcessUpdateStructureLegacy(transaction umi.Transaction) (umi.Transaction, error)

type Ledger

type Ledger struct {
	sync.RWMutex

	LastBlockTimestamp    uint32
	LastBlockHeight       uint32
	LastBlockHash         umi.Hash
	LastTransactionHeight uint64
	// contains filtered or unexported fields
}

func NewLedger

func NewLedger(conf *config.Config) *Ledger

func (*Ledger) Account

func (ledger *Ledger) Account(address umi.Address) (account *Account, ok bool)

func (*Ledger) HasTransaction

func (ledger *Ledger) HasTransaction(hash umi.Hash) bool

func (*Ledger) NftsByAddr

func (ledger *Ledger) NftsByAddr(addr umi.Address) []umi.Hash

func (*Ledger) Structure

func (ledger *Ledger) Structure(prefix umi.Prefix) (structure *Structure, ok bool)

func (*Ledger) Structures

func (ledger *Ledger) Structures() (structures []*Structure)

type Structure

type Structure struct {
	CreatedAt uint32

	Prefix        umi.Prefix
	Description   string
	ProfitPercent uint16
	FeePercent    uint16

	MasterAddress umi.Address
	FeeAddress    umi.Address
	ProfitAddress umi.Address
	DevAddress    umi.Address

	AddressCount int

	Balance   uint64
	UpdatedAt uint32

	Level             uint8
	LevelInterestRate uint16
	// contains filtered or unexported fields
}

func NewStructure

func NewStructure(network string, prefix umi.Prefix, masterAddr umi.Address) *Structure

func (*Structure) BalanceAt

func (structure *Structure) BalanceAt(timestamp uint32) uint64

func (*Structure) DecreaseBalance

func (structure *Structure) DecreaseBalance(amount uint64, timestamp uint32)

func (*Structure) IncreaseBalance

func (structure *Structure) IncreaseBalance(amount uint64, timestamp uint32)

func (*Structure) InterestRate

func (structure *Structure) InterestRate(accountType umi.AccountType) uint16

func (*Structure) IsOwner

func (structure *Structure) IsOwner(addr umi.Address) bool

func (*Structure) MarshalJSON

func (structure *Structure) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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