Skip to content

Commit 00f3dc2

Browse files
committed
feat(protocol): Added ensure function and modified comments
Signed-off-by: Akhil Repala <[email protected]>
1 parent 40340b1 commit 00f3dc2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

internal/handshake/protocol/network.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,16 @@ func Get(t NetworkType) *Network {
508508
return SelectNetwork(t)
509509
}
510510

511-
// Ensure returns t if known, else returns Primary()
512-
func Ensure(t *Network) *Network {
513-
if t != nil {
514-
return t
511+
// Ensure returns n if known, else returns Primary()
512+
func Ensure(n *Network) *Network {
513+
if n != nil {
514+
return n
515515
}
516516
return Primary()
517517
}
518518

519+
// Lookups helper functions
520+
519521
// FromMagic finds a network by magic number.
520522
func FromMagic(magic uint32, prefer ...NetworkType) *Network {
521523
if len(prefer) > 0 {
@@ -638,3 +640,8 @@ func FromAddress(hrp string, prefer ...NetworkType) *Network {
638640
func (n *Network) String() string {
639641
return n.Type
640642
}
643+
644+
// Types lists all supported network type constants.
645+
func Types() []NetworkType {
646+
return []NetworkType{Mainnet, Testnet, Regtest, Simnet}
647+
}

0 commit comments

Comments
 (0)