@@ -809,7 +809,7 @@ rpc::upd_price::upd_price()
809809 ckey_( nullptr ),
810810 gkey_( nullptr ),
811811 akey_( nullptr ),
812- cmd_( e_cmd_upd_price )
812+ cmd_( e_cmd_batch_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_upd_price ;
854+ cmd_ = is_agg?e_cmd_agg_price:e_cmd_batch_upd_price ;
855855}
856856
857857void rpc::upd_price::set_slot ( const uint64_t pub_slot )
@@ -918,18 +918,30 @@ bool rpc::upd_price::build_tx(
918918 tx.add ( *first.bhash_ ); // recent block hash
919919
920920 // instructions section
921- tx.add_len ( n ); // n instruction(s)
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
922929 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
926930 tx.add ( (uint8_t )( i + 1 ) ); // index of symbol account
927- tx.add ( (uint8_t )( n + 1 ) ); // index of sysvar account
931+ }
932+ tx.add ( (uint8_t )( n + 1 ) ); // index of sysvar account
928933
929- auto const & upd = *upds[ i ];
934+ // Instruction parameter section
935+ tx.add_len ( sizeof ( cmd_batch_upd_price_header ) + ( n * sizeof ( cmd_upd_price ) ) );
930936
931- // instruction parameter section
932- tx.add_len <sizeof (cmd_upd_price)>();
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 ) {
944+ auto const & upd = *upds[ i ];
933945 tx.add ( (uint32_t )PC_VERSION );
934946 tx.add ( (int32_t )( upd.cmd_ ) );
935947 tx.add ( (int32_t )( upd.st_ ) );
0 commit comments