general: fix typos, rename variables, add comments

This commit is contained in:
Andrey Samokhvalov 2016-10-26 15:25:42 +03:00 committed by Olaoluwa Osuntokun
parent b70d1f8cfe
commit 5b9e4ae61e
9 changed files with 23 additions and 17 deletions

@ -827,7 +827,7 @@ func (f *fundingManager) handleErrorGenericMsg(fmsg *fundingErrorMsg) {
"exceeded -- unable to cancel reservation: %v",
err)
} else {
resCtx.err <- grpc.Errorf(OpenChannelFundingError,
resCtx.err <- grpc.Errorf(ErrorMaxPendingChannels,
"unable to create channel, max number of "+
"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
// switch, in that it facilitates multi-hop payments by acting as a central
// 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,
// and total link capacity.
func (h *htlcSwitch) htlcForwarder() {
@ -292,7 +292,7 @@ out:
switch wireMsg := pkt.msg.(type) {
// A link has just forwarded us a new HTLC, therefore
// 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.
case *lnwire.HTLCAddRequest:
// Create the two ends of the payment circuit
@ -328,7 +328,7 @@ out:
// With the circuit initiated, send the htlcPkt
// to the clearing link within the circuit to
// continue propagating the HTLC accross the
// continue propagating the HTLC across the
// network.
circuit.clear.linkChan <- &htlcPacket{
msg: wireMsg,

@ -885,8 +885,8 @@ func testMaxPendingChannels(net *networkHarness, t *harnessTest) {
_, err = net.OpenChannel(ctx, net.Alice, carol, amount, 1)
if err == nil {
t.Fatalf("error wasn't received")
} else if grpc.Code(err) != OpenChannelFundingError {
t.Fatalf("not expected error was received : %v", err)
} else if grpc.Code(err) != ErrorMaxPendingChannels {
t.Fatalf("not expected error was received: %v", err)
}
// 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.
// 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.
func processAddEntry(htlc *PaymentDescriptor, ourBalance, theirBalance *btcutil.Amount,
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
// 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
// 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
// state, then this newly added commitment becomes our current accepted channel
// 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
// P2WKH output, without any added CSV delay.
// P2WPKH output, without any added CSV delay.
theirWitnessKeyHash, err := commitScriptUnencumbered(theirKey)
if err != nil {
return nil, err

@ -135,7 +135,7 @@ func initRevocationWindows(chanA, chanB *LightningChannel, windowSize int) error
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
// pending updates.
func forceStateTransition(chanA, chanB *LightningChannel) error {
@ -320,7 +320,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan
// TestSimpleAddSettleWorkflow tests a simple channel scenario wherein the
// 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
// 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
// the state machine
// * DSL language perhaps?
@ -389,7 +389,7 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
}
// Alice then processes this revocation, sending her own recovation for
// 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 {
t.Fatalf("alice unable to rocess bob's revocation: %v", err)
} 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
// intial window. Same goes for Bob.
// initial window. Same goes for Bob.
if aliceChannel.revocationWindowEdge != 4 {
t.Fatalf("alice revocation window not incremented, is %v should be %v",
aliceChannel.revocationWindowEdge, 4)

@ -340,7 +340,7 @@ func senderHtlcSpendTimeout(commitScript []byte, outputAmt btcutil.Amount,
//
// Possible Input Scripts:
// RECVR: <sig> <preimage> 1
// REVOK: <sig> <preimage> 1 0
// REVOK: <sig> <preimage> 0 1
// SENDR: <sig> 0 0
//
// OP_IF
@ -358,7 +358,7 @@ func senderHtlcSpendTimeout(commitScript []byte, outputAmt btcutil.Amount,
// <revoke hash> OP_EQUALVERIFY
// OP_ELSE
// //Refund
// <absolute blockehight> OP_CHECKLOCKTIMEVERIFY OP_DROP
// <absolute blockheight> OP_CHECKLOCKTIMEVERIFY OP_DROP
// OP_ENDIF
// <sender key> OP_CHECKSIG
// OP_ENDIF

@ -15,6 +15,10 @@ const (
// ErrorMaxPendingChannels is returned by remote peer when the number
// of active pending channels exceeds their maximum policy limit.
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

@ -977,7 +977,7 @@ type commitmentState struct {
logCommitTimer <-chan time.Time
// switchChan is a channel used to send packets to the htlc switch for
// fowarding.
// forwarding.
switchChan chan<- *htlcPacket
// sphinx is an instance of the Sphinx onion Router for this node. The

@ -29,7 +29,9 @@ import (
)
const (
OpenChannelFundingError = 100
// ErrorMaxPendingChannels is an additional gRPC error, which is
// returned if max pending channel restriction was violated.
ErrorMaxPendingChannels = 100
)
var (