general: fix typos, rename variables, add comments
This commit is contained in:
parent
b70d1f8cfe
commit
5b9e4ae61e
@ -827,7 +827,7 @@ func (f *fundingManager) handleErrorGenericMsg(fmsg *fundingErrorMsg) {
|
|||||||
"exceeded -- unable to cancel reservation: %v",
|
"exceeded -- unable to cancel reservation: %v",
|
||||||
err)
|
err)
|
||||||
} else {
|
} else {
|
||||||
resCtx.err <- grpc.Errorf(OpenChannelFundingError,
|
resCtx.err <- grpc.Errorf(ErrorMaxPendingChannels,
|
||||||
"unable to create channel, max number of "+
|
"unable to create channel, max number of "+
|
||||||
"pending channels exceeded.")
|
"pending channels exceeded.")
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ func (h *htlcSwitch) SendHTLC(htlcPkt *htlcPacket) error {
|
|||||||
// their links. The duties of the forwarder are similar to that of a network
|
// their links. The duties of the forwarder are similar to that of a network
|
||||||
// switch, in that it facilitates multi-hop payments by acting as a central
|
// switch, in that it facilitates multi-hop payments by acting as a central
|
||||||
// messaging bus. The switch communicates will active links to create, manage,
|
// messaging bus. The switch communicates will active links to create, manage,
|
||||||
// and tearn down active onion routed payments.Each active channel is modeled
|
// and tear down active onion routed payments.Each active channel is modeled
|
||||||
// as networked device with meta-data such as the available payment bandwidth,
|
// as networked device with meta-data such as the available payment bandwidth,
|
||||||
// and total link capacity.
|
// and total link capacity.
|
||||||
func (h *htlcSwitch) htlcForwarder() {
|
func (h *htlcSwitch) htlcForwarder() {
|
||||||
@ -292,7 +292,7 @@ out:
|
|||||||
switch wireMsg := pkt.msg.(type) {
|
switch wireMsg := pkt.msg.(type) {
|
||||||
// A link has just forwarded us a new HTLC, therefore
|
// A link has just forwarded us a new HTLC, therefore
|
||||||
// we initiate the payment circuit within our internal
|
// we initiate the payment circuit within our internal
|
||||||
// staate so we can properly forward the ultimate
|
// state so we can properly forward the ultimate
|
||||||
// settle message.
|
// settle message.
|
||||||
case *lnwire.HTLCAddRequest:
|
case *lnwire.HTLCAddRequest:
|
||||||
// Create the two ends of the payment circuit
|
// Create the two ends of the payment circuit
|
||||||
@ -328,7 +328,7 @@ out:
|
|||||||
|
|
||||||
// With the circuit initiated, send the htlcPkt
|
// With the circuit initiated, send the htlcPkt
|
||||||
// to the clearing link within the circuit to
|
// to the clearing link within the circuit to
|
||||||
// continue propagating the HTLC accross the
|
// continue propagating the HTLC across the
|
||||||
// network.
|
// network.
|
||||||
circuit.clear.linkChan <- &htlcPacket{
|
circuit.clear.linkChan <- &htlcPacket{
|
||||||
msg: wireMsg,
|
msg: wireMsg,
|
||||||
|
@ -885,8 +885,8 @@ func testMaxPendingChannels(net *networkHarness, t *harnessTest) {
|
|||||||
_, err = net.OpenChannel(ctx, net.Alice, carol, amount, 1)
|
_, err = net.OpenChannel(ctx, net.Alice, carol, amount, 1)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("error wasn't received")
|
t.Fatalf("error wasn't received")
|
||||||
} else if grpc.Code(err) != OpenChannelFundingError {
|
} else if grpc.Code(err) != ErrorMaxPendingChannels {
|
||||||
t.Fatalf("not expected error was received : %v", err)
|
t.Fatalf("not expected error was received: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now our channels are in pending state, in order to not
|
// For now our channels are in pending state, in order to not
|
||||||
|
@ -1014,7 +1014,7 @@ func (lc *LightningChannel) evaluateHTLCView(view *htlcView, ourBalance,
|
|||||||
|
|
||||||
// processAddEntry evaluates the effect of an add entry within the HTLC log.
|
// processAddEntry evaluates the effect of an add entry within the HTLC log.
|
||||||
// If the HTLC hasn't yet been committed in either chain, then the height it
|
// If the HTLC hasn't yet been committed in either chain, then the height it
|
||||||
// was commited is updated. Keeping track of this inclusion height allows us to
|
// was committed is updated. Keeping track of this inclusion height allows us to
|
||||||
// later compact the log once the change is fully committed in both chains.
|
// later compact the log once the change is fully committed in both chains.
|
||||||
func processAddEntry(htlc *PaymentDescriptor, ourBalance, theirBalance *btcutil.Amount,
|
func processAddEntry(htlc *PaymentDescriptor, ourBalance, theirBalance *btcutil.Amount,
|
||||||
nextHeight uint64, remoteChain bool, isIncoming bool) {
|
nextHeight uint64, remoteChain bool, isIncoming bool) {
|
||||||
@ -1165,7 +1165,7 @@ func (lc *LightningChannel) SignNextCommitment() ([]byte, uint32, error) {
|
|||||||
// the remote party. This method will should be called in response to the
|
// the remote party. This method will should be called in response to the
|
||||||
// remote party initiating a new change, or when the remote party sends a
|
// remote party initiating a new change, or when the remote party sends a
|
||||||
// signature fully accepting a new state we've initiated. If we are able to
|
// signature fully accepting a new state we've initiated. If we are able to
|
||||||
// succesfully validate the signature, then the generated commitment is added
|
// successfully validate the signature, then the generated commitment is added
|
||||||
// to our local commitment chain. Once we send a revocation for our prior
|
// to our local commitment chain. Once we send a revocation for our prior
|
||||||
// state, then this newly added commitment becomes our current accepted channel
|
// state, then this newly added commitment becomes our current accepted channel
|
||||||
// state.
|
// state.
|
||||||
@ -1992,7 +1992,7 @@ func CreateCommitTx(fundingOutput *wire.TxIn, selfKey, theirKey *btcec.PublicKey
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Next, we create the script paying to them. This is just a regular
|
// Next, we create the script paying to them. This is just a regular
|
||||||
// P2WKH output, without any added CSV delay.
|
// P2WPKH output, without any added CSV delay.
|
||||||
theirWitnessKeyHash, err := commitScriptUnencumbered(theirKey)
|
theirWitnessKeyHash, err := commitScriptUnencumbered(theirKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -135,7 +135,7 @@ func initRevocationWindows(chanA, chanB *LightningChannel, windowSize int) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// forceStateTransition executes the neccessary interaction between the two
|
// forceStateTransition executes the necessary interaction between the two
|
||||||
// commitment state machines to transition to a new state locking in any
|
// commitment state machines to transition to a new state locking in any
|
||||||
// pending updates.
|
// pending updates.
|
||||||
func forceStateTransition(chanA, chanB *LightningChannel) error {
|
func forceStateTransition(chanA, chanB *LightningChannel) error {
|
||||||
@ -320,7 +320,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan
|
|||||||
// TestSimpleAddSettleWorkflow tests a simple channel scenario wherein the
|
// TestSimpleAddSettleWorkflow tests a simple channel scenario wherein the
|
||||||
// local node (Alice in this case) creates a new outgoing HTLC to bob, commits
|
// local node (Alice in this case) creates a new outgoing HTLC to bob, commits
|
||||||
// this change, then bob immediately commits a settlement of the HTLC after the
|
// this change, then bob immediately commits a settlement of the HTLC after the
|
||||||
// initial add is fully commited in both commit chains.
|
// initial add is fully committed in both commit chains.
|
||||||
// TODO(roasbeef): write higher level framework to exercise various states of
|
// TODO(roasbeef): write higher level framework to exercise various states of
|
||||||
// the state machine
|
// the state machine
|
||||||
// * DSL language perhaps?
|
// * DSL language perhaps?
|
||||||
@ -389,7 +389,7 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Alice then processes this revocation, sending her own recovation for
|
// Alice then processes this revocation, sending her own recovation for
|
||||||
// her prior commitment transaction. Alice shouldn't have any HTLC's to
|
// her prior commitment transaction. Alice shouldn't have any HTLC's to
|
||||||
// forward since she's sending anoutgoing HTLC.
|
// forward since she's sending an outgoing HTLC.
|
||||||
if htlcs, err := aliceChannel.ReceiveRevocation(bobRevocation); err != nil {
|
if htlcs, err := aliceChannel.ReceiveRevocation(bobRevocation); err != nil {
|
||||||
t.Fatalf("alice unable to rocess bob's revocation: %v", err)
|
t.Fatalf("alice unable to rocess bob's revocation: %v", err)
|
||||||
} else if len(htlcs) != 0 {
|
} else if len(htlcs) != 0 {
|
||||||
@ -441,7 +441,7 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Alice's revocation window should now be one beyond the size of the
|
// Alice's revocation window should now be one beyond the size of the
|
||||||
// intial window. Same goes for Bob.
|
// initial window. Same goes for Bob.
|
||||||
if aliceChannel.revocationWindowEdge != 4 {
|
if aliceChannel.revocationWindowEdge != 4 {
|
||||||
t.Fatalf("alice revocation window not incremented, is %v should be %v",
|
t.Fatalf("alice revocation window not incremented, is %v should be %v",
|
||||||
aliceChannel.revocationWindowEdge, 4)
|
aliceChannel.revocationWindowEdge, 4)
|
||||||
|
@ -340,7 +340,7 @@ func senderHtlcSpendTimeout(commitScript []byte, outputAmt btcutil.Amount,
|
|||||||
//
|
//
|
||||||
// Possible Input Scripts:
|
// Possible Input Scripts:
|
||||||
// RECVR: <sig> <preimage> 1
|
// RECVR: <sig> <preimage> 1
|
||||||
// REVOK: <sig> <preimage> 1 0
|
// REVOK: <sig> <preimage> 0 1
|
||||||
// SENDR: <sig> 0 0
|
// SENDR: <sig> 0 0
|
||||||
//
|
//
|
||||||
// OP_IF
|
// OP_IF
|
||||||
@ -358,7 +358,7 @@ func senderHtlcSpendTimeout(commitScript []byte, outputAmt btcutil.Amount,
|
|||||||
// <revoke hash> OP_EQUALVERIFY
|
// <revoke hash> OP_EQUALVERIFY
|
||||||
// OP_ELSE
|
// OP_ELSE
|
||||||
// //Refund
|
// //Refund
|
||||||
// <absolute blockehight> OP_CHECKLOCKTIMEVERIFY OP_DROP
|
// <absolute blockheight> OP_CHECKLOCKTIMEVERIFY OP_DROP
|
||||||
// OP_ENDIF
|
// OP_ENDIF
|
||||||
// <sender key> OP_CHECKSIG
|
// <sender key> OP_CHECKSIG
|
||||||
// OP_ENDIF
|
// OP_ENDIF
|
||||||
|
@ -15,6 +15,10 @@ const (
|
|||||||
// ErrorMaxPendingChannels is returned by remote peer when the number
|
// ErrorMaxPendingChannels is returned by remote peer when the number
|
||||||
// of active pending channels exceeds their maximum policy limit.
|
// of active pending channels exceeds their maximum policy limit.
|
||||||
ErrorMaxPendingChannels ErrorCode = 1
|
ErrorMaxPendingChannels ErrorCode = 1
|
||||||
|
|
||||||
|
// ErrorMaxTransactionWeight is returned by remote peer when transaction
|
||||||
|
// weight exceed maximum allowable value.
|
||||||
|
ErrorMaxTransactionWeight ErrorCode = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorGeneric represents a generic error bound to an exact channel. The
|
// ErrorGeneric represents a generic error bound to an exact channel. The
|
||||||
|
2
peer.go
2
peer.go
@ -977,7 +977,7 @@ type commitmentState struct {
|
|||||||
logCommitTimer <-chan time.Time
|
logCommitTimer <-chan time.Time
|
||||||
|
|
||||||
// switchChan is a channel used to send packets to the htlc switch for
|
// switchChan is a channel used to send packets to the htlc switch for
|
||||||
// fowarding.
|
// forwarding.
|
||||||
switchChan chan<- *htlcPacket
|
switchChan chan<- *htlcPacket
|
||||||
|
|
||||||
// sphinx is an instance of the Sphinx onion Router for this node. The
|
// sphinx is an instance of the Sphinx onion Router for this node. The
|
||||||
|
@ -29,7 +29,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
OpenChannelFundingError = 100
|
// ErrorMaxPendingChannels is an additional gRPC error, which is
|
||||||
|
// returned if max pending channel restriction was violated.
|
||||||
|
ErrorMaxPendingChannels = 100
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user