When a Client is creating a Message with an Indexation Payload, can it freely choose the tips/parent to which to refer?
Thanks.
Yes, you can manually specify the parent messages to which your new message refers. This is done by providing the parents field when creating the message. However, you should be cautious when doing this, as it may affect the confirmation of your message if the chosen parents are not optimal.
Here's an example of how you can create a message with an IndexationPayload and manually specify the parents in the Node.js library:
const { ClientBuilder } = require('@iota/client');
const client = new ClientBuilder().node('https://api.lb-0.testnet.chrysalis2.com').build();
(async () => {
const indexationPayload = {
type: 2,
index: 'Hello',
data: 'Tangle',
};
const message = await client.message().parents(['parent1', 'parent2']).payload(indexationPayload).submit();
console.log('Message sent:', message);
})();
Replace 'parent1' and 'parent2' with the actual message ids of the parent messages you want to reference. Keep in mind that this example is for the Node.js library, and the implementation may vary for other languages.
Remember that manually specifying parents can be risky, and it's generally recommended to let the node handle tip selection for you.
Credit goes to Kapa.ai and IOTA&Shimmer documentation
The tips/parents are randomly chosen and I quote:
A node should keep a set of non-lazy tips (score 2). Every time a node is asked to select tips to be approved, it will pick randomly from the set. A node must not execute tip-selection if it is not synchronized.
A tip should not be removed from the tips set immediately after it was selected in select(), to make it possible for it to be re-selected, which in turn makes the Tangle wider and improves synchronization speed. A tip is removed from the tips set if X amount of direct approvers are reached or if a certain amount of time T passed. It is recommended to use X = 2 and T = 3 but the threshold should be configurable.
To find further information on this topic explore the TIP (Tangle Improvement Proposal) available here:
https://wiki.iota.org/tips/tips/TIP-0003/
Best, Antonio