Skip to content

Commit 5a518f3

Browse files
committed
Revert "Change RPC client to send e_cmd_batch_upd_price instructions"
This reverts commit 296d7d1, as packing all updates into one instruction may hit the solana compute limit.
1 parent 91aa7c4 commit 5a518f3

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

pc/rpc_client.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ rpc::upd_price::upd_price()
809809
ckey_( nullptr ),
810810
gkey_( nullptr ),
811811
akey_( nullptr ),
812-
cmd_( e_cmd_batch_upd_price )
812+
cmd_( e_cmd_upd_price )
813813
{
814814
}
815815

@@ -851,7 +851,7 @@ void rpc::upd_price::set_price( int64_t px,
851851
price_ = px;
852852
conf_ = conf;
853853
st_ = st;
854-
cmd_ = is_agg?e_cmd_agg_price:e_cmd_batch_upd_price;
854+
cmd_ = is_agg?e_cmd_agg_price:e_cmd_upd_price;
855855
}
856856

857857
void rpc::upd_price::set_slot( const uint64_t pub_slot )
@@ -918,30 +918,18 @@ bool rpc::upd_price::build_tx(
918918
tx.add( *first.bhash_ ); // recent block hash
919919

920920
// instructions section
921-
tx.add_len( 1 );
922-
923-
// Create the cmd_batch_upd_price instruction
924-
tx.add( (uint8_t)( n + 2 ) ); // program_id index
925-
926-
// All the accounts this instruction accesses
927-
tx.add_len( 2 + n ); // number of accounts: publish; clock and the symbol accounts
928-
tx.add( (uint8_t)0 ); // index of publish account
921+
tx.add_len( n ); // n instruction(s)
929922
for ( unsigned i = 0; i < n; ++i ) {
923+
tx.add( (uint8_t)( n + 2 ) ); // program_id index
924+
tx.add_len< 3 >(); // 3 accounts: publish, symbol, sysvar
925+
tx.add( (uint8_t)0 ); // index of publish account
930926
tx.add( (uint8_t)( i + 1 ) ); // index of symbol account
931-
}
932-
tx.add( (uint8_t)( n + 1 ) ); // index of sysvar account
933-
934-
// Instruction parameter section
935-
tx.add_len( sizeof( cmd_batch_upd_price_header ) + ( n * sizeof( cmd_upd_price ) ) );
927+
tx.add( (uint8_t)( n + 1 ) ); // index of sysvar account
936928

937-
// Add the header
938-
tx.add( (uint32_t)PC_VERSION );
939-
tx.add( (int32_t)( e_cmd_batch_upd_price ) );
940-
tx.add( (uint64_t)( n ) );
941-
942-
// Add each instruction
943-
for ( unsigned i = 0; i < n; ++i ) {
944929
auto const& upd = *upds[ i ];
930+
931+
// instruction parameter section
932+
tx.add_len<sizeof(cmd_upd_price)>();
945933
tx.add( (uint32_t)PC_VERSION );
946934
tx.add( (int32_t)( upd.cmd_ ) );
947935
tx.add( (int32_t)( upd.st_ ) );

0 commit comments

Comments
 (0)