Skip to content

Instantly share code, notes, and snippets.

@naterush
Created December 6, 2017 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naterush/c7252c762a3b26c923d44c2017602e3d to your computer and use it in GitHub Desktop.
Save naterush/c7252c762a3b26c923d44c2017602e3d to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.11;
contract Parsing {
using RLP for RLP.RLPItem;
using RLP for RLP.Iterator;
using RLP for bytes;
struct BlockHeader {
bytes32 parentHash;
bytes32 ommersHash;
address beneficiary;
bytes32 stateRoot;
bytes32 transactionsRoot;
bytes32 receiptsRoot;
//bytes32 logsBloom;
uint difficulty;
uint number;
uint gasLimit;
uint gasUsed;
uint timestamp;
}
struct Transaction {
}
struct Receipt {
}
function parseBlockHeader(bytes rlpHeader) constant internal returns (BlockHeader) {
var it = rlpHeader.toRLPItem().iterator();
BlockHeader memory header;
header.parentHash = it.next().toUint();
header.ommersHash = bytes32(it.next().toUint());
header.beneficiary = //
header.stateRoot = bytes32(it.next().toUint());
header.transactionsRoot = bytes32(it.next().toUint());
header.receiptsRoot = bytes32(it.next().toUint());
it.next() // bytes32 logsBloom;
header.difficulty = it.next().toUint();
header.number = it.next().toUint();
header.gasLimit = it.next().toUint();
header.gasUsed it.next().toUint();
header.timestamp = it.next().toUint();
return header;
}
function parseTransaction(bytes rlpTransaction) constant internal returns (Transaction) {
}
function parseReceipt(bytes rlpReceipt) constant internal returns (Receipt) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment