Documentation ¶
Index ¶
- Constants
- Variables
- type AddKeyRequest
- type BalanceResponse
- type Bill
- type BillStore
- type Bills
- type BlockHeightResponse
- type BlockProcessor
- type BoltBillStore
- func (s *BoltBillStore) AddKey(k *Pubkey) error
- func (s *BoltBillStore) ContainsBill(pubkey []byte, unitID []byte) (bool, error)
- func (s *BoltBillStore) DeleteExpiredBills(blockNumber uint64) error
- func (s *BoltBillStore) GetBill(pubkey []byte, unitID []byte) (*Bill, error)
- func (s *BoltBillStore) GetBills(pubkey []byte) ([]*Bill, error)
- func (s *BoltBillStore) GetBlockNumber() (uint64, error)
- func (s *BoltBillStore) GetKey(pubkey []byte) (*Pubkey, error)
- func (s *BoltBillStore) GetKeys() ([]*Pubkey, error)
- func (s *BoltBillStore) RemoveBill(pubkey []byte, unitID []byte) error
- func (s *BoltBillStore) SetBillExpirationTime(blockNumber uint64, pubkey []byte, unitID []byte) error
- func (s *BoltBillStore) SetBills(pubkey []byte, bills ...*Bill) error
- func (s *BoltBillStore) SetBlockNumber(blockNumber uint64) error
- type EmptyResponse
- type ErrorResponse
- type ListBillVM
- type ListBillsResponse
- type Pubkey
- type RequestHandler
- type TxConverter
- type TxProof
- type WalletBackend
- func (w *WalletBackend) AddKey(pubkey []byte) error
- func (w *WalletBackend) GetBill(pubkey []byte, unitID []byte) (*Bill, error)
- func (w *WalletBackend) GetBills(pubkey []byte) ([]*Bill, error)
- func (w *WalletBackend) GetMaxBlockNumber() (uint64, error)
- func (w *WalletBackend) SetBills(pubkey []byte, bills *block.Bills) 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"
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AddKeyRequest ¶
type AddKeyRequest struct {
Pubkey string `json:"pubkey"`
}
type BalanceResponse ¶
type BalanceResponse struct {
Balance uint64 `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"` }
type BillStore ¶
type BillStore interface { GetBlockNumber() (uint64, error) SetBlockNumber(blockNumber uint64) error GetBills(pubKey []byte) ([]*Bill, error) RemoveBill(pubKey []byte, id []byte) error ContainsBill(pubkey []byte, unitID []byte) (bool, error) GetBill(pubkey []byte, unitID []byte) (*Bill, error) SetBills(pubkey []byte, bills ...*Bill) error SetBillExpirationTime(blockNumber uint64, pubkey []byte, unitID []byte) error DeleteExpiredBills(blockNumber uint64) error GetKeys() ([]*Pubkey, error) GetKey(pubkey []byte) (*Pubkey, error) AddKey(key *Pubkey) error }
type BlockHeightResponse ¶
type BlockHeightResponse struct {
BlockHeight uint64 `json:"blockHeight"`
}
type BlockProcessor ¶
type BlockProcessor struct {
// contains filtered or unexported fields
}
func NewBlockProcessor ¶
func NewBlockProcessor(store BillStore) *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) AddKey ¶
func (s *BoltBillStore) AddKey(k *Pubkey) error
func (*BoltBillStore) ContainsBill ¶
func (s *BoltBillStore) ContainsBill(pubkey []byte, unitID []byte) (bool, error)
func (*BoltBillStore) DeleteExpiredBills ¶
func (s *BoltBillStore) DeleteExpiredBills(blockNumber uint64) error
func (*BoltBillStore) GetBill ¶
func (s *BoltBillStore) GetBill(pubkey []byte, unitID []byte) (*Bill, error)
func (*BoltBillStore) GetBlockNumber ¶
func (s *BoltBillStore) GetBlockNumber() (uint64, error)
func (*BoltBillStore) GetKeys ¶
func (s *BoltBillStore) GetKeys() ([]*Pubkey, error)
func (*BoltBillStore) RemoveBill ¶
func (s *BoltBillStore) RemoveBill(pubkey []byte, unitID []byte) error
func (*BoltBillStore) SetBillExpirationTime ¶
func (s *BoltBillStore) SetBillExpirationTime(blockNumber uint64, pubkey []byte, unitID []byte) error
func (*BoltBillStore) SetBills ¶
func (s *BoltBillStore) SetBills(pubkey []byte, bills ...*Bill) error
func (*BoltBillStore) SetBlockNumber ¶
func (s *BoltBillStore) SetBlockNumber(blockNumber uint64) error
type EmptyResponse ¶
type EmptyResponse struct{}
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
}
type ListBillVM ¶
type ListBillsResponse ¶
type ListBillsResponse struct { Total int `json:"total"` Bills []*ListBillVM `json:"bills"` }
type Pubkey ¶
type RequestHandler ¶
type RequestHandler struct {
// contains filtered or unexported fields
}
type TxConverter ¶
type TxConverter struct { }
func (*TxConverter) ConvertTx ¶
func (t *TxConverter) ConvertTx(tx *txsystem.Transaction) (txsystem.GenericTransaction, error)
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, verifiers map[string]abcrypto.Verifier) *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) AddKey ¶
func (w *WalletBackend) AddKey(pubkey []byte) error
AddKey adds new public key to list of tracked keys. Returns ErrKeyAlreadyExists error if key already exists.
func (*WalletBackend) GetBill ¶
func (w *WalletBackend) GetBill(pubkey []byte, 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() (uint64, error)
GetMaxBlockNumber returns max block number known to the connected AB node.
func (*WalletBackend) SetBills ¶
func (w *WalletBackend) SetBills(pubkey []byte, bills *block.Bills) error
SetBill adds new bill to the index. Bill most have a valid block proof. Overwrites existing bill, if one exists. Returns error if given pubkey is not indexed.
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 }
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