transactions

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

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

func NewAccount

func NewAccount(id util.Address) *Account

func ParseAccount

func ParseAccount(id util.Address, data []byte) (*Account, error)

func (*Account) AccountChanged

func (a *Account) AccountChanged(data []byte) bool

func (*Account) Add

func (a *Account) Add(token util.TokenSymbol, amount *big.Int) error

func (*Account) Balance

func (a *Account) Balance() *big.Int

func (*Account) BalanceOf

func (a *Account) BalanceOf(token util.TokenSymbol) *big.Int

func (*Account) Borrow

func (a *Account) Borrow(
	token util.TokenSymbol,
	from util.Address,
	amount *big.Int,
	dueTime uint64,
) error

func (*Account) CheckAsFrom

func (a *Account) CheckAsFrom(txType ld.TxType) error

func (*Account) CheckAsTo

func (a *Account) CheckAsTo(txType ld.TxType) error

func (*Account) CheckBalance

func (a *Account) CheckBalance(token util.TokenSymbol, amount *big.Int) error

func (*Account) CloseLending

func (a *Account) CloseLending() error

func (*Account) CreateStake

func (a *Account) CreateStake(
	from util.Address,
	pledge *big.Int,
	acc *ld.TxAccounter,
	cfg *ld.StakeConfig,
) error

func (*Account) CreateToken

func (a *Account) CreateToken(data *ld.TxAccounter) error

func (*Account) DestroyStake

func (a *Account) DestroyStake(recipient *Account) error

func (*Account) DestroyToken

func (a *Account) DestroyToken(recipient *Account) error

func (*Account) GetStakeAmount

func (a *Account) GetStakeAmount(token util.TokenSymbol, from util.Address) *big.Int

func (*Account) ID

func (a *Account) ID() util.Address

func (*Account) IDKey

func (a *Account) IDKey() signer.Key

func (*Account) Init

func (a *Account) Init(pledge *big.Int, height, timestamp uint64) *Account

func (*Account) InitLedger

func (a *Account) InitLedger(data []byte) error

func (*Account) IsEmpty

func (a *Account) IsEmpty() bool

func (*Account) Keepers

func (a *Account) Keepers() signer.Keys

func (*Account) LD

func (a *Account) LD() *ld.Account

func (*Account) Ledger

func (a *Account) Ledger() *ld.AccountLedger

func (*Account) LedgerChanged

func (a *Account) LedgerChanged(data []byte) bool

func (*Account) Marshal

func (a *Account) Marshal() ([]byte, []byte, error)

func (*Account) Nonce

func (a *Account) Nonce() uint64

func (*Account) OpenLending

func (a *Account) OpenLending(cfg *ld.LendingConfig) error

func (*Account) Repay

func (a *Account) Repay(
	token util.TokenSymbol,
	from util.Address,
	amount *big.Int,
) (*big.Int, error)

func (*Account) ResetStake

func (a *Account) ResetStake(cfg *ld.StakeConfig) error

func (*Account) Sub

func (a *Account) Sub(token util.TokenSymbol, amount *big.Int) error

func (*Account) SubByNonce

func (a *Account) SubByNonce(
	token util.TokenSymbol,
	nonce uint64,
	amount *big.Int,
) error

func (*Account) SubByNonceTable

func (a *Account) SubByNonceTable(
	token util.TokenSymbol,
	expire, nonce uint64,
	amount *big.Int) error

func (*Account) TakeStake

func (a *Account) TakeStake(
	token util.TokenSymbol,
	from util.Address,
	amount *big.Int,
	lockTime uint64) error

func (*Account) Threshold

func (a *Account) Threshold() uint16

func (*Account) TotalSupply

func (a *Account) TotalSupply() *big.Int

func (*Account) Type

func (a *Account) Type() ld.AccountType

func (*Account) UpdateKeepers

func (a *Account) UpdateKeepers(
	threshold *uint16,
	keepers *signer.Keys,
	approver *signer.Key,
	approveList *ld.TxTypes,
) error

func (*Account) UpdateNonceTable

func (a *Account) UpdateNonceTable(expire uint64, ns []uint64) error

func (*Account) UpdateStakeApprover

func (a *Account) UpdateStakeApprover(
	from util.Address,
	approver signer.Key,
	txIsApprovedFn ld.TxIsApprovedFn,
) error

func (*Account) Valid

func (a *Account) Valid(t ld.AccountType) bool

func (*Account) ValidValidator

func (a *Account) ValidValidator() bool

func (*Account) Verify

func (a *Account) Verify(digestHash []byte, sigs signer.Sigs, accountKey signer.Key) bool

func (*Account) VerifyPlus

func (a *Account) VerifyPlus(digestHash []byte, sigs signer.Sigs, accountKey signer.Key) bool

func (*Account) WithdrawStake

func (a *Account) WithdrawStake(
	token util.TokenSymbol,
	from util.Address,
	amount *big.Int,
	txIsApprovedFn ld.TxIsApprovedFn,
) (*big.Int, error)

type AccountCache

type AccountCache map[util.Address]*Account

type ChainContext

type ChainContext interface {
	ChainConfig() *genesis.ChainConfig
	FeeConfig() *genesis.FeeConfig
	GasPrice() *big.Int
	Builder() util.StakeSymbol
}

type ChainState

type ChainState interface {
	Height() uint64
	Timestamp() uint64
	LoadAccount(util.Address) (*Account, error)
	LoadLedger(*Account) error
	LoadBuilder(util.StakeSymbol) (*Account, error)
	LoadModel(util.ModelID) (*ld.ModelInfo, error)
	SaveModel(*ld.ModelInfo) error
	LoadData(util.DataID) (*ld.DataInfo, error)
	SaveData(*ld.DataInfo) error
	SavePrevData(*ld.DataInfo) error
	DeleteData(*ld.DataInfo, []byte) error
	SaveName(*service.Name) error
	DeleteName(*service.Name) error
}

type GenesisTx

type GenesisTx interface {
	ApplyGenesis(ctx ChainContext, cs ChainState) error
}

type MockChainContext

type MockChainContext struct {
	Price     uint64
	BuilderID util.StakeSymbol
	// contains filtered or unexported fields
}

func NewMockChainContext

func NewMockChainContext() *MockChainContext

func (*MockChainContext) Builder

func (m *MockChainContext) Builder() util.StakeSymbol

func (*MockChainContext) ChainConfig

func (m *MockChainContext) ChainConfig() *genesis.ChainConfig

func (*MockChainContext) FeeConfig

func (m *MockChainContext) FeeConfig() *genesis.FeeConfig

func (*MockChainContext) GasPrice

func (m *MockChainContext) GasPrice() *big.Int

func (*MockChainContext) MockChainState

func (m *MockChainContext) MockChainState() *MockChainState

type MockChainState

type MockChainState struct {
	Fee *genesis.FeeConfig
	AC  AccountCache
	NC  map[string]util.DataID
	MC  map[util.ModelID][]byte
	DC  map[util.DataID][]byte
	PDC map[util.DataID][]byte
	// contains filtered or unexported fields
}

func (*MockChainState) CheckoutAccounts

func (m *MockChainState) CheckoutAccounts()

func (*MockChainState) CommitAccounts

func (m *MockChainState) CommitAccounts()

func (*MockChainState) DeleteData

func (m *MockChainState) DeleteData(di *ld.DataInfo, message []byte) error

func (*MockChainState) DeleteName

func (m *MockChainState) DeleteName(ns *service.Name) error

func (*MockChainState) Height

func (m *MockChainState) Height() uint64

func (*MockChainState) LoadAccount

func (m *MockChainState) LoadAccount(id util.Address) (*Account, error)

func (*MockChainState) LoadBuilder

func (m *MockChainState) LoadBuilder(id util.StakeSymbol) (*Account, error)

func (*MockChainState) LoadData

func (m *MockChainState) LoadData(id util.DataID) (*ld.DataInfo, error)

func (*MockChainState) LoadDataByName

func (m *MockChainState) LoadDataByName(name string) (*ld.DataInfo, error)

func (*MockChainState) LoadLedger

func (m *MockChainState) LoadLedger(acc *Account) error

func (*MockChainState) LoadModel

func (m *MockChainState) LoadModel(id util.ModelID) (*ld.ModelInfo, error)

func (*MockChainState) MustAccount

func (m *MockChainState) MustAccount(id util.Address) *Account

func (*MockChainState) SaveData

func (m *MockChainState) SaveData(di *ld.DataInfo) error

func (*MockChainState) SaveModel

func (m *MockChainState) SaveModel(mi *ld.ModelInfo) error

func (*MockChainState) SaveName

func (m *MockChainState) SaveName(ns *service.Name) error

func (*MockChainState) SavePrevData

func (m *MockChainState) SavePrevData(di *ld.DataInfo) error

func (*MockChainState) Timestamp

func (m *MockChainState) Timestamp() uint64

func (*MockChainState) VerifyState

func (m *MockChainState) VerifyState() error

type Transaction

type Transaction interface {
	LD() *ld.Transaction
	ID() util.Hash
	Type() ld.TxType
	Gas() uint64
	Bytes() []byte
	SyntacticVerify() error
	Apply(ctx ChainContext, cs ChainState) error
	MarshalJSON() ([]byte, error)
}

func NewGenesisTx

func NewGenesisTx(tx *ld.Transaction) (Transaction, error)

func NewTx

func NewTx(tx *ld.Transaction) (Transaction, error)

NewTx returns a stateful transaction from a ld.Transaction.

type TxBase

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

func (*TxBase) Apply

func (tx *TxBase) Apply(ctx ChainContext, cs ChainState) error

call after SyntacticVerify

func (*TxBase) Bytes

func (tx *TxBase) Bytes() []byte

func (*TxBase) Gas

func (tx *TxBase) Gas() uint64

func (*TxBase) ID

func (tx *TxBase) ID() util.Hash

func (*TxBase) LD

func (tx *TxBase) LD() *ld.Transaction

func (*TxBase) MarshalJSON

func (tx *TxBase) MarshalJSON() ([]byte, error)

func (*TxBase) SyntacticVerify

func (tx *TxBase) SyntacticVerify() error

func (*TxBase) Type

func (tx *TxBase) Type() ld.TxType

type TxBorrow

type TxBorrow struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxBorrow) Apply

func (tx *TxBorrow) Apply(ctx ChainContext, cs ChainState) error

func (*TxBorrow) MarshalJSON

func (tx *TxBorrow) MarshalJSON() ([]byte, error)

func (*TxBorrow) SyntacticVerify

func (tx *TxBorrow) SyntacticVerify() error

type TxCloseLending

type TxCloseLending struct {
	TxBase
}

func (*TxCloseLending) Apply

func (tx *TxCloseLending) Apply(ctx ChainContext, cs ChainState) error

func (*TxCloseLending) SyntacticVerify

func (tx *TxCloseLending) SyntacticVerify() error

type TxCreateData

type TxCreateData struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxCreateData) Apply

func (tx *TxCreateData) Apply(ctx ChainContext, cs ChainState) error

func (*TxCreateData) ApplyGenesis

func (tx *TxCreateData) ApplyGenesis(ctx ChainContext, cs ChainState) error

ApplyGenesis skipping signature verification

func (*TxCreateData) MarshalJSON

func (tx *TxCreateData) MarshalJSON() ([]byte, error)

func (*TxCreateData) SyntacticVerify

func (tx *TxCreateData) SyntacticVerify() error

TxCreateData{ID, Version, Threshold, Keepers, Data} no model keepers TxCreateData{ID, Version, To, Amount, Threshold, Keepers, Data, Expire} with model keepers

type TxCreateModel

type TxCreateModel struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxCreateModel) Apply

func (tx *TxCreateModel) Apply(ctx ChainContext, cs ChainState) error

func (*TxCreateModel) ApplyGenesis

func (tx *TxCreateModel) ApplyGenesis(ctx ChainContext, cs ChainState) error

ApplyGenesis skipping signature verification

func (*TxCreateModel) MarshalJSON

func (tx *TxCreateModel) MarshalJSON() ([]byte, error)

func (*TxCreateModel) SyntacticVerify

func (tx *TxCreateModel) SyntacticVerify() error

type TxCreateStake

type TxCreateStake struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxCreateStake) Apply

func (tx *TxCreateStake) Apply(ctx ChainContext, cs ChainState) error

func (*TxCreateStake) MarshalJSON

func (tx *TxCreateStake) MarshalJSON() ([]byte, error)

func (*TxCreateStake) SyntacticVerify

func (tx *TxCreateStake) SyntacticVerify() error

type TxCreateToken

type TxCreateToken struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxCreateToken) Apply

func (tx *TxCreateToken) Apply(ctx ChainContext, cs ChainState) error

func (*TxCreateToken) ApplyGenesis

func (tx *TxCreateToken) ApplyGenesis(ctx ChainContext, cs ChainState) error

ApplyGenesis skipping signature verification

func (*TxCreateToken) MarshalJSON

func (tx *TxCreateToken) MarshalJSON() ([]byte, error)

func (*TxCreateToken) SyntacticVerify

func (tx *TxCreateToken) SyntacticVerify() error

type TxDeleteData

type TxDeleteData struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxDeleteData) Apply

func (tx *TxDeleteData) Apply(ctx ChainContext, cs ChainState) error

func (*TxDeleteData) MarshalJSON

func (tx *TxDeleteData) MarshalJSON() ([]byte, error)

func (*TxDeleteData) SyntacticVerify

func (tx *TxDeleteData) SyntacticVerify() error

type TxDestroyStake

type TxDestroyStake struct {
	TxBase
}

func (*TxDestroyStake) Apply

func (tx *TxDestroyStake) Apply(ctx ChainContext, cs ChainState) error

func (*TxDestroyStake) SyntacticVerify

func (tx *TxDestroyStake) SyntacticVerify() error

type TxDestroyToken

type TxDestroyToken struct {
	TxBase
}

func (*TxDestroyToken) Apply

func (tx *TxDestroyToken) Apply(ctx ChainContext, cs ChainState) error

func (*TxDestroyToken) SyntacticVerify

func (tx *TxDestroyToken) SyntacticVerify() error

type TxEth

type TxEth struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxEth) SyntacticVerify

func (tx *TxEth) SyntacticVerify() error

type TxExchange

type TxExchange struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxExchange) Apply

func (tx *TxExchange) Apply(ctx ChainContext, cs ChainState) error

func (*TxExchange) MarshalJSON

func (tx *TxExchange) MarshalJSON() ([]byte, error)

func (*TxExchange) SyntacticVerify

func (tx *TxExchange) SyntacticVerify() error

type TxOpenLending

type TxOpenLending struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxOpenLending) Apply

func (tx *TxOpenLending) Apply(ctx ChainContext, cs ChainState) error

func (*TxOpenLending) MarshalJSON

func (tx *TxOpenLending) MarshalJSON() ([]byte, error)

func (*TxOpenLending) SyntacticVerify

func (tx *TxOpenLending) SyntacticVerify() error

type TxPunish

type TxPunish struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxPunish) Apply

func (tx *TxPunish) Apply(ctx ChainContext, cs ChainState) error

func (*TxPunish) MarshalJSON

func (tx *TxPunish) MarshalJSON() ([]byte, error)

func (*TxPunish) SyntacticVerify

func (tx *TxPunish) SyntacticVerify() error

type TxRepay

type TxRepay struct {
	TxBase
}

func (*TxRepay) Apply

func (tx *TxRepay) Apply(ctx ChainContext, cs ChainState) error

func (*TxRepay) SyntacticVerify

func (tx *TxRepay) SyntacticVerify() error

type TxResetStake

type TxResetStake struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxResetStake) Apply

func (tx *TxResetStake) Apply(ctx ChainContext, cs ChainState) error

func (*TxResetStake) MarshalJSON

func (tx *TxResetStake) MarshalJSON() ([]byte, error)

func (*TxResetStake) SyntacticVerify

func (tx *TxResetStake) SyntacticVerify() error

type TxTakeStake

type TxTakeStake struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxTakeStake) Apply

func (tx *TxTakeStake) Apply(ctx ChainContext, cs ChainState) error

func (*TxTakeStake) MarshalJSON

func (tx *TxTakeStake) MarshalJSON() ([]byte, error)

func (*TxTakeStake) SyntacticVerify

func (tx *TxTakeStake) SyntacticVerify() error

type TxTest

type TxTest struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxTest) Apply

func (tx *TxTest) Apply(ctx ChainContext, cs ChainState) error

call after SyntacticVerify

func (*TxTest) MarshalJSON

func (tx *TxTest) MarshalJSON() ([]byte, error)

func (*TxTest) SyntacticVerify

func (tx *TxTest) SyntacticVerify() error

type TxTransfer

type TxTransfer struct {
	TxBase
}

func (*TxTransfer) ApplyGenesis

func (tx *TxTransfer) ApplyGenesis(ctx ChainContext, cs ChainState) error

ApplyGenesis skipping signature verification

func (*TxTransfer) SyntacticVerify

func (tx *TxTransfer) SyntacticVerify() error

type TxTransferCash

type TxTransferCash struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxTransferCash) Apply

func (tx *TxTransferCash) Apply(ctx ChainContext, cs ChainState) error

func (*TxTransferCash) MarshalJSON

func (tx *TxTransferCash) MarshalJSON() ([]byte, error)

func (*TxTransferCash) SyntacticVerify

func (tx *TxTransferCash) SyntacticVerify() error

type TxTransferMultiple

type TxTransferMultiple struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxTransferMultiple) Apply

func (tx *TxTransferMultiple) Apply(ctx ChainContext, cs ChainState) error

Apply skipping signature verification

func (*TxTransferMultiple) MarshalJSON

func (tx *TxTransferMultiple) MarshalJSON() ([]byte, error)

func (*TxTransferMultiple) SyntacticVerify

func (tx *TxTransferMultiple) SyntacticVerify() error

type TxTransferPay

type TxTransferPay struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxTransferPay) Apply

func (tx *TxTransferPay) Apply(ctx ChainContext, cs ChainState) error

func (*TxTransferPay) MarshalJSON

func (tx *TxTransferPay) MarshalJSON() ([]byte, error)

func (*TxTransferPay) SyntacticVerify

func (tx *TxTransferPay) SyntacticVerify() error

type TxUpdateAccountInfo

type TxUpdateAccountInfo struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxUpdateAccountInfo) Apply

func (tx *TxUpdateAccountInfo) Apply(ctx ChainContext, cs ChainState) error

func (*TxUpdateAccountInfo) ApplyGenesis

func (tx *TxUpdateAccountInfo) ApplyGenesis(ctx ChainContext, cs ChainState) error

ApplyGenesis skipping signature verification

func (*TxUpdateAccountInfo) MarshalJSON

func (tx *TxUpdateAccountInfo) MarshalJSON() ([]byte, error)

func (*TxUpdateAccountInfo) SyntacticVerify

func (tx *TxUpdateAccountInfo) SyntacticVerify() error

type TxUpdateData

type TxUpdateData struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxUpdateData) Apply

func (tx *TxUpdateData) Apply(ctx ChainContext, cs ChainState) error

func (*TxUpdateData) MarshalJSON

func (tx *TxUpdateData) MarshalJSON() ([]byte, error)

func (*TxUpdateData) SyntacticVerify

func (tx *TxUpdateData) SyntacticVerify() error

type TxUpdateDataInfo

type TxUpdateDataInfo struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxUpdateDataInfo) Apply

func (tx *TxUpdateDataInfo) Apply(ctx ChainContext, cs ChainState) error

func (*TxUpdateDataInfo) MarshalJSON

func (tx *TxUpdateDataInfo) MarshalJSON() ([]byte, error)

func (*TxUpdateDataInfo) SyntacticVerify

func (tx *TxUpdateDataInfo) SyntacticVerify() error

type TxUpdateDataInfoByAuth

type TxUpdateDataInfoByAuth struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxUpdateDataInfoByAuth) Apply

func (*TxUpdateDataInfoByAuth) MarshalJSON

func (tx *TxUpdateDataInfoByAuth) MarshalJSON() ([]byte, error)

func (*TxUpdateDataInfoByAuth) SyntacticVerify

func (tx *TxUpdateDataInfoByAuth) SyntacticVerify() error

type TxUpdateModelInfo

type TxUpdateModelInfo struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxUpdateModelInfo) Apply

func (tx *TxUpdateModelInfo) Apply(ctx ChainContext, cs ChainState) error

func (*TxUpdateModelInfo) MarshalJSON

func (tx *TxUpdateModelInfo) MarshalJSON() ([]byte, error)

func (*TxUpdateModelInfo) SyntacticVerify

func (tx *TxUpdateModelInfo) SyntacticVerify() error

type TxUpdateNonceTable

type TxUpdateNonceTable struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxUpdateNonceTable) Apply

func (tx *TxUpdateNonceTable) Apply(ctx ChainContext, cs ChainState) error

func (*TxUpdateNonceTable) MarshalJSON

func (tx *TxUpdateNonceTable) MarshalJSON() ([]byte, error)

func (*TxUpdateNonceTable) SyntacticVerify

func (tx *TxUpdateNonceTable) SyntacticVerify() error

ApplyGenesis skipping signature verification

type TxUpdateStakeApprover

type TxUpdateStakeApprover struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxUpdateStakeApprover) Apply

func (*TxUpdateStakeApprover) MarshalJSON

func (tx *TxUpdateStakeApprover) MarshalJSON() ([]byte, error)

func (*TxUpdateStakeApprover) SyntacticVerify

func (tx *TxUpdateStakeApprover) SyntacticVerify() error

type TxUpgradeData

type TxUpgradeData struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxUpgradeData) Apply

func (tx *TxUpgradeData) Apply(ctx ChainContext, cs ChainState) error

func (*TxUpgradeData) MarshalJSON

func (tx *TxUpgradeData) MarshalJSON() ([]byte, error)

func (*TxUpgradeData) SyntacticVerify

func (tx *TxUpgradeData) SyntacticVerify() error

type TxWithdrawStake

type TxWithdrawStake struct {
	TxBase
	// contains filtered or unexported fields
}

func (*TxWithdrawStake) Apply

func (tx *TxWithdrawStake) Apply(ctx ChainContext, cs ChainState) error

func (*TxWithdrawStake) MarshalJSON

func (tx *TxWithdrawStake) MarshalJSON() ([]byte, error)

func (*TxWithdrawStake) SyntacticVerify

func (tx *TxWithdrawStake) SyntacticVerify() error

Jump to

Keyboard shortcuts

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