Documentation ¶
Index ¶
- Constants
- Variables
- type AddFeeCmd
- type AddFeeCmdResponse
- type AddFeeCreditCtx
- type AddFeeTxProofs
- type BoltStore
- func (s *BoltStore) Close() error
- func (s *BoltStore) DeleteAddFeeContext(accountID []byte) error
- func (s *BoltStore) DeleteReclaimFeeContext(accountID []byte) error
- func (s *BoltStore) GetAddFeeContext(accountID []byte) (*AddFeeCreditCtx, error)
- func (s *BoltStore) GetReclaimFeeContext(accountID []byte) (*ReclaimFeeCreditCtx, error)
- func (s *BoltStore) SetAddFeeContext(accountID []byte, feeCtx *AddFeeCreditCtx) error
- func (s *BoltStore) SetReclaimFeeContext(accountID []byte, feeCtx *ReclaimFeeCreditCtx) error
- type FeeManager
- func (w *FeeManager) AddFeeCredit(ctx context.Context, cmd AddFeeCmd) (*AddFeeCmdResponse, error)
- func (w *FeeManager) Close()
- func (w *FeeManager) GetFeeCredit(ctx context.Context, cmd GetFeeCreditCmd) (*sdktypes.FeeCreditRecord, error)
- func (w *FeeManager) LockFeeCredit(ctx context.Context, cmd LockFeeCreditCmd) (*types.TxRecordProof, error)
- func (w *FeeManager) MinAddFeeAmount() uint64
- func (w *FeeManager) MinReclaimFeeAmount() uint64
- func (w *FeeManager) ReclaimFeeCredit(ctx context.Context, cmd ReclaimFeeCmd) (*ReclaimFeeCmdResponse, error)
- func (w *FeeManager) UnlockFeeCredit(ctx context.Context, cmd UnlockFeeCreditCmd) (*types.TxRecordProof, error)
- type FeeManagerDB
- type GenerateFcrID
- type GetFeeCreditCmd
- type LockFeeCreditCmd
- type ReclaimFeeCmd
- type ReclaimFeeCmdResponse
- type ReclaimFeeCreditCtx
- type ReclaimFeeTxProofs
- type UnlockFeeCreditCmd
Constants ¶
const (
FeeManagerDBFileName = "feemanager.db"
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AddFeeCmdResponse ¶
type AddFeeCmdResponse struct {
Proofs []*AddFeeTxProofs
}
type AddFeeCreditCtx ¶
type AddFeeCreditCtx struct { TargetPartitionID types.PartitionID `json:"targetPartitionId"` // target partition id where the fee is being added to TargetBillID types.UnitID `json:"targetBillId"` // transferFC target bill id TargetBillCounter uint64 `json:"targetBillCounter"` // transferFC target bill counter TargetAmount uint64 `json:"targetAmount"` // the amount to add to the fee credit record LockingDisabled bool `json:"lockingDisabled,omitempty"` // user defined flag if we should lock fee credit record when adding fees FeeCreditRecordID types.UnitID `json:"feeCreditRecordId,omitempty"` // the fee credit record id used in current fee credit process LockFCTx *types.TransactionOrder `json:"lockFCTx,omitempty"` LockFCProof *types.TxRecordProof `json:"lockFCProof,omitempty"` TransferFCTx *types.TransactionOrder `json:"transferFCTx,omitempty"` TransferFCProof *types.TxRecordProof `json:"transferFCProof,omitempty"` AddFCTx *types.TransactionOrder `json:"addFCTx,omitempty"` AddFCProof *types.TxRecordProof `json:"addFCProof,omitempty"` }
type AddFeeTxProofs ¶
type AddFeeTxProofs struct { LockFC *types.TxRecordProof TransferFC *types.TxRecordProof AddFC *types.TxRecordProof }
func (*AddFeeTxProofs) GetFees ¶
func (p *AddFeeTxProofs) GetFees() uint64
type BoltStore ¶
type BoltStore struct {
// contains filtered or unexported fields
}
func NewBoltStore ¶
func NewFeeManagerDB ¶
func (*BoltStore) DeleteAddFeeContext ¶
func (*BoltStore) DeleteReclaimFeeContext ¶
func (*BoltStore) GetAddFeeContext ¶
func (s *BoltStore) GetAddFeeContext(accountID []byte) (*AddFeeCreditCtx, error)
func (*BoltStore) GetReclaimFeeContext ¶
func (s *BoltStore) GetReclaimFeeContext(accountID []byte) (*ReclaimFeeCreditCtx, error)
func (*BoltStore) SetAddFeeContext ¶
func (s *BoltStore) SetAddFeeContext(accountID []byte, feeCtx *AddFeeCreditCtx) error
func (*BoltStore) SetReclaimFeeContext ¶
func (s *BoltStore) SetReclaimFeeContext(accountID []byte, feeCtx *ReclaimFeeCreditCtx) error
type FeeManager ¶
type FeeManager struct {
// contains filtered or unexported fields
}
func NewFeeManager ¶
func NewFeeManager( networkID types.NetworkID, am account.Manager, db FeeManagerDB, moneyPartitionID types.PartitionID, moneyClient sdktypes.MoneyPartitionClient, moneyPartitionFcrIDFn GenerateFcrID, targetPartitionPartitionID types.PartitionID, targetPartitionClient sdktypes.PartitionClient, targetPartitionFcrIDFn GenerateFcrID, maxFee uint64, log *slog.Logger, ) *FeeManager
NewFeeManager creates new fee credit manager. Parameters: - account manager - fee manager db
- money partition:
- partitionID
- rpc node client
- fee credit record id generation function
- fee credit record unit type part
- target partition:
- partitionID
- rpc node client
- fee credit record id generation function
- fee credit record unit type part
func (*FeeManager) AddFeeCredit ¶
func (w *FeeManager) AddFeeCredit(ctx context.Context, cmd AddFeeCmd) (*AddFeeCmdResponse, error)
AddFeeCredit creates fee credit for the given amount. If the wallet does not have a bill large enough for the required amount, multiple bills are used until the target amount is reached. In case of partial add (the add process was previously left in an incomplete state) only the partial bill is added to fee credit. Returns transaction proofs that were used to add credit.
func (*FeeManager) GetFeeCredit ¶
func (w *FeeManager) GetFeeCredit(ctx context.Context, cmd GetFeeCreditCmd) (*sdktypes.FeeCreditRecord, error)
GetFeeCredit returns fee credit record for given account, returns nil if fee credit record has not been created yet.
func (*FeeManager) LockFeeCredit ¶
func (w *FeeManager) LockFeeCredit(ctx context.Context, cmd LockFeeCreditCmd) (*types.TxRecordProof, error)
LockFeeCredit locks fee credit record for given account, returns error if fee credit record has not been created yet or is already locked.
func (*FeeManager) MinAddFeeAmount ¶
func (w *FeeManager) MinAddFeeAmount() uint64
func (*FeeManager) MinReclaimFeeAmount ¶
func (w *FeeManager) MinReclaimFeeAmount() uint64
func (*FeeManager) ReclaimFeeCredit ¶
func (w *FeeManager) ReclaimFeeCredit(ctx context.Context, cmd ReclaimFeeCmd) (*ReclaimFeeCmdResponse, error)
ReclaimFeeCredit reclaims fee credit i.e. reclaims entire fee credit record balance back to the main balance. Reclaimed fee credit is added to the largest bill in wallet. Returns transaction proofs that were used to reclaim fee credit.
func (*FeeManager) UnlockFeeCredit ¶
func (w *FeeManager) UnlockFeeCredit(ctx context.Context, cmd UnlockFeeCreditCmd) (*types.TxRecordProof, error)
UnlockFeeCredit unlocks fee credit record for given account, returns error if fee credit record has not been created yet or is already unlocked.
type FeeManagerDB ¶
type FeeManagerDB interface { GetAddFeeContext(accountID []byte) (*AddFeeCreditCtx, error) SetAddFeeContext(accountID []byte, feeCtx *AddFeeCreditCtx) error DeleteAddFeeContext(accountID []byte) error GetReclaimFeeContext(accountID []byte) (*ReclaimFeeCreditCtx, error) SetReclaimFeeContext(accountID []byte, feeCtx *ReclaimFeeCreditCtx) error DeleteReclaimFeeContext(accountID []byte) error Close() error }
type GenerateFcrID ¶
GenerateFcrID function to generate fee credit record ID
type GetFeeCreditCmd ¶
type GetFeeCreditCmd struct {
AccountIndex uint64
}
type LockFeeCreditCmd ¶
type ReclaimFeeCmd ¶
type ReclaimFeeCmdResponse ¶
type ReclaimFeeCmdResponse struct {
Proofs *ReclaimFeeTxProofs
}
type ReclaimFeeCreditCtx ¶
type ReclaimFeeCreditCtx struct { TargetPartitionID types.PartitionID `json:"targetPartitionId"` // target partition id where the fee credit is being reclaimed from TargetBillID []byte `json:"targetBillId"` // closeFC target bill id TargetBillCounter uint64 `json:"targetBillCounter"` // closeFC target bill counter LockingDisabled bool `json:"lockingDisabled,omitempty"` LockTx *types.TransactionOrder `json:"lockTx,omitempty"` LockTxProof *types.TxRecordProof `json:"lockTxProof,omitempty"` CloseFCTx *types.TransactionOrder `json:"closeFCTx,omitempty"` CloseFCProof *types.TxRecordProof `json:"closeFCProof,omitempty"` ReclaimFCTx *types.TransactionOrder `json:"reclaimFCTx,omitempty"` ReclaimFCProof *types.TxRecordProof `json:"reclaimFCProof,omitempty"` }
type ReclaimFeeTxProofs ¶
type ReclaimFeeTxProofs struct { Lock *types.TxRecordProof CloseFC *types.TxRecordProof ReclaimFC *types.TxRecordProof }
func (*ReclaimFeeTxProofs) GetFees ¶
func (p *ReclaimFeeTxProofs) GetFees() uint64
type UnlockFeeCreditCmd ¶
type UnlockFeeCreditCmd struct {
AccountIndex uint64
}