Conversation
|
I think this is a good idea but should we perhaps just add one new field OutgoingHookOn. If it's absent then HookOn is used for both (as you've already coded here) but if the new field is present then outgoing is filtered through it. A little bit less confusing than adding two new fields? |
When considering a scenario where a HookDefinition created by another account has OutgoingHookOn set,
|
I think if OutgoingHookOn is specified in the definition and you install that hook, but don't specify it, then you'd use the definition's OutgoingHookOn. It's up to you to know what's in the definition. If you want your HookOn field to be the same as OutgoingHookOn then the safest thing to do is actually specify a OutgoingHookOn (identical to HookOn) every time. The backwards compatibility mode is only there to prevent stuff from breaking. People shouldn't use it unless they have to. |
|
Do you have any thoughts on using IncomingHookOn instead of OutgoingHookOn? The Functional Hooks currently under development can only be called from Incoming Txn, so I think it would be better to use the name IncomingHookOn here for this feature. |
I think it fine as long as its well documented. So in the absence of IncomingHookOn field the HookOn field is both (incoming and outgoing) but if you add IncomingHookOn then HookOn only becomes the outgoing. |
|
Suggest changing names to HookOnIncoming HookOnOutgoing... following general convention of "name" "action" in both hook apis and transactors |
src/ripple/app/tx/impl/SetHook.cpp
Outdated
| return false; | ||
| if (!ctx.rules.enabled(featureHookOnV2) || | ||
| !(hookSetObj.isFieldPresent(sfHookOnOutgoing) && | ||
| hookSetObj.isFieldPresent(sfHookOnIncoming))) |
There was a problem hiding this comment.
Negative A or Negative (B and C) is not intuitive. Prefer positive rather than negative logic, or apply De morgans law (Negative A or Negative B or Negative C) for ease of reading and to help future programmers not make a logic error here.
Best practice is make the condition bigger and easier to read like this:
if (enabled(featureHookOnV2))
{
if (isFieldPresent(sfHookOnOutgoing) && isFieldPresent(sfHookOnIncoming))
{
// pass, this is valid in v2
}
else
{
// error here
}
}
High Level Overview of Change
Instead of making the Outgoing/Incoming txn check within the Hook code, this makes it possible to check it outside the Hook code by defining it in the HookDefinition.
Context of Change
Add OutgoingHookOn/IncomingHookOn field
In the HookDefinition field, one of the following fields is set
Type of Change
.gitignore, formatting, dropping support for older tooling)API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)