chains: use distinct StaticFeeEstimator instances for Bitcoin and Litecoin

This commit is contained in:
Olaoluwa Osuntokun 2017-09-03 16:53:04 -07:00
parent f823a860c8
commit d5cc0441f4
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -53,8 +53,8 @@ var defaultChannelConstraints = channeldb.ChannelConstraints{
MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2, MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2,
} }
// chainCode is an enum-like structure for keeping track of the chains currently // chainCode is an enum-like structure for keeping track of the chains
// supported within lnd. // currently supported within lnd.
type chainCode uint32 type chainCode uint32
const ( const (
@ -112,34 +112,37 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB) (*chainControl
ltndLog.Infof("Primary chain is set to: %v", ltndLog.Infof("Primary chain is set to: %v",
registeredChains.PrimaryChain()) registeredChains.PrimaryChain())
estimator := lnwallet.StaticFeeEstimator{FeeRate: 50} cc := &chainControl{}
walletConfig := &btcwallet.Config{
PrivatePass: []byte("hello"),
DataDir: homeChainConfig.ChainDir,
NetParams: activeNetParams.Params,
FeeEstimator: estimator,
}
cc := &chainControl{
feeEstimator: estimator,
}
switch registeredChains.PrimaryChain() { switch registeredChains.PrimaryChain() {
case bitcoinChain: case bitcoinChain:
cc.routingPolicy = defaultBitcoinForwardingPolicy cc.routingPolicy = defaultBitcoinForwardingPolicy
cc.feeEstimator = lnwallet.StaticFeeEstimator{
FeeRate: 50,
}
case litecoinChain: case litecoinChain:
cc.routingPolicy = defaultLitecoinForwardingPolicy cc.routingPolicy = defaultLitecoinForwardingPolicy
cc.feeEstimator = lnwallet.StaticFeeEstimator{
FeeRate: 100,
}
default: default:
return nil, nil, fmt.Errorf("Default routing policy for "+ return nil, nil, fmt.Errorf("Default routing policy for "+
"chain %v is unknown", registeredChains.PrimaryChain()) "chain %v is unknown", registeredChains.PrimaryChain())
} }
walletConfig := &btcwallet.Config{
PrivatePass: []byte("hello"),
DataDir: homeChainConfig.ChainDir,
NetParams: activeNetParams.Params,
FeeEstimator: cc.feeEstimator,
}
var ( var (
err error err error
cleanUp func() cleanUp func()
) )
// If spv mode is active, then we'll be using a distimnct set of // If spv mode is active, then we'll be using a distinct set of
// chainControl interfaces that interface directly with the p2p network // chainControl interfaces that interface directly with the p2p network
// of the selected chain. // of the selected chain.
if cfg.NeutrinoMode.Active { if cfg.NeutrinoMode.Active {