Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Only tidy ups
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffsmale90 committed Jun 28, 2023
1 parent 44405b7 commit 8093a75
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,10 @@ export default class BlockManager extends Manager<Block> {
]);
if (json) {
const number = BigInt(json.number);
const timestamp = BigInt(json.timestamp);
if (number <= fallback.blockNumber.toBigInt()) {
const common = fallback.getCommonForBlock(this.#common, {
number,
timestamp
timestamp: BigInt(json.timestamp)
});
return new Block(BlockManager.rawFromJSON(json, common), common);
}
Expand Down
14 changes: 4 additions & 10 deletions src/chains/ethereum/ethereum/src/forking/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@ export class ForkCache extends Cache {
* Looks up address in underlying trie.
* @param address - Address of account
*/
const lookupAccount: (
address: Address
) => Promise<Account | undefined> = async (address: Address) => {
const lookupAccount = async (address: Address) => {
const rlp = await (trie as ForkTrie).get(address.buf);
return rlp ? Account.fromRlpSerializedAccount(rlp) : undefined;
};
super({
getCb: lookupAccount,
putCb: trie.put.bind(trie),
deleteCb: trie.del.bind(trie)
});
return rlp ? Account.fromRlpSerializedAccount(rlp) : new Account();
}
super({ getCb: lookupAccount, putCb: trie.put.bind(trie), deleteCb: trie.del.bind(trie) });
}
}
11 changes: 3 additions & 8 deletions src/chains/ethereum/ethereum/src/forking/fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,12 @@ export class Fork {
const hfTimestamp = BigInt(hf.timestamp);
if (block.timestamp >= hfTimestamp) {
hardfork = hf.name;
} else {
break;
}
} else if (hf.block) {
if (block.number >= BigInt(hf.block)) {
hardfork = hf.name;
} else {
break;
}
} else if (hf.block && block.number >= BigInt(hf.block)) {
hardfork = hf.name;
}
}

forkCommon = new Common({ chain: this.chainId, hardfork });
} else {
// we don't know about this chain or hardfork, so just carry on per usual,
Expand Down
17 changes: 10 additions & 7 deletions src/chains/ethereum/transaction/src/transaction-serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ export function serializeRpcForDb(
return serializeForDb(txData, blockHash, blockNumber, transactionIndex);
}

type SerializableTransaction = {
raw: TypedRawTransaction;
from: Address;
hash: Data;
effectiveGasPrice: Quantity;
type: Quantity;
};

export function serializeForDb(
tx: {
raw: TypedRawTransaction;
from: Address;
hash: Data;
effectiveGasPrice: Quantity;
type: Quantity;
},
tx: SerializableTransaction,
blockHash: Data,
blockNumber: Quantity,
transactionIndex: Quantity
Expand All @@ -61,6 +63,7 @@ export function serializeForDb(
tx.effectiveGasPrice.toBuffer()
]
];

return encode(txAndExtraData);
}

Expand Down

0 comments on commit 8093a75

Please sign in to comment.