Skip to content

Commit 1e08aeb

Browse files
authored
rename cfx_getTransactionCount to cfx_getNextNonce (#1139)
* rename cfx_getTransactionCount to cfx_getNextNonce
1 parent 0b58d3f commit 1e08aeb

File tree

12 files changed

+20
-29
lines changed

12 files changed

+20
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ target
66
build/
77
.*
88
**/blockchain_db/
9+
**/sqlite_db/
910
**/net_config/
1011
**/*.log
1112
**/testnet.toml

client/src/rpc/impls/alliance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl Cfx for CfxHandler {
207207
fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> RpcResult<Option<RpcBlock>>;
208208
fn epoch_number(&self, epoch_num: Option<EpochNumber>) -> RpcResult<RpcU256>;
209209
fn gas_price(&self) -> RpcResult<RpcU256>;
210-
fn transaction_count(&self, address: RpcH160, num: Option<BlockHashOrEpochNumber>) -> RpcResult<RpcU256>;
210+
fn next_nonce(&self, address: RpcH160, num: Option<BlockHashOrEpochNumber>) -> RpcResult<RpcU256>;
211211

212212
fn admin(&self, address: RpcH160, num: Option<EpochNumber>) -> BoxFuture<RpcH160>;
213213
fn sponsor_info(&self, address: RpcH160, num: Option<EpochNumber>) -> BoxFuture<RpcSponsorInfo>;

client/src/rpc/impls/cfx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ impl RpcImpl {
359359

360360
if tx.nonce.is_none() {
361361
let nonce = consensus_graph
362-
.transaction_count(
362+
.next_nonce(
363363
tx.from.clone().into(),
364364
BlockHashOrEpochNumber::EpochNumber(
365365
EpochNumber::LatestState,
@@ -834,7 +834,7 @@ impl Cfx for CfxHandler {
834834
fn blocks_by_epoch(&self, num: EpochNumber) -> RpcResult<Vec<RpcH256>>;
835835
fn epoch_number(&self, epoch_num: Option<EpochNumber>) -> RpcResult<RpcU256>;
836836
fn gas_price(&self) -> RpcResult<RpcU256>;
837-
fn transaction_count(&self, address: RpcH160, num: Option<BlockHashOrEpochNumber>) -> RpcResult<RpcU256>;
837+
fn next_nonce(&self, address: RpcH160, num: Option<BlockHashOrEpochNumber>) -> RpcResult<RpcU256>;
838838
}
839839

840840
target self.rpc_impl {

client/src/rpc/impls/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl RpcImpl {
218218
.and_then(|vec| Ok(vec.into_iter().map(|x| x.into()).collect()))
219219
}
220220

221-
pub fn transaction_count(
221+
pub fn next_nonce(
222222
&self, address: RpcH160, num: Option<BlockHashOrEpochNumber>,
223223
) -> RpcResult<RpcU256> {
224224
let consensus_graph = self
@@ -230,12 +230,12 @@ impl RpcImpl {
230230
EpochNumber::LatestState,
231231
));
232232
info!(
233-
"RPC Request: cfx_getTransactionCount address={:?} epoch_num={:?}",
233+
"RPC Request: cfx_getNextNonce address={:?} epoch_num={:?}",
234234
address, num
235235
);
236236

237237
consensus_graph
238-
.transaction_count(address.into(), num.into())
238+
.next_nonce(address.into(), num.into())
239239
.map_err(RpcError::invalid_params)
240240
.map(|x| x.into())
241241
}

client/src/rpc/impls/light.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl Cfx for CfxHandler {
446446
fn blocks_by_epoch(&self, num: EpochNumber) -> RpcResult<Vec<RpcH256>>;
447447
fn epoch_number(&self, epoch_num: Option<EpochNumber>) -> RpcResult<RpcU256>;
448448
fn gas_price(&self) -> RpcResult<RpcU256>;
449-
fn transaction_count(&self, address: RpcH160, num: Option<BlockHashOrEpochNumber>) -> RpcResult<RpcU256>;
449+
fn next_nonce(&self, address: RpcH160, num: Option<BlockHashOrEpochNumber>) -> RpcResult<RpcU256>;
450450
}
451451

452452
target self.rpc_impl {

client/src/rpc/traits/cfx.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ pub trait Cfx {
107107
#[rpc(name = "cfx_getBestBlockHash")]
108108
fn best_block_hash(&self) -> RpcResult<RpcH256>;
109109

110-
/// Returns the number of transactions sent from given address at given time
111-
/// (epoch number).
112-
#[rpc(name = "cfx_getTransactionCount")]
113-
fn transaction_count(
110+
/// Returns the nonce should be filled in next sending transaction from
111+
/// given address at given time (epoch number).
112+
#[rpc(name = "cfx_getNextNonce")]
113+
fn next_nonce(
114114
&self, addr: RpcH160, epoch_number: Option<BlockHashOrEpochNumber>,
115115
) -> RpcResult<RpcU256>;
116116

@@ -124,16 +124,6 @@ pub trait Cfx {
124124
// fn block_trasaction_count_by_number(&self, BlockNumber) ->
125125
// BoxFuture<Option<RpcU256>>;
126126

127-
// /// Returns the number of uncles in a block with given hash.
128-
// #[rpc(name = "cfx_getUncleCountByBlockHash")]
129-
// fn block_uncles_count_by_hash(&self, RpcH256) ->
130-
// BoxFuture<Option<RpcU256>>;
131-
132-
// /// Returns the number of uncles in a block with given block
133-
// number. #[rpc(name = "cfx_getUnclesCountByBlockNumber")]
134-
// fn block_uncles_count_by_number(&self, BlockNumber) ->
135-
// BoxFuture<Option<RpcU256>>;
136-
137127
/// Sends signed transaction, returning its hash.
138128
#[rpc(name = "cfx_sendRawTransaction")]
139129
fn send_raw_transaction(&self, raw_tx: Bytes) -> RpcResult<RpcH256>;

core/src/alliance_tree_graph/consensus/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl TreeGraphConsensus {
426426
Some((results_with_epoch, address, state_root))
427427
}
428428

429-
pub fn transaction_count(
429+
pub fn next_nonce(
430430
&self, address: Address,
431431
block_hash_or_epoch_number: BlockHashOrEpochNumber,
432432
) -> Result<U256, String>

core/src/consensus/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ impl ConsensusGraph {
687687
}
688688
}
689689

690-
pub fn transaction_count(
690+
pub fn next_nonce(
691691
&self, address: H160,
692692
block_hash_or_epoch_number: BlockHashOrEpochNumber,
693693
) -> Result<U256, String>

run/throttling.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cfx_getBlockByHash="20,20,5,1,5"
3535
cfx_getBlockByHashWithPivotAssumption="20,20,5,1,5"
3636
cfx_getBlockByEpochNumber="20,20,5,1,5"
3737
cfx_getBestBlockHash="50,50,10,1,5"
38-
cfx_getTransactionCount="50,50,10,1,5"
38+
cfx_getNextNonce="50,50,10,1,5"
3939
cfx_sendRawTransaction="50,50,10,1,5"
4040
cfx_call="20,20,5,1,5"
4141
cfx_getLogs="20,20,5,1,5"

src/cli.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ subcommands:
342342
about: Get nonce of specified account
343343
args:
344344
- rpc-method:
345-
default_value: cfx_getTransactionCount
345+
default_value: cfx_getNextNonce
346346
hidden: true
347347
- rpc-args:
348348
multiple: true

tests/conflux/rpc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ def get_admin(self, addr: str, epoch: str = None) -> str:
193193
''' Ignore block_hash if epoch is not None '''
194194
def get_nonce(self, addr: str, epoch: str = None, block_hash: str = None) -> int:
195195
if epoch is None and block_hash is None:
196-
return int(self.node.cfx_getTransactionCount(addr), 0)
196+
return int(self.node.cfx_getNextNonce(addr), 0)
197197
elif epoch is None:
198-
return int(self.node.cfx_getTransactionCount(addr, "hash:"+block_hash), 0)
198+
return int(self.node.cfx_getNextNonce(addr, "hash:"+block_hash), 0)
199199
else:
200-
return int(self.node.cfx_getTransactionCount(addr, epoch), 0)
200+
return int(self.node.cfx_getNextNonce(addr, epoch), 0)
201201

202202
def send_raw_tx(self, raw_tx: str) -> str:
203203
tx_hash = self.node.cfx_sendRawTransaction(raw_tx)

tests/test_framework/blocktools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def wait_for_initial_nonce_for_address(node, addr, timeout=10):
9595
raise AssertionError("Wait for initial nonce for address {} timeout after {} seconds, last exception is {}"
9696
.format(addr, timeout, last_exception))
9797
try:
98-
nonce = int(node.cfx_getTransactionCount(addr), 0)
98+
nonce = int(node.cfx_getNextNonce(addr), 0)
9999
except jsonrpcclient.exceptions.ReceivedErrorResponseError as e:
100100
# It's possible that
101101
last_exception = e

0 commit comments

Comments
 (0)