Skip to content

Commit

Permalink
Cosmetic: normalize 'self.' and 'x.' to 'this.' or '__.' for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
knocte committed Jun 22, 2021
1 parent 5ab1a1d commit c4d0ebc
Show file tree
Hide file tree
Showing 10 changed files with 344 additions and 326 deletions.
542 changes: 280 additions & 262 deletions src/DotNetLightning.Core/Channel/Channel.fs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/DotNetLightning.Core/Channel/ChannelTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ module Data =
LocalClosingFeesProposed = List.empty
RemoteClosingFeeProposed = None
}
member self.HasEnteredShutdown(): bool =
self.LocalRequestedShutdown.IsSome && self.RemoteRequestedShutdown.IsSome
member this.HasEnteredShutdown(): bool =
this.LocalRequestedShutdown.IsSome && this.RemoteRequestedShutdown.IsSome

type ClosingSignedResponse =
| NewClosingSigned of ClosingSignedMsg
Expand Down
18 changes: 9 additions & 9 deletions src/DotNetLightning.Core/Channel/CommitmentToLocalExtension.fs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ type CommitmentToLocalParameters = {

type internal CommitmentToLocalExtension() =
inherit BuilderExtension()
override self.CanGenerateScriptSig (scriptPubKey: Script): bool =
override __.CanGenerateScriptSig (scriptPubKey: Script): bool =
(CommitmentToLocalParameters.TryExtractParameters scriptPubKey).IsSome

override self.GenerateScriptSig(scriptPubKey: Script, keyRepo: IKeyRepository, signer: ISigner): Script =
override __.GenerateScriptSig(scriptPubKey: Script, keyRepo: IKeyRepository, signer: ISigner): Script =
let parameters =
match (CommitmentToLocalParameters.TryExtractParameters scriptPubKey) with
| Some parameters -> parameters
Expand Down Expand Up @@ -112,25 +112,25 @@ type internal CommitmentToLocalExtension() =
]
| _ -> null

override self.CanDeduceScriptPubKey(_scriptSig: Script): bool =
override __.CanDeduceScriptPubKey(_scriptSig: Script): bool =
false

override self.DeduceScriptPubKey(_scriptSig: Script): Script =
override __.DeduceScriptPubKey(_scriptSig: Script): Script =
raise <| NotSupportedException()

override self.CanEstimateScriptSigSize(_scriptPubKey: Script): bool =
override __.CanEstimateScriptSigSize(_scriptPubKey: Script): bool =
false

override self.EstimateScriptSigSize(_scriptPubKey: Script): int =
override __.EstimateScriptSigSize(_scriptPubKey: Script): int =
raise <| NotSupportedException()

override self.CanCombineScriptSig(_scriptPubKey: Script, _a: Script, _b: Script): bool =
override __.CanCombineScriptSig(_scriptPubKey: Script, _a: Script, _b: Script): bool =
false

override self.CombineScriptSig(_scriptPubKey: Script, _a: Script, _b: Script): Script =
override __.CombineScriptSig(_scriptPubKey: Script, _a: Script, _b: Script): Script =
raise <| NotSupportedException()

override self.IsCompatibleKey(pubKey: PubKey, scriptPubKey: Script): bool =
override __.IsCompatibleKey(pubKey: PubKey, scriptPubKey: Script): bool =
match CommitmentToLocalParameters.TryExtractParameters scriptPubKey with
| None -> false
| Some parameters ->
Expand Down
4 changes: 2 additions & 2 deletions src/DotNetLightning.Core/Channel/Commitments.fs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ type RemoteNextCommitInfo =
| Waiting _ -> remoteNextCommitInfo
| Revoked _ -> Revoked commitmentPubKey)

member self.PerCommitmentPoint(): PerCommitmentPoint =
match self with
member this.PerCommitmentPoint(): PerCommitmentPoint =
match this with
| Waiting remoteCommit -> remoteCommit.RemotePerCommitmentPoint
| Revoked perCommitmentPoint -> perCommitmentPoint

Expand Down
10 changes: 5 additions & 5 deletions src/DotNetLightning.Core/Routing/Graph.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ module Graph =
num
interface IEquatable<WeightedNode> with
member this.Equals o = this.Equals o
member x.CompareTo(y: WeightedNode) =
let weightCmp = x.Weight.CompareTo(y.Weight)
member this.CompareTo(other: WeightedNode) =
let weightCmp = this.Weight.CompareTo other.Weight
if (weightCmp <> 0) then weightCmp else
x.Id.Value.ToHex().CompareTo(y.Id.Value.ToHex())
this.Id.Value.ToHex().CompareTo(other.Id.Value.ToHex())
interface IComparable with
member this.CompareTo(o: obj) =
match o with
Expand Down Expand Up @@ -140,8 +140,8 @@ module Graph =

interface IEquatable<WeightedPath> with
member this.Equals o = this.Equals o
member x.CompareTo(y: WeightedPath)=
x.Weight.CompareTo(y.Weight)
member this.CompareTo(other: WeightedPath)=
this.Weight.CompareTo other.Weight

interface IComparable with
member this.CompareTo o =
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetLightning.Core/Utils/ChannelId.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace DotNetLightning.Utils
open NBitcoin

type ChannelId = | ChannelId of uint256 with
member x.Value = let (ChannelId v) = x in v
member this.Value = let (ChannelId v) = this in v

static member Zero = uint256.Zero |> ChannelId

38 changes: 19 additions & 19 deletions src/DotNetLightning.Core/Utils/Extensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,34 @@ type System.UInt64 with
bytes8
BitConverter.ToUInt64(bytes, 0)

member x.ToVarInt() =
if x < 0xfdUL then
[|uint8 x|]
else if x < 0x10000UL then
member this.ToVarInt() =
if this < 0xfdUL then
[|uint8 this|]
elif this < 0x10000UL then
let buf = Array.zeroCreate(3)
buf.[0] <- (0xfduy)
buf.[1] <- (byte (x >>> 8))
buf.[2] <- byte x
buf.[1] <- (byte (this >>> 8))
buf.[2] <- byte this
buf
else if x < 0x100000000UL then
elif this < 0x100000000UL then
let buf = Array.zeroCreate(5)
buf.[0] <- (0xfeuy)
buf.[1] <- (byte (x >>> 24))
buf.[2] <- (byte (x >>> 16))
buf.[3] <- (byte (x >>> 8))
buf.[4] <- (byte x)
buf.[1] <- (byte (this >>> 24))
buf.[2] <- (byte (this >>> 16))
buf.[3] <- (byte (this >>> 8))
buf.[4] <- (byte this)
buf
else
let buf = Array.zeroCreate(9)
buf.[0] <- (0xffuy)
buf.[1] <- (byte (x >>> 56))
buf.[2] <- (byte (x >>> 48))
buf.[3] <- (byte (x >>> 40))
buf.[4] <- (byte (x >>> 32))
buf.[5] <- (byte (x >>> 24))
buf.[6] <- (byte (x >>> 16))
buf.[7] <- (byte (x >>> 8))
buf.[8] <- (byte x)
buf.[1] <- (byte (this >>> 56))
buf.[2] <- (byte (this >>> 48))
buf.[3] <- (byte (this >>> 40))
buf.[4] <- (byte (this >>> 32))
buf.[5] <- (byte (this >>> 24))
buf.[6] <- (byte (this >>> 16))
buf.[7] <- (byte (this >>> 8))
buf.[8] <- (byte this)
buf

type System.UInt32 with
Expand Down
46 changes: 23 additions & 23 deletions src/DotNetLightning.Core/Utils/Primitives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ module Primitives =
type BlockHeight = | BlockHeight of uint32 with
static member Zero = 0u |> BlockHeight
static member One = 1u |> BlockHeight
member x.Value = let (BlockHeight v) = x in v
member x.AsOffset() =
x.Value |> Checked.uint16 |> BlockHeightOffset16
member this.Value = let (BlockHeight v) = this in v
member this.AsOffset() =
this.Value |> Checked.uint16 |> BlockHeightOffset16

static member (+) (a: BlockHeight, b: BlockHeightOffset16) =
a.Value + (uint32 b.Value ) |> BlockHeight
Expand All @@ -67,7 +67,7 @@ module Primitives =
[<Struct>]
#endif
BlockHeightOffset16 = | BlockHeightOffset16 of uint16 with
member x.Value = let (BlockHeightOffset16 v) = x in v
member this.Value = let (BlockHeightOffset16 v) = this in v

static member ofBlockHeightOffset32(bho32: BlockHeightOffset32) =
BlockHeightOffset16 (uint16 bho32.Value)
Expand All @@ -90,7 +90,7 @@ module Primitives =
[<Struct>]
#endif
BlockHeightOffset32 = | BlockHeightOffset32 of uint32 with
member x.Value = let (BlockHeightOffset32 v) = x in v
member this.Value = let (BlockHeightOffset32 v) = this in v

static member ofBlockHeightOffset16(bho16: BlockHeightOffset16) =
BlockHeightOffset32 (uint32 bho16.Value)
Expand All @@ -110,7 +110,7 @@ module Primitives =
/// 3. Custom `ToString`
[<CustomEquality;CustomComparison;StructuredFormatDisplay("{AsString}")>]
type LNECDSASignature = LNECDSASignature of ECDSASignature | Empty with
member x.Value = match x with LNECDSASignature s -> s | Empty -> failwith "Unreachable!"
member this.Value = match this with LNECDSASignature s -> s | Empty -> failwith "Unreachable!"
override this.GetHashCode() = hash this.Value
override this.Equals(obj: obj) =
match obj with
Expand Down Expand Up @@ -172,10 +172,10 @@ module Primitives =
ec |> LNECDSASignature

type PaymentHash = | PaymentHash of uint256 with
member x.Value = let (PaymentHash v) = x in v
member x.ToBytes(?lEndian) =
member this.Value = let (PaymentHash v) = this in v
member this.ToBytes(?lEndian) =
let e = defaultArg lEndian false
x.Value.ToBytes(e)
this.Value.ToBytes e

member x.GetRIPEMD160() =
let b = x.Value.ToBytes() |> Array.rev
Expand Down Expand Up @@ -245,7 +245,7 @@ module Primitives =

[<CustomEquality;CustomComparison>]
type ComparablePubKey = ComparablePubKey of PubKey with
member x.Value = let (ComparablePubKey v) = x in v
member this.Value = let (ComparablePubKey v) = this in v
interface IComparable with
override this.CompareTo(other) =
match other with
Expand All @@ -261,7 +261,7 @@ module Primitives =

[<CustomEquality;CustomComparison>]
type NodeId = | NodeId of PubKey with
member x.Value = let (NodeId v) = x in v
member this.Value = let (NodeId v) = this in v
interface IComparable with
override this.CompareTo(other) =
match other with
Expand All @@ -278,7 +278,7 @@ module Primitives =
/// So that it supports comparison and equality constraints
[<CustomComparison;CustomEquality>]
type LNOutPoint = LNOutPoint of OutPoint with
member x.Value = let (LNOutPoint v) = x in v
member this.Value = let (LNOutPoint v) = this in v

member this.CompareTo(other: LNOutPoint) =
if this.Value.Hash > other.Value.Hash then
Expand Down Expand Up @@ -315,7 +315,7 @@ module Primitives =

/// feerate per kilo weight
type FeeRatePerKw = | FeeRatePerKw of uint32 with
member x.Value = let (FeeRatePerKw v) = x in v
member this.Value = let (FeeRatePerKw v) = this in v
static member FromFee(fee: Money, weight: uint64) =
(((uint64 fee.Satoshi) * 1000UL) / weight)
|> uint32
Expand Down Expand Up @@ -363,28 +363,28 @@ module Primitives =

/// Block Hash
type BlockId = | BlockId of uint256 with
member x.Value = let (BlockId v) = x in v
member this.Value = let (BlockId v) = this in v

#if !NoDUsAsStructs
[<Struct>]
#endif
type HTLCId = | HTLCId of uint64 with
static member Zero = HTLCId(0UL)
member x.Value = let (HTLCId v) = x in v
member this.Value = let (HTLCId v) = this in v

static member (+) (a: HTLCId, b: uint64) = (a.Value + b) |> HTLCId

#if !NoDUsAsStructs
[<Struct>]
#endif
type TxOutIndex = | TxOutIndex of uint16 with
member x.Value = let (TxOutIndex v) = x in v
member this.Value = let (TxOutIndex v) = this in v

#if !NoDUsAsStructs
[<Struct>]
#endif
type TxIndexInBlock = | TxIndexInBlock of uint32 with
member x.Value = let (TxIndexInBlock v) = x in v
member this.Value = let (TxIndexInBlock v) = this in v

#if !NoDUsAsStructs
[<Struct;StructuredFormatDisplay("{AsString}")>]
Expand Down Expand Up @@ -484,11 +484,11 @@ module Primitives =
sprintf "Invalid final script pubkey(%A). it must be one of p2pkh, p2sh, p2wpkh, p2wsh" scriptPubKey
|> Error

member self.ScriptPubKey(): Script =
self.ShutdownScript
member this.ScriptPubKey(): Script =
this.ShutdownScript

member self.ToBytes(): array<byte> =
self.ShutdownScript.ToBytes()
member this.ToBytes(): array<byte> =
this.ShutdownScript.ToBytes()

type ChannelFlags = {
// Set to announce the channel publicly and notify all nodes that they
Expand All @@ -505,8 +505,8 @@ module Primitives =
AnnounceChannel = (flags &&& ChannelFlags.AnnounceChannelMask) = ChannelFlags.AnnounceChannelMask
}

member self.IntoUInt8(): uint8 =
if self.AnnounceChannel then
member this.IntoUInt8(): uint8 =
if this.AnnounceChannel then
ChannelFlags.AnnounceChannelMask
else
0uy
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetLightning.Core/Utils/TxId.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ open NBitcoin

[<StructuralComparison;StructuralEquality>]
type TxId = | TxId of uint256 with
member x.Value = let (TxId v) = x in v
member this.Value = let (TxId v) = this in v
static member Zero = uint256.Zero |> TxId

4 changes: 2 additions & 2 deletions src/DotNetLightning.Core/Utils/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ module Async =

/// extend default async builder to enable awaiting task without Async.AwaitTask
type AsyncBuilder with
member x.Bind(t: Task<'T>, f: 'T -> Async<'R>): Async<'R> =
member __.Bind(t: Task<'T>, f: 'T -> Async<'R>): Async<'R> =
async.Bind(Async.AwaitTask t, f)

member x.Bind(t: Task, f: unit -> Async<'R>): Async<'R> =
member __.Bind(t: Task, f: unit -> Async<'R>): Async<'R> =
async.Bind(Async.AwaitTask t, f)
module Set =
let first (predicate: 'a -> bool) (items: Set<'a>) =
Expand Down

0 comments on commit c4d0ebc

Please sign in to comment.