Skip to content

Commit fb188d6

Browse files
Little-Peonyclaude
andcommitted
docs: fix missing api.proto import and clarify auto-registration
implement-a-customized-actuator (EN+ZH): - Add the missing 'import "core/contract/math_contract.proto"' step in api.proto; without it the proto compiler cannot resolve SumContract in the InvokeSum RPC definition (compile failure) - Add a note explaining that SumActuator must live in org.tron.core.actuator: TransactionRegister.registerActuator() uses Reflections to scan that package at startup and auto-registers every AbstractActuator subclass via the super() constructor call into TransactionFactory Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fedb29e commit fb188d6

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

docs/implement-a-customized-actuator-en.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ message Transaction {
4242
}
4343
```
4444

45-
Then register a function to ensure that gRPC can receive and identify the requests of this contract. Currently, gRPC protocols are all defined in `src/main/protos/api/api.proto`. To add an `InvokeSum` interface in Wallet Service:
45+
Then register a function to ensure that gRPC can receive and identify the requests of this contract. Currently, gRPC protocols are all defined in `src/main/protos/api/api.proto`. First add the import for the new proto file at the top of `api.proto`:
46+
47+
```protobuf
48+
import "core/contract/math_contract.proto";
49+
```
50+
51+
Then add an `InvokeSum` interface in the Wallet service:
4652

4753
```protobuf
4854
service Wallet {
@@ -76,6 +82,8 @@ After compilation, the corresponding .class under the java_out directory will be
7682

7783
For now, the default Actuator supported by java-tron is located in `org.tron.core.actuator`. Creating `SumActuator` under this directory:
7884

85+
> **Note**: The Actuator must be placed in the `org.tron.core.actuator` package. At node startup, `TransactionRegister.registerActuator()` uses reflection to scan that package and auto-discovers every `AbstractActuator` subclass. Each subclass is instantiated once (triggering the `super()` constructor which calls `TransactionFactory.register()`), so no manual registration code is needed.
86+
7987
```java
8088
import static org.tron.core.config.Parameter.ChainConstant.TRANSFER_FEE;
8189

docs/implement-a-customized-actuator-zh.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ message Transaction {
4444
}
4545
```
4646

47-
然后还需要注册一个方法来保证 gRPC 能够接收并识别该类型合约的请求,目前 gRPC 协议统一定义在 src/main/protos/api/api.proto,在 api.proto 中的 Wallet Service 新增 `InvokeSum` 接口:
47+
然后还需要注册一个方法来保证 gRPC 能够接收并识别该类型合约的请求,目前 gRPC 协议统一定义在 src/main/protos/api/api.proto。首先在 `api.proto` 顶部添加对新 proto 文件的 import:
48+
49+
```protobuf
50+
import "core/contract/math_contract.proto";
51+
```
52+
53+
然后在 Wallet service 中新增 `InvokeSum` 接口:
4854

4955
```protobuf
5056
service Wallet {
@@ -78,6 +84,8 @@ protoc -I=src/main/protos/api -I=src/main/protos/core -I=src/main/protos --java
7884

7985
目前 java-tron 默认支持的 Actuator 存放在该模块的 org.tron.core.actuator 目录下,同样在该目录下创建 `SumActuator`
8086

87+
> **注意**:Actuator 必须放在 `org.tron.core.actuator` 包下。节点启动时,`TransactionRegister.registerActuator()` 会通过反射扫描该包,自动发现所有 `AbstractActuator` 的子类,并各实例化一次(触发 `super()` 构造器,进而调用 `TransactionFactory.register()`)。因此无需手动编写注册代码。
88+
8189
```java
8290
import static org.tron.core.config.Parameter.ChainConstant.TRANSFER_FEE;
8391

0 commit comments

Comments
 (0)