fundingmanager: commit to new states in stateStep
This commit moves the saving of the new channelOpeningState to the stateStep method.
This commit is contained in:
parent
49bbf0eb61
commit
b2a7e42f44
@ -907,8 +907,22 @@ func (f *fundingManager) stateStep(channel *channeldb.OpenChannel,
|
|||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As the fundingLocked message is now sent to the peer, the
|
||||||
|
// channel is moved to the next state of the state machine. It
|
||||||
|
// will be moved to the last state (actually deleted from the
|
||||||
|
// database) after the channel is finally announced.
|
||||||
|
err = f.saveChannelOpeningState(
|
||||||
|
&channel.FundingOutpoint, fundingLockedSent,
|
||||||
|
shortChanID,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error setting channel state to"+
|
||||||
|
" fundingLockedSent: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
fndgLog.Debugf("Channel(%v) with ShortChanID %v: successfully "+
|
fndgLog.Debugf("Channel(%v) with ShortChanID %v: successfully "+
|
||||||
"sent FundingLocked", chanID, shortChanID)
|
"sent FundingLocked", chanID, shortChanID)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
// fundingLocked was sent to peer, but the channel was not added to the
|
// fundingLocked was sent to peer, but the channel was not added to the
|
||||||
@ -920,6 +934,19 @@ func (f *fundingManager) stateStep(channel *channeldb.OpenChannel,
|
|||||||
"router graph: %v", err)
|
"router graph: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As the channel is now added to the ChannelRouter's topology,
|
||||||
|
// the channel is moved to the next state of the state machine.
|
||||||
|
// It will be moved to the last state (actually deleted from
|
||||||
|
// the database) after the channel is finally announced.
|
||||||
|
err = f.saveChannelOpeningState(
|
||||||
|
&channel.FundingOutpoint, addedToRouterGraph,
|
||||||
|
shortChanID,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error setting channel state to"+
|
||||||
|
" addedToRouterGraph: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
fndgLog.Debugf("Channel(%v) with ShortChanID %v: successfully "+
|
fndgLog.Debugf("Channel(%v) with ShortChanID %v: successfully "+
|
||||||
"added to router graph", chanID, shortChanID)
|
"added to router graph", chanID, shortChanID)
|
||||||
|
|
||||||
@ -961,8 +988,20 @@ func (f *fundingManager) stateStep(channel *channeldb.OpenChannel,
|
|||||||
"announcement: %v", err)
|
"announcement: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We delete the channel opening state from our internal
|
||||||
|
// database as the opening process has succeeded. We can do
|
||||||
|
// this because we assume the AuthenticatedGossiper queues the
|
||||||
|
// announcement messages, and persists them in case of a daemon
|
||||||
|
// shutdown.
|
||||||
|
err = f.deleteChannelOpeningState(&channel.FundingOutpoint)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error deleting channel state: %v",
|
||||||
|
err)
|
||||||
|
}
|
||||||
|
|
||||||
fndgLog.Debugf("Channel(%v) with ShortChanID %v: successfully "+
|
fndgLog.Debugf("Channel(%v) with ShortChanID %v: successfully "+
|
||||||
"announced", chanID, shortChanID)
|
"announced", chanID, shortChanID)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2068,17 +2107,6 @@ func (f *fundingManager) sendFundingLocked(peer lnpeer.Peer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// As the fundingLocked message is now sent to the peer, the channel is
|
|
||||||
// moved to the next state of the state machine. It will be moved to the
|
|
||||||
// last state (actually deleted from the database) after the channel is
|
|
||||||
// finally announced.
|
|
||||||
err = f.saveChannelOpeningState(&completeChan.FundingOutpoint,
|
|
||||||
fundingLockedSent, shortChanID)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error setting channel state to"+
|
|
||||||
" fundingLockedSent: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2157,17 +2185,6 @@ func (f *fundingManager) addToRouterGraph(completeChan *channeldb.OpenChannel,
|
|||||||
return ErrFundingManagerShuttingDown
|
return ErrFundingManagerShuttingDown
|
||||||
}
|
}
|
||||||
|
|
||||||
// As the channel is now added to the ChannelRouter's topology, the
|
|
||||||
// channel is moved to the next state of the state machine. It will be
|
|
||||||
// moved to the last state (actually deleted from the database) after
|
|
||||||
// the channel is finally announced.
|
|
||||||
err = f.saveChannelOpeningState(&completeChan.FundingOutpoint,
|
|
||||||
addedToRouterGraph, shortChanID)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error setting channel state to"+
|
|
||||||
" addedToRouterGraph: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2309,15 +2326,6 @@ func (f *fundingManager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
|
|||||||
"announced", &fundingPoint, shortChanID)
|
"announced", &fundingPoint, shortChanID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We delete the channel opening state from our internal database
|
|
||||||
// as the opening process has succeeded. We can do this because we
|
|
||||||
// assume the AuthenticatedGossiper queues the announcement messages,
|
|
||||||
// and persists them in case of a daemon shutdown.
|
|
||||||
err := f.deleteChannelOpeningState(&completeChan.FundingOutpoint)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error deleting channel state: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user