Documentation ¶
Index ¶
- Constants
- Variables
- func CreateAndRun(ctx context.Context, config *Config) error
- func NewTxConverter(systemId []byte) *txConverter
- type AddKeyRequest
- type BalanceResponse
- type Bill
- type BillStore
- type BillStoreTx
- type Bills
- type BlockHeightResponse
- type BlockProcessor
- type BoltBillStore
- type BoltBillStoreTx
- func (s *BoltBillStoreTx) DeleteExpiredBills(blockNumber uint64) error
- func (s *BoltBillStoreTx) GetBill(unitID []byte) (*Bill, error)
- func (s *BoltBillStoreTx) GetBills(ownerPredicate []byte) ([]*Bill, error)
- func (s *BoltBillStoreTx) GetBlockNumber() (uint64, error)
- func (s *BoltBillStoreTx) RemoveBill(unitID []byte) error
- func (s *BoltBillStoreTx) SetBill(bill *Bill) error
- func (s *BoltBillStoreTx) SetBillExpirationTime(blockNumber uint64, unitID []byte) error
- func (s *BoltBillStoreTx) SetBlockNumber(blockNumber uint64) error
- type Config
- type EmptyResponse
- type ErrorResponse
- type GenericWalletBackendHttpServer
- type ListBillVM
- type ListBillsResponse
- type Pubkey
- type RequestHandler
- type TxProof
- type WalletBackend
- func (w *WalletBackend) GetBill(unitID []byte) (*Bill, error)
- func (w *WalletBackend) GetBills(pubkey []byte) ([]*Bill, error)
- func (w *WalletBackend) GetMaxBlockNumber(ctx context.Context) (uint64, error)
- func (w *WalletBackend) Shutdown()
- func (w *WalletBackend) Start(ctx context.Context) error
- func (w *WalletBackend) StartProcess(ctx context.Context)
- type WalletBackendHttpServer
- type WalletBackendService
Constants ¶
const BoltBillStoreFileName = "bills.db"
const DustBillDeletionTimeout = 65536
Variables ¶
var (
ErrOwnerPredicateIsNil = errors.New("unit owner predicate is nil")
)
Functions ¶
func NewTxConverter ¶
func NewTxConverter(systemId []byte) *txConverter
Types ¶
type AddKeyRequest ¶
type AddKeyRequest struct {
Pubkey string `json:"pubkey"`
}
type BalanceResponse ¶
type BalanceResponse struct {
Balance string `json:"balance"`
}
type Bill ¶
type Bill struct { Id []byte `json:"id"` Value uint64 `json:"value"` TxHash []byte `json:"txHash"` IsDCBill bool `json:"isDcBill"` // OrderNumber insertion order of given bill in pubkey => list of bills bucket, needed for determistic paging OrderNumber uint64 `json:"orderNumber"` TxProof *TxProof `json:"txProof"` OwnerPredicate []byte `json:"OwnerPredicate"` }
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) ([]*Bill, error) SetBill(bill *Bill) error RemoveBill(unitID []byte) error SetBillExpirationTime(blockNumber uint64, unitID []byte) error DeleteExpiredBills(blockNumber uint64) error }
BillStoreTx type for managing units by their ID and owner condition
type BlockHeightResponse ¶
type BlockHeightResponse struct {
BlockHeight string `json:"blockHeight"`
}
type BlockProcessor ¶
type BlockProcessor struct { TxConverter block.TxConverter // contains filtered or unexported fields }
func NewBlockProcessor ¶
func NewBlockProcessor(store BillStore, txConverter block.TxConverter) *BlockProcessor
func (*BlockProcessor) ProcessBlock ¶
func (p *BlockProcessor) ProcessBlock(b *block.Block) error
type BoltBillStore ¶
type BoltBillStore struct {
// contains filtered or unexported fields
}
func NewBoltBillStore ¶
func NewBoltBillStore(dbFile string) (*BoltBillStore, error)
NewBoltBillStore creates new on-disk persistent storage for bills and proofs using bolt db. If the file does not exist then it will be created, however, parent directories must exist beforehand.
func (*BoltBillStore) Do ¶
func (s *BoltBillStore) Do() BillStoreTx
func (*BoltBillStore) WithTransaction ¶
func (s *BoltBillStore) WithTransaction(fn func(txc BillStoreTx) error) error
type BoltBillStoreTx ¶
type BoltBillStoreTx struct {
// contains filtered or unexported fields
}
func (*BoltBillStoreTx) DeleteExpiredBills ¶
func (s *BoltBillStoreTx) DeleteExpiredBills(blockNumber uint64) error
func (*BoltBillStoreTx) GetBills ¶
func (s *BoltBillStoreTx) GetBills(ownerPredicate []byte) ([]*Bill, error)
func (*BoltBillStoreTx) GetBlockNumber ¶
func (s *BoltBillStoreTx) GetBlockNumber() (uint64, error)
func (*BoltBillStoreTx) RemoveBill ¶
func (s *BoltBillStoreTx) RemoveBill(unitID []byte) error
func (*BoltBillStoreTx) SetBill ¶
func (s *BoltBillStoreTx) SetBill(bill *Bill) error
func (*BoltBillStoreTx) SetBillExpirationTime ¶
func (s *BoltBillStoreTx) SetBillExpirationTime(blockNumber uint64, unitID []byte) error
func (*BoltBillStoreTx) SetBlockNumber ¶
func (s *BoltBillStoreTx) SetBlockNumber(blockNumber uint64) error
type EmptyResponse ¶
type EmptyResponse struct{}
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
}
type GenericWalletBackendHttpServer ¶
type GenericWalletBackendHttpServer struct {
Handler RequestHandler
}
@BasePath /api/v1
type ListBillVM ¶
type ListBillVM struct { Id []byte `json:"id" swaggertype:"string" format:"base64" example:"AAAAAAgwv3UA1HfGO4qc1T3I3EOvqxfcrhMjJpr9Tn4="` Value string `json:"value" example:"1000"` TxHash []byte `json:"txHash" swaggertype:"string" format:"base64" example:"Q4ShCITC0ODXPR+j1Zl/teYcoU3/mAPy0x8uSsvQFM8="` IsDCBill bool `json:"isDcBill" example:"false"` }
type ListBillsResponse ¶
type ListBillsResponse struct { Total int `json:"total" example:"1"` Bills []*ListBillVM `json:"bills"` }
type RequestHandler ¶
type RequestHandler struct { Service WalletBackendService ListBillsPageLimit int }
func (*RequestHandler) Router ¶
func (s *RequestHandler) Router() *mux.Router
type TxProof ¶
type TxProof struct { BlockNumber uint64 `json:"blockNumber"` Tx *txsystem.Transaction `json:"tx"` Proof *block.BlockProof `json:"proof"` }
type WalletBackend ¶
type WalletBackend struct {
// contains filtered or unexported fields
}
func New ¶
func New(wallet *wallet.Wallet, store BillStore) *WalletBackend
New creates a new wallet backend Service which can be started by calling the Start or StartProcess method. Shutdown method should be called to close resources used by the Service.
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) ([]*Bill, error)
GetBills returns all bills for given public key.
func (*WalletBackend) GetMaxBlockNumber ¶
func (w *WalletBackend) GetMaxBlockNumber(ctx context.Context) (uint64, error)
GetMaxBlockNumber returns max block number known to the connected AB node.
func (*WalletBackend) Shutdown ¶
func (w *WalletBackend) Shutdown()
Shutdown terminates wallet backend Service.
func (*WalletBackend) Start ¶
func (w *WalletBackend) Start(ctx context.Context) error
Start starts downloading blocks and indexing bills by their owner's public key. Blocks forever or until alphabill connection is terminated.
func (*WalletBackend) StartProcess ¶
func (w *WalletBackend) StartProcess(ctx context.Context)
StartProcess calls Start in a retry loop, can be canceled by cancelling context or calling Shutdown method.
type WalletBackendHttpServer ¶
type WalletBackendHttpServer struct { Handler RequestHandler // contains filtered or unexported fields }
@BasePath /api/v1
func NewHttpServer ¶
func NewHttpServer(addr string, listBillsPageLimit int, service WalletBackendService) *WalletBackendHttpServer
func (*WalletBackendHttpServer) Shutdown ¶
func (s *WalletBackendHttpServer) Shutdown(ctx context.Context) error
func (*WalletBackendHttpServer) Start ¶
func (s *WalletBackendHttpServer) Start() error