unitlock

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnitStoreDBFileName = "unitlock.db"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltStore

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

func NewBoltStore

func NewBoltStore(dbFile string) (*BoltStore, error)

func (*BoltStore) Close

func (s *BoltStore) Close() error

func (*BoltStore) DeleteUnit

func (s *BoltStore) DeleteUnit(accountID, unitID []byte) error

func (*BoltStore) GetUnit

func (s *BoltStore) GetUnit(accountID, unitID []byte) (*LockedUnit, error)

func (*BoltStore) GetUnits

func (s *BoltStore) GetUnits(accountID []byte) ([]*LockedUnit, error)

func (*BoltStore) PutUnit

func (s *BoltStore) PutUnit(unit *LockedUnit) error

type InMemoryUnitLocker

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

func NewInMemoryUnitLocker

func NewInMemoryUnitLocker() *InMemoryUnitLocker

func (*InMemoryUnitLocker) Close

func (m *InMemoryUnitLocker) Close() error

func (*InMemoryUnitLocker) GetUnit

func (m *InMemoryUnitLocker) GetUnit(accountID, unitID []byte) (*LockedUnit, error)

func (*InMemoryUnitLocker) GetUnits

func (m *InMemoryUnitLocker) GetUnits(accountID []byte) ([]*LockedUnit, error)

func (*InMemoryUnitLocker) LockUnit

func (m *InMemoryUnitLocker) LockUnit(lockedBill *LockedUnit) error

func (*InMemoryUnitLocker) UnlockUnit

func (m *InMemoryUnitLocker) UnlockUnit(accountID, unitID []byte) error

type LockReason

type LockReason uint
const (
	LockReasonAddFees LockReason = iota
	LockReasonReclaimFees
	LockReasonCollectDust
)

func (LockReason) String

func (r LockReason) String() string

type LockedUnit

type LockedUnit struct {
	AccountID    []byte         `json:"accountId"`    // account id of the unit e.g. a public key
	UnitID       []byte         `json:"unitId"`       // id of the locked unit
	TxHash       []byte         `json:"txHash"`       // state hash of the locked unit
	SystemID     []byte         `json:"systemId"`     // target system id of the locked unit
	LockReason   LockReason     `json:"lockReason"`   // reason for locking the bill
	Transactions []*Transaction `json:"transactions"` // transactions that must be confirmed/failed in order to unlock the bill
}

func NewLockedUnit

func NewLockedUnit(accountID, unitID, txHash, systemID []byte, lockReason LockReason, transactions ...*Transaction) *LockedUnit

type Transaction

type Transaction struct {
	TxOrder *types.TransactionOrder `json:"txOrder"`
	TxHash  []byte                  `json:"txHash"`
}

func NewTransaction

func NewTransaction(txo *types.TransactionOrder) *Transaction

type UnitLocker

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

func NewUnitLocker

func NewUnitLocker(dir string) (*UnitLocker, error)

func (*UnitLocker) Close

func (l *UnitLocker) Close() error

func (*UnitLocker) GetUnit

func (l *UnitLocker) GetUnit(accountID, unitID []byte) (*LockedUnit, error)

func (*UnitLocker) GetUnits

func (l *UnitLocker) GetUnits(accountID []byte) ([]*LockedUnit, error)

func (*UnitLocker) LockUnit

func (l *UnitLocker) LockUnit(unit *LockedUnit) error

func (*UnitLocker) UnlockUnit

func (l *UnitLocker) UnlockUnit(accountID, unitID []byte) error

type UnitStore

type UnitStore interface {
	GetUnit(accountID, unitID []byte) (*LockedUnit, error)
	GetUnits(accountID []byte) ([]*LockedUnit, error)
	PutUnit(unit *LockedUnit) error
	DeleteUnit(accountID, unitID []byte) error
	Close() error
}

Jump to

Keyboard shortcuts

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