Skip to content

Commit

Permalink
fix(jsonrpc): returns the correct block hash (nervosnetwork#280)
Browse files Browse the repository at this point in the history
* 2019-06-11 13:40:26

* bug(jsonrpc): returns the correct block hash
  • Loading branch information
mohanson authored and yejiayu committed Jun 11, 2019
1 parent 6aed2fe commit f6a58d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/jsonrpc/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ where
) -> RpcResult<cita::Block> {
let mut res_block = cita::Block {
version: 0,
hash: raw_block.header.hash(),
hash: raw_block.hash,
header: cita::BlockHeader {
timestamp: raw_block.header.timestamp * 1000, // ms
prev_hash: raw_block.header.prevhash,
Expand Down
8 changes: 4 additions & 4 deletions components/transaction-pool/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ impl TxCache {
// TODO: concurrently get
pub fn get_count(&self, count: usize) -> Vec<SignedTransaction> {
let mut all_txs = vec![];
let mut leaf_count = count;
let mut left_count = count;

// TODO: Make sure each bucket is average.
for bucket in self.buckets.iter() {
let txs = bucket.get_count(leaf_count);
let txs = bucket.get_count(left_count);
let txs_len = txs.len();
all_txs.extend(txs);

// Avoid overflow
if leaf_count > txs_len {
leaf_count -= txs_len
if left_count > txs_len {
left_count -= txs_len
} else {
break;
}
Expand Down

0 comments on commit f6a58d0

Please sign in to comment.