aiken_design_patterns/linked_list/unordered
Types
Every list node utxo:
- has a unique
key
(unless it’s the root node) - has a unique
link
to another node’s key (unless it’s the last node of the list) - holds some app-specific
data
Constructors
-
NodeDatum { key: NodeKey, link: NodeKey, data: Data }
Same as Option
, but with more informative constructor names.
Constructors
-
Key { key: ByteArray }
-
Empty
Constants
Functions
Data types, constants, and accessors
Predicates (used outside of list validators)
Prove that a node belongs to the given list and is its root.
Prove that a node belongs to the given list and is its last node.
Prove that the given list is empty, as witnessed by a node that
is both the root and last node of the list.
Prove that a key is a member of the given list, as witnessed by a node
that satisfies the membership predicate with the key.
State integrity handlers (used in list spending validator)
Detect whether the list’s minting policy is invoked in the transaction,
so that the spending validator can forward to it.
modify_data(
node_mint: Dict<AssetName, Int>,
own_input: Output,
own_output: Output,
node_nft_policy_id: ByteArray,
node_nft_asset_name: ByteArray,
) -> Bool
Modify the data
field of a list node without changing the key
and
link
fields.
State transition handlers (used in list minting policy)
Initialize an empty unordered list.
Application code must ensure that this action can happen only once.
Deinitialize an empty unordered list.
prepend_unsafe(
key_to_prepend: NodeKey,
prepended_node_index: Int,
anchor_node_output_index: Int,
node_inputs: List<Output>,
node_outputs: List<Output>,
node_mint: Dict<AssetName, Int>,
) -> Bool
Prepend a new node to the beginning of the list.
WARNING: An application using a key-unordered list MUST only add nodes with
unique keys to the list. Duplicate keys break the linked list data structure.
The index arguments in this function are relative to the node_inputs
and node_outputs. They are NOT absolute.
append_unsafe(
key_to_append: NodeKey,
appended_node_index: Int,
anchor_node_output_index: Int,
node_inputs: List<Output>,
node_outputs: List<Output>,
node_mint: Dict<AssetName, Int>,
) -> Bool
Append a new node to the end of the list.
WARNING: An application using a key-unordered list MUST only add nodes with
unique keys to the list. Duplicate keys break the linked list data structure.
The index arguments in this function are relative to the node_inputs
and node_outputs. They are NOT absolute.
remove(
key_to_remove: NodeKey,
removed_node_input_index: Int,
anchor_node_input_index: Int,
node_inputs: List<Output>,
node_outputs: List<Output>,
node_mint: Dict<AssetName, Int>,
) -> Bool
Remove a non-root node from the list.
The index arguments in this function are relative to the node_inputs
and node_outputs. They are NOT absolute.
Prove that a node belongs to the given list and is its root.
Prove that a node belongs to the given list and is its last node.
Prove that the given list is empty, as witnessed by a node that is both the root and last node of the list.
Prove that a key is a member of the given list, as witnessed by a node that satisfies the membership predicate with the key.
Detect whether the list’s minting policy is invoked in the transaction, so that the spending validator can forward to it.
modify_data(
node_mint: Dict<AssetName, Int>,
own_input: Output,
own_output: Output,
node_nft_policy_id: ByteArray,
node_nft_asset_name: ByteArray,
) -> Bool
Modify the data
field of a list node without changing the key
and
link
fields.
State transition handlers (used in list minting policy)
Initialize an empty unordered list.
Application code must ensure that this action can happen only once.
Deinitialize an empty unordered list.
prepend_unsafe(
key_to_prepend: NodeKey,
prepended_node_index: Int,
anchor_node_output_index: Int,
node_inputs: List<Output>,
node_outputs: List<Output>,
node_mint: Dict<AssetName, Int>,
) -> Bool
Prepend a new node to the beginning of the list.
WARNING: An application using a key-unordered list MUST only add nodes with
unique keys to the list. Duplicate keys break the linked list data structure.
The index arguments in this function are relative to the node_inputs
and node_outputs. They are NOT absolute.
append_unsafe(
key_to_append: NodeKey,
appended_node_index: Int,
anchor_node_output_index: Int,
node_inputs: List<Output>,
node_outputs: List<Output>,
node_mint: Dict<AssetName, Int>,
) -> Bool
Append a new node to the end of the list.
WARNING: An application using a key-unordered list MUST only add nodes with
unique keys to the list. Duplicate keys break the linked list data structure.
The index arguments in this function are relative to the node_inputs
and node_outputs. They are NOT absolute.
remove(
key_to_remove: NodeKey,
removed_node_input_index: Int,
anchor_node_input_index: Int,
node_inputs: List<Output>,
node_outputs: List<Output>,
node_mint: Dict<AssetName, Int>,
) -> Bool
Remove a non-root node from the list.
The index arguments in this function are relative to the node_inputs
and node_outputs. They are NOT absolute.
Initialize an empty unordered list.
Application code must ensure that this action can happen only once.
Deinitialize an empty unordered list.
prepend_unsafe(
key_to_prepend: NodeKey,
prepended_node_index: Int,
anchor_node_output_index: Int,
node_inputs: List<Output>,
node_outputs: List<Output>,
node_mint: Dict<AssetName, Int>,
) -> Bool
Prepend a new node to the beginning of the list.
WARNING: An application using a key-unordered list MUST only add nodes with unique keys to the list. Duplicate keys break the linked list data structure.
The index arguments in this function are relative to the node_inputs and node_outputs. They are NOT absolute.
append_unsafe(
key_to_append: NodeKey,
appended_node_index: Int,
anchor_node_output_index: Int,
node_inputs: List<Output>,
node_outputs: List<Output>,
node_mint: Dict<AssetName, Int>,
) -> Bool
Append a new node to the end of the list.
WARNING: An application using a key-unordered list MUST only add nodes with unique keys to the list. Duplicate keys break the linked list data structure.
The index arguments in this function are relative to the node_inputs and node_outputs. They are NOT absolute.
remove(
key_to_remove: NodeKey,
removed_node_input_index: Int,
anchor_node_input_index: Int,
node_inputs: List<Output>,
node_outputs: List<Output>,
node_mint: Dict<AssetName, Int>,
) -> Bool
Remove a non-root node from the list.
The index arguments in this function are relative to the node_inputs and node_outputs. They are NOT absolute.