channeldb: remove RevocationDelay field from the HTLC struct

This commit removes the RevocationDelay field from the HTLC struct as
with the latest commitment transaction scheme, it is no longer needed.
This is due to the fact the the delay is now observed when an on-chain
HTLC claim is attempted, rather than from Shane the HTLC itself has
been broadcast.
This commit is contained in:
Olaoluwa Osuntokun 2017-07-29 17:40:14 -07:00
parent e87cc29b36
commit 88c15abeef
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 17 additions and 31 deletions

View File

@ -530,13 +530,6 @@ type HTLC struct {
// must wait before reclaiming the funds in limbo.
RefundTimeout uint32
// RevocationDelay is the relative timeout the party who broadcasts the
// commitment transaction must wait before being able to fully sweep
// the funds on-chain in the case of a unilateral channel closure.
//
// TODO(roasbeef): no longer needed?
RevocationDelay uint32
// OutputIndex is the output index for this particular HTLC output
// within the commitment transaction.
OutputIndex int32
@ -549,11 +542,10 @@ type HTLC struct {
// Copy returns a full copy of the target HTLC.
func (h *HTLC) Copy() HTLC {
clone := HTLC{
Incoming: h.Incoming,
Amt: h.Amt,
RefundTimeout: h.RefundTimeout,
RevocationDelay: h.RevocationDelay,
OutputIndex: h.OutputIndex,
Incoming: h.Incoming,
Amt: h.Amt,
RefundTimeout: h.RefundTimeout,
OutputIndex: h.OutputIndex,
}
copy(clone.Signature[:], h.Signature)
copy(clone.RHash[:], h.RHash[:])
@ -2045,9 +2037,6 @@ func serializeHTLC(w io.Writer, h *HTLC) error {
if err := binary.Write(w, byteOrder, h.RefundTimeout); err != nil {
return err
}
if err := binary.Write(w, byteOrder, h.RevocationDelay); err != nil {
return err
}
if err := binary.Write(w, byteOrder, h.OutputIndex); err != nil {
return err
}
@ -2085,9 +2074,6 @@ func deserializeHTLC(r io.Reader) (*HTLC, error) {
if err := binary.Read(r, byteOrder, &h.RefundTimeout); err != nil {
return nil, err
}
if err := binary.Read(r, byteOrder, &h.RevocationDelay); err != nil {
return nil, err
}
if err := binary.Read(r, byteOrder, &h.OutputIndex); err != nil {
return nil, err
}

View File

@ -205,12 +205,11 @@ func TestOpenChannelPutGetDelete(t *testing.T) {
}
state.Htlcs = []*HTLC{
{
Signature: testSig.Serialize(),
Incoming: true,
Amt: 10,
RHash: key,
RefundTimeout: 1,
RevocationDelay: 2,
Signature: testSig.Serialize(),
Incoming: true,
Amt: 10,
RHash: key,
RefundTimeout: 1,
},
}
if err := state.FullSync(); err != nil {
@ -348,18 +347,19 @@ func TestChannelStateTransition(t *testing.T) {
incoming = true
}
htlc := &HTLC{
Signature: testSig.Serialize(),
Incoming: incoming,
Amt: 10,
RHash: key,
RefundTimeout: i,
RevocationDelay: i + 2,
OutputIndex: int32(i * 3),
Signature: testSig.Serialize(),
Incoming: incoming,
Amt: 10,
RHash: key,
RefundTimeout: i,
OutputIndex: int32(i * 3),
}
htlcs = append(htlcs, htlc)
htlcAmt += htlc.Amt
}
// TODO(roasbeef): ensure that expiry matches
// Create a new channel delta which includes the above HTLCs, some
// balance updates, and an increment of the current commitment height.
// Additionally, modify the signature and commitment transaction.