Skip to main content

setFields(options)

Set the fields to be retrieved for data items of each supported type. The options object has the following structure:
Every field selector is a collection of boolean fields that map to the fields of data items within the batch context iterables. Defining a field of a field selector of a given type and setting it to true will cause the processor to populate the corresponding field of all data items of that type. Here is a definition of a processor that requests hash and fee fields for transactions and the data field for logs:
Same fields will be available for all data items of any given type, including the items accessed via nested references. Suppose we used the processor defined above to subscribe to some transactions as well as some logs, and for each log we requested its parent transaction:
The hash and fee fields will be available both within the data items of the transactions iterable of block data and within the transaction items populating the .transaction field of log data items:
Some data fields, like hash for transactions, are enabled by default but can be disabled by setting a field of a field selector to false. For example, this code will not compile:
Disabling unused fields will improve sync performance, as the fields’ data will not be fetched from the SQD Network gateway.

Data item types and field selectors

Most IDEs support smart suggestions to show the possible field selectors. For VS Code, press Ctrl+Space.
Here we describe the data item types as functions of the field selectors. On Tron, each data item type field maps to the eponymous field of its corresponding field selector. Item fields are divided into three categories:
  • Fields that are always added regardless of the setFields() call.
  • Fields that are enabled by default and can be disabled by setFields(). E.g. a hash field will be fetched for transactions by default, but can be disabled by setting hash: false within the transaction field selector.
  • Fields that can be requested by setFields().

Transaction

Fields of Transaction data items may be requested by the eponymous fields of the field selector. Here’s a detailed description of possible Transaction fields:
Here, TransactionResult is defined as follows:
Request the fields with eponymous field request flags.

Log

Fields of Log data items may be requested by the eponymous fields of the field selector. Here’s a detailed description of possible Log fields:
Request the fields with eponymous field request flags.

Internal transaction

Fields of InternalTransaction data items may be requested by the eponymous fields of the field selector. Here’s a detailed description of possible InternalTransaction fields:
Here, CallValueInfo is defined as follows:
Request the fields with eponymous field request flags.

Block header

BlockHeader data items may have the following fields:
Request the fields with eponymous field request flags.

A complete example

TBA