Skip to content

Commit cc1e6f1

Browse files
committed
fixup
1 parent c715cf3 commit cc1e6f1

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

pc/request.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,7 @@ bool price::update(
700700
if ( mgr->get_do_tx() )
701701
mgr->submit( preq_ );
702702
else {
703-
get_rpc_client()->send(
704-
(pc::rpc::upd_price **)(&preq_),
705-
1,
706-
get_manager()->get_requested_upd_price_cu_units(),
707-
get_manager()->get_requested_upd_price_cu_price()
708-
);
703+
get_rpc_client()->send( preq_ );
709704
tvec_.emplace_back( std::string( 100, '\0' ), preq_->get_sent_time() );
710705
preq_->get_signature()->enc_base58( tvec_.back().first );
711706
PC_LOG_DBG( "sent price update transaction" )

pc/rpc_client.cpp

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

9861002
bool 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+
9991021
bool rpc::upd_price::request(
10001022
json_wtr& msg, upd_price* upds[], const unsigned n, unsigned cu_units, unsigned cu_price
10011023
)

pc/rpc_client.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ namespace pc
425425
void request( json_wtr& ) override;
426426
void response( const jtree& ) override;
427427

428+
static bool build( net_wtr&, upd_price*[], unsigned n );
429+
static bool request( json_wtr&, upd_price*[], const unsigned n );
430+
428431
static bool build( net_wtr&, upd_price*[], unsigned n, unsigned cu_units, unsigned cu_price );
429432
static bool request( json_wtr&, upd_price*[], const unsigned n, unsigned cu_units, unsigned cu_price );
430433

0 commit comments

Comments
 (0)