You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-45Lines changed: 9 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,58 +34,22 @@ through the `RUST_LOG` environment variable using the standard
34
34
`error|warn|info|debug|trace`.
35
35
36
36
#### Plain/JSON logging
37
-
By default, pyth-agent will print plaintext log statements. This can be switched to structured JSON output with `-l json`.
38
-
39
-
#### Code location in logs
40
-
For debugging purposes, you can specify `-L` to print file/line information with each log statement. This option is disabled by default.
41
-
42
-
### Key Store Config Migration [v1.x.x LEGACY]
43
-
Pyth agent v2.0.0 introduces a simplified program and mapping key configuration. This breaking change alters how you define program/mapping key options in your agent config:
44
-
```toml
45
-
# Old v1.x.x way
46
-
[primarynetwork]
47
-
key_store.root_path = "/path/to/keystore"
48
-
key_store.publish_keypair_path = "publish_key_pair.json"# Relative path from root_path, "publish_key_pair.json" by default
49
-
key_store.program_key_path = "program_key.json"# Relative path from root_path, "program_key.json" by default
50
-
key_store.mapping_key_path = "mapping_key.json"# Relative path from root_path, "mapping_key.json" by default
51
-
52
-
# [...]
53
-
54
-
# New v2.0.0 way
55
-
[primary_network]
56
-
key_store.publish_keypair_path = "/path/to/keypair.json"# The root_path is gone, we specify the full path
57
-
# Not using separate files anymore
58
-
key_store.program_key = "LiteralProgramPubkeyInsideTheConfig"# contents of legacy program_key.json;
59
-
key_store.mapping_key = "LiteralMappingPubkeyInsideTheConfig"# contents of legacy mapping_key.json
60
-
61
-
# [...]
62
-
63
-
```
64
-
65
-
#### Automatic Migration
66
-
If you are upgrading to agent v2.0.0 with an existing config, you can use the provided automatic migrator program:
67
-
```shell
68
-
# Build
69
-
$ cargo build --release
70
-
# Run the migrator, making sure that the key store with previous keys is reachable
#### `Could not open {mapping|program|...} key file`
75
-
This error can appear if some of your program/mapping/publish key
76
-
files are not reachable under their `key_store.*` setting values.
77
-
78
-
Ensure that your current working directory is correct for reaching the
79
-
key store path inside your config. You may also migrate manually by
80
-
changing `key_store.*_key_path` and `key_store.publish_keypair_path`
81
-
options by hand, as described in the config example above.
37
+
Pyth agent will print logs in plaintext in terminal and JSON format in non-terminal environments (e.g. when writing to a file).
82
38
83
39
## Run
84
40
`cargo run --release -- --config <your_config.toml>` will build and run the agent in a single step.
85
41
86
42
## Publishing API
87
43
A running agent will expose a WebSocket serving the JRPC publishing API documented [here](https://docs.pyth.network/documentation/publish-data/pyth-client-websocket-api). See `config/config.toml` for related settings.
88
44
45
+
## Best practices
46
+
If your publisher is publishing updates to more than 50 price feeds, it is recommended that you do the following to reduce the connection overhead to the agent:
47
+
- Batch your messages together and send them as a single request to the agent (as an array of messages). The agent will respond to the batch messages
48
+
with a single response containing an array of individual responses (in the same order). If batching is not possible, you can disable the `instant_flush` option
49
+
in the configuration file to let agent send the responses every `flush_interval` seconds.
50
+
- Do not use subscribe to the price schedule. Instead, define a schedule on the client side and send the messages based on your own schedule. Ideally
51
+
you should send price updates as soon as you have them to increase the latency of the data on the Pyth Network.
52
+
89
53
# Development
90
54
## Unit Testing
91
55
A collection of Rust unit tests is provided, ran with `cargo test`.
0 commit comments