Skip to content

Module hb_private.erl

This module provides basic helper utilities for managing the private element of a message, which can be used to store state that is not included in serialized messages, or those granted to users via the APIs.

Description

Private elements of a message can be useful for storing state that is only relevant temporarily. For example, a device might use the private element to store a cache of values that are expensive to recompute. They should not be used for encoding state that makes the execution of a device non-deterministic (unless you are sure you know what you are doing).

The set and get functions of this module allow you to run those keys as AO-Core paths if you would like to have private devices in the messages non-public zone.

See hb_ao for more information about the AO-Core protocol and private elements of messages.

Function Index

from_message/1Return the private key from a message.
get/3Helper for getting a value from the private element of a message.
get/4
get_private_key_test/0*
is_private/1Check if a key is private.
priv_ao_opts/1*The opts map that should be used when resolving paths against the private element of a message.
remove_private_specifier/2*Remove the first key from the path if it is a private specifier.
reset/1Unset all of the private keys in a message.
set/3
set/4Helper function for setting a key in the private element of a message.
set_priv/2Helper function for setting the complete private element of a message.
set_private_test/0*

Function Details

from_message/1

from_message(Msg) -> any()

Return the private key from a message. If the key does not exist, an empty map is returned.

get/3

get(Key, Msg, Opts) -> any()

Helper for getting a value from the private element of a message. Uses AO-Core resolve under-the-hood, removing the private specifier from the path if it exists.

get/4

get(InputPath, Msg, Default, Opts) -> any()

get_private_key_test/0 *

get_private_key_test() -> any()

is_private/1

is_private(Key) -> any()

Check if a key is private.

priv_ao_opts/1 *

priv_ao_opts(Opts) -> any()

The opts map that should be used when resolving paths against the private element of a message.

remove_private_specifier/2 *

remove_private_specifier(InputPath, Opts) -> any()

Remove the first key from the path if it is a private specifier.

reset/1

reset(Msg) -> any()

Unset all of the private keys in a message.

set/3

set(Msg, PrivMap, Opts) -> any()

set/4

set(Msg, InputPath, Value, Opts) -> any()

Helper function for setting a key in the private element of a message.

set_priv/2

set_priv(Msg, PrivMap) -> any()

Helper function for setting the complete private element of a message.

set_private_test/0 *

set_private_test() -> any()