mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr: public deposit method scope
This commit is contained in:
parent
b7b553cf1e
commit
70b21893e0
3 changed files with 12 additions and 12 deletions
|
|
@ -71,28 +71,28 @@ func (d *Deposit) IsInFinalState() bool {
|
|||
return d.state == Expired || d.state == Failed
|
||||
}
|
||||
|
||||
func (d *Deposit) isExpired(currentHeight, expiry uint32) bool {
|
||||
func (d *Deposit) IsExpired(currentHeight, expiry uint32) bool {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
|
||||
return currentHeight >= uint32(d.ConfirmationHeight)+expiry
|
||||
}
|
||||
|
||||
func (d *Deposit) getState() fsm.StateType {
|
||||
func (d *Deposit) GetState() fsm.StateType {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
|
||||
return d.state
|
||||
}
|
||||
|
||||
func (d *Deposit) setState(state fsm.StateType) {
|
||||
func (d *Deposit) SetState(state fsm.StateType) {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
|
||||
d.state = state
|
||||
}
|
||||
|
||||
func (d *Deposit) isInState(state fsm.StateType) bool {
|
||||
func (d *Deposit) IsInState(state fsm.StateType) bool {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func NewFSM(ctx context.Context, deposit *Deposit, cfg *ManagerConfig,
|
|||
|
||||
if recoverStateMachine {
|
||||
depoFsm.StateMachine = fsm.NewStateMachineWithState(
|
||||
depositStates, deposit.getState(),
|
||||
depositStates, deposit.GetState(),
|
||||
DefaultObserverSize,
|
||||
)
|
||||
} else {
|
||||
|
|
@ -145,8 +145,8 @@ func (f *FSM) handleBlockNotification(ctx context.Context,
|
|||
|
||||
// If the deposit is expired but not yet sufficiently confirmed, we
|
||||
// republish the expiry sweep transaction.
|
||||
if f.deposit.isExpired(currentHeight, params.Expiry) {
|
||||
if f.deposit.isInState(WaitForExpirySweep) {
|
||||
if f.deposit.IsExpired(currentHeight, params.Expiry) {
|
||||
if f.deposit.IsInState(WaitForExpirySweep) {
|
||||
f.PublishDepositExpirySweepAction(ctx, nil)
|
||||
} else {
|
||||
go func() {
|
||||
|
|
@ -232,13 +232,13 @@ func (f *FSM) updateDeposit(ctx context.Context,
|
|||
notification.Event,
|
||||
)
|
||||
|
||||
f.deposit.setState(notification.NextState)
|
||||
f.deposit.SetState(notification.NextState)
|
||||
|
||||
// Don't update the deposit if we are in an initial state or if we
|
||||
// are transitioning from an initial state to a failed state.
|
||||
d := f.deposit
|
||||
if d.isInState(fsm.EmptyState) || d.isInState(Deposited) ||
|
||||
(notification.PreviousState == Deposited && d.isInState(
|
||||
if d.IsInState(fsm.EmptyState) || d.IsInState(Deposited) ||
|
||||
(notification.PreviousState == Deposited && d.IsInState(
|
||||
Failed,
|
||||
)) {
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func (s *SqlStore) CreateDeposit(ctx context.Context, deposit *Deposit) error {
|
|||
updateArgs := sqlc.InsertDepositUpdateParams{
|
||||
DepositID: deposit.ID[:],
|
||||
UpdateTimestamp: s.clock.Now().UTC(),
|
||||
UpdateState: string(deposit.getState()),
|
||||
UpdateState: string(deposit.GetState()),
|
||||
}
|
||||
|
||||
return s.baseDB.ExecTx(ctx, &loopdb.SqliteTxOptions{},
|
||||
|
|
@ -63,7 +63,7 @@ func (s *SqlStore) UpdateDeposit(ctx context.Context, deposit *Deposit) error {
|
|||
insertUpdateArgs := sqlc.InsertDepositUpdateParams{
|
||||
DepositID: deposit.ID[:],
|
||||
UpdateTimestamp: s.clock.Now().UTC(),
|
||||
UpdateState: string(deposit.getState()),
|
||||
UpdateState: string(deposit.GetState()),
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue