@@ -923,19 +923,24 @@ bool rpc::upd_price::build_tx(
923923 tx.add ( *first.bhash_ ); // recent block hash
924924
925925 // instructions section
926- unsigned instruction_count = n + 1 ; // 1 compute limit instruction, n upd_price instruction(s)
926+ unsigned instruction_count = n; // n upd_price instruction(s)
927+ if ( cu_units > 0 ) {
928+ instruction_count += 1 ; // Extra instruction for specifying number of cus per instructions
929+ }
927930 if ( cu_price > 0 ) {
928931 instruction_count += 1 ; // Extra instruction for specifying compute unit price
929932 }
930933 tx.add_len ( instruction_count ); // 1 compute limit instruction, 1 compute unit price instruction, n upd_price instruction(s)
931934
932935 // Set compute limit
933- tx.add ( (uint8_t )( n + 3 ) ); // compute budget program id index in accounts list
934- tx.add_len <0 >(); // no accounts
935- // compute limit instruction parameters
936- tx.add_len <sizeof (uint8_t ) + sizeof (uint32_t )>(); // uint8_t enum variant + uint32_t requested compute units
937- tx.add ( (uint8_t ) 2 ); // SetComputeLimit enum variant
938- tx.add ( (uint32_t ) ( cu_units * n ) ); // the budget (scaled for number of instructions)
936+ if ( cu_units > 0 ) {
937+ tx.add ( (uint8_t )( n + 3 ) ); // compute budget program id index in accounts list
938+ tx.add_len <0 >(); // no accounts
939+ // compute limit instruction parameters
940+ tx.add_len <sizeof (uint8_t ) + sizeof (uint32_t )>(); // uint8_t enum variant + uint32_t requested compute units
941+ tx.add ( (uint8_t ) 2 ); // SetComputeLimit enum variant
942+ tx.add ( (uint32_t ) ( cu_units * n ) ); // the budget (scaled for number of instructions)
943+ }
939944
940945 // Set compute unit price
941946 if ( cu_price > 0 ) {
@@ -974,13 +979,24 @@ bool rpc::upd_price::build_tx(
974979 return true ;
975980}
976981
977- void rpc::upd_price::build ( net_wtr& )
982+ void rpc::upd_price::build ( net_wtr& wtr )
978983{
984+ upd_price* upds[] = { this };
985+ build ( wtr, upds, 1 );
979986}
980987
981988
982- void rpc::upd_price::request ( json_wtr& )
989+ void rpc::upd_price::request ( json_wtr& msg )
983990{
991+ upd_price* upds[] = { this };
992+ request ( msg, upds, 1 );
993+ }
994+
995+ bool rpc::upd_price::build (
996+ net_wtr& wtr, upd_price* upds[], const unsigned n
997+ )
998+ {
999+ return build ( wtr, upds, n, 0 , 0 );
9841000}
9851001
9861002bool rpc::upd_price::build (
@@ -996,6 +1012,12 @@ bool rpc::upd_price::build(
9961012 return true ;
9971013}
9981014
1015+ bool rpc::upd_price::request (
1016+ json_wtr& msg, upd_price* upds[], const unsigned n
1017+ ) {
1018+ return request ( msg, upds, n, 0 , 0 );
1019+ }
1020+
9991021bool rpc::upd_price::request (
10001022 json_wtr& msg, upd_price* upds[], const unsigned n, unsigned cu_units, unsigned cu_price
10011023)
0 commit comments