Reference Counted Hook Definitions
Avoid re-uploading the same bytecode to the ledger
Last updated
Avoid re-uploading the same bytecode to the ledger
Last updated
When a novel Hook's web assembly byte-code is uploaded to Xahau, a significant storage burden is imposed on the network. This storage burden is reflected in the Hook Fees charged by the network.
To avoid this burden (and high fees for end users) reference counting is used:
The first time a novel Hook is installed, the SetHook Transaction must provide a significant fee.
The Hook's web assembly byte-code becomes an unowned and reference counted object on the ledger (called a HookDefinition
).
Subsequent installations by the same or other users for an identical Hook (i.e. with identical byte-code) increment the reference count. These installations point at the same object on the ledger. These transactions are billed in a similar way to setting a Trust Line, as the storage burden for the Hook was already paid for in the original Set Hook transaction.
While the reference count on the Hook Definition is greater than zero (meaning one or more accounts still have the Hook installed) the object remains on the ledger.