backend

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DustBillDeletionTimeout    = 65536
	ExpiredBillDeletionTimeout = 65536
)
View Source
const BoltBillStoreFileName = "bills.db"

Variables

View Source
var (
	ErrOwnerPredicateIsNil = errors.New("unit owner predicate is nil")
)

Functions

func Run

func Run(ctx context.Context, config *Config) error

Types

type ABClient

type ABClient interface {
	SendTransaction(ctx context.Context, tx *types.TransactionOrder) error
	GetRoundNumber(ctx context.Context) (uint64, error)
}

type AddKeyRequest

type AddKeyRequest struct {
	Pubkey string `json:"pubkey"`
}

type BalanceResponse

type BalanceResponse struct {
	Balance uint64 `json:"balance,string"`
}

type Bill

type Bill struct {
	Id                   []byte         `json:"id"`
	Value                uint64         `json:"value"`
	TxHash               []byte         `json:"txHash"`
	DCTargetUnitID       []byte         `json:"dcTargetUnitId,omitempty"`
	DCTargetUnitBacklink []byte         `json:"dcTargetUnitBacklink,omitempty"`
	OwnerPredicate       []byte         `json:"ownerPredicate"`
	Locked               sdk.LockReason `json:"locked"`
}

func (*Bill) IsDCBill

func (b *Bill) IsDCBill() bool

func (*Bill) ToGenericBill

func (b *Bill) ToGenericBill() *sdk.Bill

func (*Bill) ToGenericBills

func (b *Bill) ToGenericBills() *sdk.Bills

type BillStore

type BillStore interface {
	Do() BillStoreTx
	WithTransaction(func(tx BillStoreTx) error) error
}

BillStore type for creating BillStoreTx transactions

type BillStoreTx

type BillStoreTx interface {
	GetBlockNumber() (uint64, error)
	SetBlockNumber(blockNumber uint64) error
	GetBill(unitID []byte) (*Bill, error)
	GetBills(ownerCondition []byte, includeDCBills bool, offsetKey []byte, limit int) ([]*Bill, []byte, error)
	SetBill(bill *Bill, proof *sdk.Proof) error
	RemoveBill(unitID []byte) error
	SetBillExpirationTime(blockNumber uint64, unitID []byte) error
	DeleteExpiredBills(blockNumber uint64) error
	GetFeeCreditBill(unitID []byte) (*Bill, error)
	SetFeeCreditBill(fcb *Bill, proof *sdk.Proof) error
	GetSystemDescriptionRecords() ([]*genesis.SystemDescriptionRecord, error)
	SetSystemDescriptionRecords(sdrs []*genesis.SystemDescriptionRecord) error
	GetTxProof(unitID types.UnitID, txHash sdk.TxHash) (*sdk.Proof, error)
	StoreTxHistoryRecord(hash sdk.PubKeyHash, rec *sdk.TxHistoryRecord) error
	GetTxHistoryRecords(hash sdk.PubKeyHash, dbStartKey []byte, count int) ([]*sdk.TxHistoryRecord, []byte, error)
	StoreTxProof(unitID types.UnitID, txHash sdk.TxHash, txProof *sdk.Proof) error
}

BillStoreTx type for managing units by their ID and owner condition

type Bills

type Bills struct {
	Bills []*Bill `json:"bills"`
}

type BlockProcessor

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

func NewBlockProcessor

func NewBlockProcessor(store BillStore, moneySystemID types.SystemID, log *slog.Logger) (*BlockProcessor, error)

func (*BlockProcessor) ProcessBlock

func (p *BlockProcessor) ProcessBlock(ctx context.Context, b *types.Block) error

type Config

type Config struct {
	ABMoneySystemIdentifier  types.SystemID
	AlphabillUrl             string
	ServerAddr               string
	DbFile                   string
	ListBillsPageLimit       int
	InitialBill              InitialBill
	SystemDescriptionRecords []*genesis.SystemDescriptionRecord
	Logger                   *slog.Logger
	Observe                  Observability
}

type InitialBill

type InitialBill struct {
	Id        []byte
	Value     uint64
	Predicate []byte
}

type ListBillsResponse

type ListBillsResponse struct {
	Bills []*sdk.Bill `json:"bills"`
}

type Observability

type Observability interface {
	Tracer(name string, options ...trace.TracerOption) trace.Tracer
	TracerProvider() trace.TracerProvider
	Logger() *slog.Logger
}

type Pubkey

type Pubkey struct {
	Pubkey     []byte             `json:"pubkey"`
	PubkeyHash *account.KeyHashes `json:"pubkeyHash"`
}

type WalletBackend

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

func (*WalletBackend) GetBill

func (w *WalletBackend) GetBill(unitID []byte) (*Bill, error)

GetBill returns most recently seen bill with given unit id.

func (*WalletBackend) GetBills

func (w *WalletBackend) GetBills(pubkey []byte, includeDCBills bool, offsetKey []byte, limit int) ([]*Bill, []byte, error)

GetBills returns first N=limit bills for given owner predicate starting from the offsetKey or if offsetKey is nil then starting from the very first key. Always returns the next key if it exists i.e. even if limit=0. Furthermore, the next key might not match the filter (isDCBill).

func (*WalletBackend) GetFeeCreditBill

func (w *WalletBackend) GetFeeCreditBill(unitID []byte) (*Bill, error)

GetFeeCreditBill returns most recently seen fee credit bill with given unit id.

func (*WalletBackend) GetRoundNumber

func (w *WalletBackend) GetRoundNumber(ctx context.Context) (*sdk.RoundNumber, error)

GetRoundNumber returns the latest round number in node and backend.

func (*WalletBackend) GetTxHistoryRecords

func (w *WalletBackend) GetTxHistoryRecords(hash sdk.PubKeyHash, dbStartKey []byte, count int) ([]*sdk.TxHistoryRecord, []byte, error)

func (*WalletBackend) GetTxProof

func (w *WalletBackend) GetTxProof(unitID types.UnitID, txHash sdk.TxHash) (*sdk.Proof, error)

func (*WalletBackend) HandleTransactionsSubmission

func (w *WalletBackend) HandleTransactionsSubmission(egp *errgroup.Group, sender sdk.PubKey, txs []*types.TransactionOrder)

func (*WalletBackend) SendTransactions

func (w *WalletBackend) SendTransactions(ctx context.Context, txs []*types.TransactionOrder) map[string]string

TODO: Share functionaly with tokens partiton SendTransactions forwards transactions to partiton node(s).

type WalletBackendService

type WalletBackendService interface {
	GetBills(pubKey []byte, includeDCBills bool, offsetKey []byte, limit int) ([]*Bill, []byte, error)
	GetBill(unitID []byte) (*Bill, error)
	GetFeeCreditBill(unitID []byte) (*Bill, error)
	GetRoundNumber(ctx context.Context) (*sdk.RoundNumber, error)
	SendTransactions(ctx context.Context, txs []*types.TransactionOrder) map[string]string
	GetTxProof(unitID types.UnitID, txHash sdk.TxHash) (*sdk.Proof, error)
	HandleTransactionsSubmission(egp *errgroup.Group, sender sdk.PubKey, txs []*types.TransactionOrder)
	GetTxHistoryRecords(hash sdk.PubKeyHash, dbStartKey []byte, count int) ([]*sdk.TxHistoryRecord, []byte, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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