lnwallet: add a PreimageCache instead of a FeeEstimator as LightningChannel dep

This commit is contained in:
Olaoluwa Osuntokun 2018-01-16 18:08:20 -08:00
parent b1503adfad
commit 75d2f09d4c
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
1 changed files with 8 additions and 5 deletions

View File

@ -1120,9 +1120,12 @@ type LightningChannel struct {
// signatures, of which there may be hundreds.
sigPool *sigPool
// feeEstimator is used to calculate the fee rate for the channel's
// commitment and cooperative close transactions.
feeEstimator FeeEstimator
// pCache is the global preimage cache shared across all other
// LightningChannel instance. We'll use this cache either when we force
// close, or we detect that the remote party has force closed. If the
// preimage for an incoming HTLC is found in the cache, then we'll try
// to claim it on chain.
pCache PreimageCache
// Capacity is the total capacity of this channel.
Capacity btcutil.Amount
@ -1224,7 +1227,7 @@ type LightningChannel struct {
// automatically persist pertinent state to the database in an efficient
// manner.
func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier,
fe FeeEstimator, state *channeldb.OpenChannel) (*LightningChannel, error) {
pCache PreimageCache, state *channeldb.OpenChannel) (*LightningChannel, error) {
localKey := state.LocalChanCfg.MultiSigKey.SerializeCompressed()
remoteKey := state.RemoteChanCfg.MultiSigKey.SerializeCompressed()
@ -1263,7 +1266,7 @@ func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier,
sigPool: newSigPool(runtime.NumCPU(), signer),
signer: signer,
channelEvents: events,
feeEstimator: fe,
pCache: pCache,
stateHintObfuscator: stateHint,
currentHeight: localCommit.CommitHeight,
remoteCommitChain: newCommitmentChain(remoteCommit.CommitHeight),