-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added find method for Block and fixed the style for others
- Loading branch information
1 parent
cf942f8
commit fce6b6b
Showing
3 changed files
with
143 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,113 @@ | ||
function rawBlockToEntity (data) { | ||
function rawBlockToEntity ({ | ||
number, | ||
hash, | ||
miner, | ||
parentHash, | ||
sha3Uncles, | ||
logsBloom, | ||
transactionsRoot, | ||
stateRoot, | ||
receiptsRoot, | ||
difficulty, | ||
totalDifficulty, | ||
extraData, | ||
size, | ||
gasLimit, | ||
gasUsed, | ||
timestamp, | ||
minimumGasPrice, | ||
bitcoinMergedMiningHeader, | ||
bitcoinMergedMiningCoinbaseTransaction, | ||
bitcoinMergedMiningMerkleProof, | ||
hashForMergedMining, | ||
paidFees, | ||
cumulativeDifficulty, | ||
received | ||
}) { | ||
return { | ||
number: data.number, | ||
hash: data.hash, | ||
miner: data.miner, | ||
parentHash: data.parentHash, | ||
sha3Uncles: data.sha3Uncles, | ||
logsBloom: data.logsBloom, | ||
transactionsRoot: data.transactionsRoot, | ||
stateRoot: data.stateRoot, | ||
receiptsRoot: data.receiptsRoot, | ||
difficulty: data.difficulty, | ||
totalDifficulty: data.totalDifficulty, | ||
extraData: data.extraData, | ||
size: data.size, | ||
gasLimit: data.gasLimit, | ||
gasUsed: data.gasUsed, | ||
timestamp: String(data.timestamp), | ||
minimumGasPrice: data.minimumGasPrice, | ||
bitcoinMergedMiningHeader: data.bitcoinMergedMiningHeader, | ||
bitcoinMergedMiningCoinbaseTransaction: data.bitcoinMergedMiningCoinbaseTransaction, | ||
bitcoinMergedMiningMerkleProof: data.bitcoinMergedMiningMerkleProof, | ||
hashForMergedMining: data.hashForMergedMining, | ||
paidFees: data.paidFees, | ||
cumulativeDifficulty: data.cumulativeDifficulty, | ||
received: String(data._received) | ||
number, | ||
hash, | ||
miner, | ||
parentHash, | ||
sha3Uncles, | ||
logsBloom, | ||
transactionsRoot, | ||
stateRoot, | ||
receiptsRoot, | ||
difficulty, | ||
totalDifficulty, | ||
extraData, | ||
size, | ||
gasLimit, | ||
gasUsed, | ||
timestamp: String(timestamp), | ||
minimumGasPrice, | ||
bitcoinMergedMiningHeader, | ||
bitcoinMergedMiningCoinbaseTransaction, | ||
bitcoinMergedMiningMerkleProof, | ||
hashForMergedMining, | ||
paidFees, | ||
cumulativeDifficulty, | ||
received: String(received) | ||
} | ||
} | ||
|
||
function blockEntityToRaw (blockEntity) { | ||
blockEntity['_received'] = Number(blockEntity.received) | ||
delete blockEntity['received'] | ||
|
||
blockEntity['timestamp'] = Number(blockEntity['timestamp']) | ||
|
||
blockEntity.uncles = blockEntity.uncle.map(uncleObj => uncleObj.hash) | ||
delete blockEntity['uncle'] | ||
|
||
return blockEntity | ||
function blockEntityToRaw ({ | ||
number, | ||
hash, | ||
miner, | ||
parentHash, | ||
sha3Uncles, | ||
logsBloom, | ||
transactionsRoot, | ||
stateRoot, | ||
receiptsRoot, | ||
difficulty, | ||
totalDifficulty, | ||
extraData, | ||
size, | ||
gasLimit, | ||
gasUsed, | ||
timestamp, | ||
minimumGasPrice, | ||
bitcoinMergedMiningHeader, | ||
bitcoinMergedMiningCoinbaseTransaction, | ||
bitcoinMergedMiningMerkleProof, | ||
hashForMergedMining, | ||
paidFees, | ||
cumulativeDifficulty, | ||
received, | ||
uncle, | ||
transaction_transaction_block_numberToblock: transactions | ||
}) { | ||
return { | ||
number, | ||
hash, | ||
miner, | ||
parentHash, | ||
sha3Uncles, | ||
logsBloom, | ||
transactionsRoot, | ||
stateRoot, | ||
receiptsRoot, | ||
difficulty, | ||
totalDifficulty, | ||
extraData, | ||
size, | ||
gasLimit, | ||
gasUsed, | ||
timestamp: Number(timestamp), | ||
minimumGasPrice, | ||
bitcoinMergedMiningHeader, | ||
bitcoinMergedMiningCoinbaseTransaction, | ||
bitcoinMergedMiningMerkleProof, | ||
hashForMergedMining, | ||
paidFees, | ||
cumulativeDifficulty, | ||
_received: Number(received), | ||
uncles: uncle.map(({hash}) => hash), | ||
transactions: transactions.map(({hash}) => hash) | ||
} | ||
} | ||
|
||
export {rawBlockToEntity, blockEntityToRaw} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters