Skip to content

Commit e69ce2a

Browse files
committed
[pyth_admin] Separate out admin commands into new binary.
1 parent 692e826 commit e69ce2a

File tree

12 files changed

+698
-583
lines changed

12 files changed

+698
-583
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ add_executable( pythd pcapps/pythd.cpp )
7171
target_link_libraries( pythd ${PC_DEP} )
7272
add_executable( pyth pcapps/pyth.cpp )
7373
target_link_libraries( pyth ${PC_DEP} )
74+
add_executable( pyth_admin pcapps/pyth_admin.cpp )
75+
target_link_libraries( pyth_admin ${PC_DEP} )
7476
add_executable( pyth_csv pcapps/pyth_csv.cpp )
7577
target_link_libraries( pyth_csv ${PC_DEP} )
7678
add_executable( pyth_tx pcapps/tx_svr.cpp pcapps/pyth_tx.cpp )
@@ -81,7 +83,7 @@ target_link_libraries( pyth_tx ${PC_DEP} )
8183
#
8284

8385
install( TARGETS pc DESTINATION lib )
84-
install( TARGETS pyth pythd pyth_csv pyth_tx DESTINATION bin )
86+
install( TARGETS pyth pyth_admin pythd pyth_csv pyth_tx DESTINATION bin )
8587
install( FILES ${PC_HDR} DESTINATION include/pc )
8688
install( FILES program/src/oracle/oracle.h DESTINATION include/oracle )
8789

doc/getting_started.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting started with publishing via pyth-client
22

3-
The pyth-client repo consists of a C++ library (libpc.a), a command-line administration tool (pyth), a json/websocket-based server (pythd) and a gateway/proxy server for price publishing (pyth_tx).
3+
The pyth-client repo consists of a C++ library (libpc.a), two command-line administration tools (pyth & pyth_admin), a json/websocket-based server (pythd) and a gateway/proxy server for price publishing (pyth_tx).
44

55
You can integrate with libpc directly in your application. See `pctest/test_publish.cpp` for an example. Or, you can integrate with the pythd server via json/websockets. See `pctest/test_publish.py` for an example.
66

@@ -34,7 +34,7 @@ Once permissioned, you need two additional public keys in the key-store. The id
3434
Use the init_key_store.sh script to initialize these account keys:
3535

3636
```
37-
KENV=devnet # or mainnet-beta
37+
KENV=devnet # or testnet, prodbeta
3838
3939
# initialize keys for solana devnet
4040
../pctest/init_key_store.sh $KENV $KDIR
@@ -47,17 +47,17 @@ Once permissioned, you can test your setup by running the test_publish.cpp examp
4747

4848

4949
```
50-
KHOST=api.devnet.solana.com
50+
RHOST=api.devnet.solana.com
5151
THOST=<your_pyth_tx_host>
52-
./test_publish -k $KDIR -r $KHOST -t $THOST
52+
./test_publish -k $KDIR -r $RHOST -t $THOST
5353
```
5454

5555
The -r and -t options correspond to the locations of required solana validator and pyth_tx server instances.
5656

5757
You can also publish to solana using the pythd server. Start up the server using the same key-store directory and host specification:
5858

5959
```
60-
./pythd -k $KDIR -r $KHOST -t $THOST
60+
./pythd -k $KDIR -r $RHOST -t $THOST
6161
```
6262

6363
Run the test_publish.py example program on the same host to connect to the pythd server:
@@ -80,7 +80,7 @@ You can run your own pyth_tx instance (recommended) or connect to provided serve
8080
Start up the pyth_tx server as follows:
8181

8282
```
83-
./pyth_tx -r $KHOST
83+
./pyth_tx -r $RHOST
8484
```
8585

8686
The -r option points to the IP address of a solana validator node or rpc end-point. It can be the same or different IP address to that passed to test_publish or pythd as long as it corresponds to the same environment.
@@ -91,7 +91,7 @@ The -r option points to the IP address of a solana validator node or rpc end-poi
9191
The pythd server also exports a dashboard web page for watching the ticking pyth prices. The public key you create above does not need publish-permission to watch the ticking pyth prices. To activate the dashboard page include an additional `-w` argument to pythd pointing at the html/javscript code directory:
9292

9393
```
94-
./pythd -k $KDIR -r $KHOST -w ../dashboard
94+
./pythd -k $KDIR -r $RHOST -w ../dashboard
9595
```
9696

9797
Connect to the dashboard via http://localhost:8910.

pc/manager.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,30 @@ void manager::submit( tx_request *req )
793793
tconn_.add_send( msg );
794794
}
795795

796+
bool manager::submit_poll( request *req )
797+
{
798+
// submit request and poll for completion or error
799+
submit( req );
800+
while( !req->get_is_done() &&
801+
!req->get_is_err() &&
802+
!get_is_err() ) {
803+
poll();
804+
}
805+
if ( req->get_is_err() ) {
806+
PC_LOG_ERR( "request error")
807+
.add( "error", req->get_err_msg() )
808+
.end();
809+
return false;
810+
}
811+
if ( get_is_err() ) {
812+
PC_LOG_ERR( "request error")
813+
.add( "error", get_err_msg() )
814+
.end();
815+
return false;
816+
}
817+
return true;
818+
}
819+
796820
void manager::on_connect()
797821
{
798822
// callback user with connection status

pc/manager.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ namespace pc
132132
void submit( request * );
133133
void submit( tx_request * );
134134

135+
// submit pyth client api request and poll until finished
136+
bool submit_poll( request * );
137+
135138
// check status condition
136139
bool has_status( int status ) const;
137140

0 commit comments

Comments
 (0)