Package-level declarations

Types

Link copied to clipboard

An abstraction of a byte array, with offset and size that does no copying of bytes unless asked to.

Link copied to clipboard
open class Id<out VALUE : Any>(val value: VALUE, val entityType: String?, val timestamp: Instant)

Represents a unique, timestamped id.

Link copied to clipboard
data class NetworkHostAndPort(val host: String, val port: Int)

Tuple of host and port. Use NetworkHostAndPort.parse on untrusted data.

Link copied to clipboard
class NonEmptySet<T> : Set<T>

An immutable ordered non-empty set.

Link copied to clipboard
open class OpaqueBytes(bytes: ByteArray) : ByteSequence

A simple class that wraps a byte array and makes the equals/hashCode/toString methods work as you actually expect. In an ideal JVM this would be a value type and be completely overhead free. Project Valhalla is adding such functionality to Java, but it won't arrive for a few years yet!

Link copied to clipboard
class OpaqueBytesSubSequence(val bytes: ByteArray, val offset: Int, val size: Int) : ByteSequence

Class is public for serialization purposes.

Link copied to clipboard

A progress tracker helps surface information about the progress of an operation to a user interface or API of some kind. It lets you define a set of steps that represent an operation. A step is represented by an object (typically a singleton).

Link copied to clipboard
interface PropertyDelegate<out T>

Simple interface encapsulating the implicit Kotlin contract for immutable property delegates.

Link copied to clipboard
sealed class Try<out A>

Representation of an operation that has either succeeded with a result (represented by Success) or failed with an exception (represented by Failure).

Link copied to clipboard
class UntrustworthyData<out T>(fromUntrustedWorld: T)

A small utility to approximate taint tracking: if a method gives you back one of these, it means the data came from a remote source that may be incentivised to pass us junk that violates basic assumptions and thus must be checked first. The wrapper helps you to avoid forgetting this vital step. Things you might want to check are:

Link copied to clipboard
Link copied to clipboard

Simple interface encapsulating the implicit Kotlin contract for mutable property delegates.

Properties

Link copied to clipboard

Extension method for easier construction of Durations in terms of integer days: val twoDays = 2.days.

Link copied to clipboard

Extension method for easier construction of Durations in terms of integer hours: val twoHours = 2.hours.

Link copied to clipboard
const val MAX_HASH_HEX_SIZE: Int = 130

The maximum supported field-size for hash HEX-encoded outputs (e.g. database fields). This value is enough to support hash functions with outputs up to 512 bits (e.g. SHA3-512), in which case 128 HEX characters are required. 130 was selected instead of 128, to allow for 2 extra characters that will be used as hash-scheme identifiers.

Link copied to clipboard

Extension method for easier construction of Durations in terms of integer milliseconds: val twoMillis = 2.millis.

Link copied to clipboard

Extension method for easier construction of Durations in terms of integer minutes: val twoMinutes = 2.minutes.

Link copied to clipboard

Extension method for easier construction of Durations in terms of integer seconds: val twoSeconds = 2.seconds.

Functions

Link copied to clipboard
fun ThreadInfo.asString(maxFrames: Int = 256): String

Inspired by ThreadInfo.toString

Link copied to clipboard

Encoding changer. Base58-String to Base64-String, i.e. "SGVsbG8gV29ybGQ=" -> JxF12TrwUP45BMd"

Link copied to clipboard
Link copied to clipboard

Encoding changer. Base58-String to Hex-String, i.e. "SGVsbG8gV29ybGQ=" -> "48656C6C6F20576F726C64"

Link copied to clipboard

Base58-String to the actual real String, i.e. "JxF12TrwUP45BMd" -> "Hello World".

Link copied to clipboard

Encoding changer. Base64-String to Base58-String, i.e. "SGVsbG8gV29ybGQ=" -> JxF12TrwUP45BMd"

Link copied to clipboard
Link copied to clipboard

Encoding changer. Base64-String to Hex-String, i.e. "SGVsbG8gV29ybGQ=" -> "48656C6C6F20576F726C64"

Link copied to clipboard

Base64-String to the actual real String, i.e. "SGVsbG8gV29ybGQ=" -> "Hello World".

Link copied to clipboard
fun Any.contextLogger(): <Error class: unknown class>

When called from a companion object, returns the logger for the enclosing class.

Link copied to clipboard
inline fun <Error class: unknown class>.debug(msg: () -> String)

Log a DEBUG level message produced by evaluating the given lamdba, but only if DEBUG logging is enabled.

Link copied to clipboard
fun detailedLogger(): <Error class: unknown class>

Returns the logger used for detailed logging.

Link copied to clipboard
infix fun Int.exactAdd(b: Int): Int
infix fun Long.exactAdd(b: Long): Long

Like the + operator but throws ArithmeticException in case of integer overflow.

Link copied to clipboard
fun <V> Future<V>.getOrThrow(timeout: Duration? = null): V

Same as Future.get except that the ExecutionException is unwrapped.

Link copied to clipboard

Encoding changer. Hex-String to Base58-String, i.e. "48656C6C6F20576F726C64" -> "JxF12TrwUP45BMd"

Link copied to clipboard

Encoding changer. Hex-String to Base64-String, i.e. "48656C6C6F20576F726C64" -> "SGVsbG8gV29ybGQ="

Link copied to clipboard

Hex-String to ByteArray. Accept any hex form (capitalized, lowercase, mixed).

Link copied to clipboard

HEX-String to the actual real String, i.e. "48656C6C6F20576F726C64" -> "Hello World".

Link copied to clipboard
inline fun <T : Any> loggerFor(): <Error class: unknown class>

Usually you won't need this method:

Link copied to clipboard

Converts this String of hexadecimal digits into a ByteArray.

Link copied to clipboard

Method to return the PublicKey object given its Base58-String representation.

Link copied to clipboard
fun ByteArray.sequence(offset: Int = 0, size: Int = this.size): ByteSequence

Wrap size bytes from this ByteArray starting from offset into a new ByteArray.

Link copied to clipboard
Link copied to clipboard

Convert a byte array to a Base58 encoded String.

Link copied to clipboard

Return the Base58 representation of the serialised public key.

Link copied to clipboard

Convert a byte array to a Base64 encoded String.

Link copied to clipboard

Convert a byte array to a hex (Base16) capitalized encoded String.

Link copied to clipboard

Converts this ByteArray into a String of hexadecimal digits.

Link copied to clipboard
Link copied to clipboard

Return the bytes of the SHA-256 output for this public key.

Link copied to clipboard
inline fun <Error class: unknown class>.trace(msg: () -> String)

Log a TRACE level message produced by evaluating the given lamdba, but only if TRACE logging is enabled.

Link copied to clipboard
fun <T> transient(initializer: () -> T): PropertyDelegate<T>

A simple wrapper that enables the use of Kotlin's val x by transient { ... } syntax. Such a property will not be serialized, and if it's missing (or the first time it's accessed), the initializer will be used to set it up.

Link copied to clipboard
inline fun <T, R> UntrustworthyData<T>.unwrap(validator: (T) -> R): R