mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-15 20:30:17 +01:00
Add little endian functionality to Network Element and Factory (#931)
This commit is contained in:
parent
971de61004
commit
69077f8d08
2 changed files with 12 additions and 0 deletions
|
@ -16,8 +16,14 @@ trait NetworkElement extends Any {
|
|||
/** The hexadecimal representation of the NetworkElement */
|
||||
def hex: String = bytes.toHex
|
||||
|
||||
/** The hexadecimal representation of the NetworkElement in little endian */
|
||||
def hexLE: String = bytesLE.toHex
|
||||
|
||||
/** The byte representation of the NetworkElement */
|
||||
def bytes: ByteVector
|
||||
|
||||
/** The byte representation of the NetworkElement in little endian */
|
||||
def bytesLE: ByteVector = bytes.reverse
|
||||
|
||||
def logger = BitcoinSLogger.logger
|
||||
}
|
||||
|
|
|
@ -12,9 +12,15 @@ abstract class Factory[+T] {
|
|||
/** Creates a T out of a hex string. */
|
||||
def fromHex(hex: String): T = fromBytes(BitcoinSUtil.decodeHex(hex))
|
||||
|
||||
/** Creates a T out of a hex string in little endian. */
|
||||
def fromHexLE(hex: String): T = fromBytesLE(BitcoinSUtil.decodeHex(hex))
|
||||
|
||||
/** Creates a T out of a sequence of bytes. */
|
||||
def fromBytes(bytes: ByteVector): T
|
||||
|
||||
/** Creates a T out of a sequence of bytes in little endian. */
|
||||
def fromBytesLE(bytes: ByteVector): T = fromBytes(bytes.reverse)
|
||||
|
||||
/** Creates a T out of a sequence of bytes. */
|
||||
def apply(bytes: ByteVector): T = fromBytes(bytes)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue