This node represents a byte discrimination strategy where the data is identified by a constant value at a given offset. Discriminator nodes are used to distinguish between different types of accounts or instructions in a program.
Attribute | Type | Description |
---|---|---|
kind |
"constantDiscriminatorNode" |
The node discriminator. |
offset |
number |
The byte at which the constant should be located. |
Attribute | Type | Description |
---|---|---|
constant |
ConstantValueNode |
The constant value that identifies the data. |
Helper function that creates a ConstantDiscriminatorNode
object from a constant value node and an optional offset.
const node = constantDiscriminatorNode(constantValueNodeFromString('utf8', 'Hello'), 64);
accountNode({
discriminators: [constantDiscriminatorNode(constantValueNode(numberTypeNode('u32'), numberValueNode(42)))],
// ...
});
instructionNode({
discriminators: [constantValueNodeFromBytes('base16', '0011223344556677')],
// ...
});