Merge pull request #1847 from halseth/kidoutput-height-hint
[utxonursery] Use kidoutput broadcast height as height hint
This commit is contained in:
6 files changed
+22
-7
No files matched your search
@@ -105,7 +105,7 @@ type ChainArbitratorConfig struct {
|
|||||||
// absolute/relative item block.
|
// absolute/relative item block.
|
||||||
IncubateOutputs func(wire.OutPoint, *lnwallet.CommitOutputResolution,
|
IncubateOutputs func(wire.OutPoint, *lnwallet.CommitOutputResolution,
|
||||||
*lnwallet.OutgoingHtlcResolution,
|
*lnwallet.OutgoingHtlcResolution,
|
||||||
*lnwallet.IncomingHtlcResolution) error
|
*lnwallet.IncomingHtlcResolution, uint32) error
|
||||||
|
|
||||||
// PreimageDB is a global store of all known pre-images. We'll use this
|
// PreimageDB is a global store of all known pre-images. We'll use this
|
||||||
// to decide if we should broadcast a commitment transaction to claim
|
// to decide if we should broadcast a commitment transaction to claim
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ func (c *ChannelArbitrator) stateStep(triggerHeight uint32,
|
|||||||
|
|
||||||
err = c.cfg.IncubateOutputs(
|
err = c.cfg.IncubateOutputs(
|
||||||
c.cfg.ChanPoint, commitRes,
|
c.cfg.ChanPoint, commitRes,
|
||||||
nil, nil,
|
nil, nil, triggerHeight,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO(roasbeef): check for AlreadyExists errors
|
// TODO(roasbeef): check for AlreadyExists errors
|
||||||
|
|||||||
@@ -152,7 +152,10 @@ func (h *htlcTimeoutResolver) Resolve() (ContractResolver, error) {
|
|||||||
log.Tracef("%T(%v): incubating htlc output", h,
|
log.Tracef("%T(%v): incubating htlc output", h,
|
||||||
h.htlcResolution.ClaimOutpoint)
|
h.htlcResolution.ClaimOutpoint)
|
||||||
|
|
||||||
err := h.IncubateOutputs(h.ChanPoint, nil, &h.htlcResolution, nil)
|
err := h.IncubateOutputs(
|
||||||
|
h.ChanPoint, nil, &h.htlcResolution, nil,
|
||||||
|
h.broadcastHeight,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -568,7 +571,10 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
|||||||
log.Infof("%T(%x): incubating incoming htlc output",
|
log.Infof("%T(%x): incubating incoming htlc output",
|
||||||
h, h.payHash[:])
|
h, h.payHash[:])
|
||||||
|
|
||||||
err := h.IncubateOutputs(h.ChanPoint, nil, nil, &h.htlcResolution)
|
err := h.IncubateOutputs(
|
||||||
|
h.ChanPoint, nil, nil, &h.htlcResolution,
|
||||||
|
h.broadcastHeight,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -628,7 +628,8 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
|
|||||||
IncubateOutputs: func(chanPoint wire.OutPoint,
|
IncubateOutputs: func(chanPoint wire.OutPoint,
|
||||||
commitRes *lnwallet.CommitOutputResolution,
|
commitRes *lnwallet.CommitOutputResolution,
|
||||||
outHtlcRes *lnwallet.OutgoingHtlcResolution,
|
outHtlcRes *lnwallet.OutgoingHtlcResolution,
|
||||||
inHtlcRes *lnwallet.IncomingHtlcResolution) error {
|
inHtlcRes *lnwallet.IncomingHtlcResolution,
|
||||||
|
broadcastHeight uint32) error {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
inRes []lnwallet.IncomingHtlcResolution
|
inRes []lnwallet.IncomingHtlcResolution
|
||||||
@@ -643,6 +644,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
|
|||||||
|
|
||||||
return s.utxoNursery.IncubateOutputs(
|
return s.utxoNursery.IncubateOutputs(
|
||||||
chanPoint, commitRes, outRes, inRes,
|
chanPoint, commitRes, outRes, inRes,
|
||||||
|
broadcastHeight,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
PreimageDB: s.witnessBeacon,
|
PreimageDB: s.witnessBeacon,
|
||||||
|
|||||||
+5
-2
@@ -343,7 +343,8 @@ func (u *utxoNursery) Stop() error {
|
|||||||
func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint,
|
func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint,
|
||||||
commitResolution *lnwallet.CommitOutputResolution,
|
commitResolution *lnwallet.CommitOutputResolution,
|
||||||
outgoingHtlcs []lnwallet.OutgoingHtlcResolution,
|
outgoingHtlcs []lnwallet.OutgoingHtlcResolution,
|
||||||
incomingHtlcs []lnwallet.IncomingHtlcResolution) error {
|
incomingHtlcs []lnwallet.IncomingHtlcResolution,
|
||||||
|
broadcastHeight uint32) error {
|
||||||
|
|
||||||
numHtlcs := len(incomingHtlcs) + len(outgoingHtlcs)
|
numHtlcs := len(incomingHtlcs) + len(outgoingHtlcs)
|
||||||
var (
|
var (
|
||||||
@@ -469,7 +470,9 @@ func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint,
|
|||||||
// kindergarten bucket.
|
// kindergarten bucket.
|
||||||
if len(kidOutputs) != 0 {
|
if len(kidOutputs) != 0 {
|
||||||
for _, kidOutput := range kidOutputs {
|
for _, kidOutput := range kidOutputs {
|
||||||
err := u.registerPreschoolConf(&kidOutput, u.bestHeight)
|
err := u.registerPreschoolConf(
|
||||||
|
&kidOutput, broadcastHeight,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,6 +336,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestKidOutputSerialization(t *testing.T) {
|
func TestKidOutputSerialization(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
for i, kid := range kidOutputs {
|
for i, kid := range kidOutputs {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
if err := kid.Encode(&b); err != nil {
|
if err := kid.Encode(&b); err != nil {
|
||||||
@@ -358,6 +360,8 @@ func TestKidOutputSerialization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBabyOutputSerialization(t *testing.T) {
|
func TestBabyOutputSerialization(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
for i, baby := range babyOutputs {
|
for i, baby := range babyOutputs {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
if err := baby.Encode(&b); err != nil {
|
if err := baby.Encode(&b); err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user