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) (*api.FeeCreditBill, error)
- func (w *FeeManager) LockFeeCredit(ctx context.Context, cmd LockFeeCreditCmd) (*wallet.Proof, error)
- func (w *FeeManager) ReclaimFeeCredit(ctx context.Context, cmd ReclaimFeeCmd) (*ReclaimFeeCmdResponse, error)
- func (w *FeeManager) UnlockFeeCredit(ctx context.Context, cmd UnlockFeeCreditCmd) (*wallet.Proof, error)
- type FeeManagerDB
- type GenerateFcrIDFromPublicKey
- type GetFeeCreditCmd
- type LockFeeCreditCmd
- type ReclaimFeeCmd
- type ReclaimFeeCmdResponse
- type ReclaimFeeCreditCtx
- type ReclaimFeeTxProofs
- type RpcClient
- type UnlockFeeCreditCmd
Constants ¶
const (
FeeManagerDBFileName = "feemanager.db"
)
const (
MinimumFeeAmount = 4 * txbuilder.MaxFee
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AddFeeCmdResponse ¶
type AddFeeCmdResponse struct {
Proofs []*AddFeeTxProofs
}
type AddFeeCreditCtx ¶
type AddFeeCreditCtx struct { TargetPartitionID types.SystemID `json:"targetPartitionId"` // target partition id where the fee is being added to TargetBillID []byte `json:"targetBillId"` // transferFC target bill id TargetBillBacklink []byte `json:"targetBillBacklink"` // transferFC target bill backlink TargetAmount uint64 `json:"targetAmount"` // the amount to add to the fee credit bill LockingDisabled bool `json:"lockingDisabled,omitempty"` // user defined flag if we should lock fee credit record when adding fees LockFCTx *types.TransactionOrder `json:"lockFCTx,omitempty"` LockFCProof *wallet.Proof `json:"lockFCProof,omitempty"` TransferFCTx *types.TransactionOrder `json:"transferFCTx,omitempty"` TransferFCProof *wallet.Proof `json:"transferFCProof,omitempty"` AddFCTx *types.TransactionOrder `json:"addFCTx,omitempty"` AddFCProof *wallet.Proof `json:"addFCProof,omitempty"` }
type AddFeeTxProofs ¶
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( am account.Manager, db FeeManagerDB, moneySystemID types.SystemID, moneyClient RpcClient, moneyPartitionFcrIDFn GenerateFcrIDFromPublicKey, targetPartitionSystemID types.SystemID, targetPartitionClient RpcClient, fcrIDFn GenerateFcrIDFromPublicKey, log *slog.Logger, ) *FeeManager
NewFeeManager creates new fee credit manager. Parameters: - account manager - fee manager db
- money partition:
- systemID
- rpc node client
- fee credit record id generation function
- target partition:
- systemID
- rpc node client
- fee credit record id generation function
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) (*api.FeeCreditBill, error)
GetFeeCredit returns fee credit bill for given account, returns nil if fee credit bill has not been created yet.
func (*FeeManager) LockFeeCredit ¶
func (w *FeeManager) LockFeeCredit(ctx context.Context, cmd LockFeeCreditCmd) (*wallet.Proof, error)
LockFeeCredit locks fee credit bill for given account, returns error if fee credit bill has not been created yet or is already locked.
func (*FeeManager) ReclaimFeeCredit ¶
func (w *FeeManager) ReclaimFeeCredit(ctx context.Context, cmd ReclaimFeeCmd) (*ReclaimFeeCmdResponse, error)
ReclaimFeeCredit reclaims fee credit i.e. reclaims entire fee credit bill 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) (*wallet.Proof, error)
UnlockFeeCredit unlocks fee credit bill for given account, returns error if fee credit bill 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 GenerateFcrIDFromPublicKey ¶
GenerateFcrIDFromPublicKey function to generate fee credit UnitID from shard number nad public key
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.SystemID `json:"targetPartitionId"` // target partition id where the fee credit is being reclaimed from TargetBillID []byte `json:"targetBillId"` // closeFC target bill id TargetBillBacklink []byte `json:"targetBillBacklink"` // closeFC target bill backlink LockingDisabled bool `json:"lockingDisabled,omitempty"` LockTx *types.TransactionOrder `json:"lockTx,omitempty"` LockTxProof *wallet.Proof `json:"lockTxProof,omitempty"` CloseFCTx *types.TransactionOrder `json:"closeFCTx,omitempty"` CloseFCProof *wallet.Proof `json:"closeFCProof,omitempty"` ReclaimFCTx *types.TransactionOrder `json:"reclaimFCTx,omitempty"` ReclaimFCProof *wallet.Proof `json:"reclaimFCProof,omitempty"` }
type ReclaimFeeTxProofs ¶
func (*ReclaimFeeTxProofs) GetFees ¶
func (p *ReclaimFeeTxProofs) GetFees() uint64
type RpcClient ¶ added in v0.4.0
type RpcClient interface { GetRoundNumber(ctx context.Context) (uint64, error) GetBill(ctx context.Context, unitID types.UnitID, includeStateProof bool) (*api.Bill, error) GetFeeCreditRecord(ctx context.Context, unitID types.UnitID, includeStateProof bool) (*api.FeeCreditBill, error) GetUnitsByOwnerID(ctx context.Context, ownerID types.Bytes) ([]types.UnitID, error) SendTransaction(ctx context.Context, tx *types.TransactionOrder) ([]byte, error) GetTransactionProof(ctx context.Context, txHash types.Bytes) (*types.TransactionRecord, *types.TxProof, error) }
type UnlockFeeCreditCmd ¶
type UnlockFeeCreditCmd struct {
AccountIndex uint64
}