b0VIM 7.4U&zGnulldomus~null/code/ethereumjs-block/index.jsutf-8 3210#"! Utpcad&pZB#poV=  q p c V > =    t E  d c L  x \ Z Y U ! { f !  wba6F6! H@7540aA P:S async.parallel( async.parallel([ var self = thisBlock.prototype.validate = function(blockChain, cb) { */ * @param {Function} cb the callback which is given a `String` if the block is not valid * @param {BlockChain} blockChain the blockchain that this block wants to be part of * @method validate * Validates the block/**} return validTxs }) validTxs &= tx.validate() this.transactions.forEach(function(tx) { var validTxs = trueBlock.prototype.validateTransactions = function() { */ * @return {Boolean} * @method validateTransactions * Validates the transactions/**} return txT === ethUtil.SHA3_RLP else return txT === this.txTrie.root.toString('hex') if (this.transactions.length) var txT = this.header.transactionsTrie.toString('hex')Block.prototype.validateTransactionsTrie = function() { */ * @return {Boolean} * @method validateTransactionTrie * Validates the transaction trie/**} }, cb) i++ self.txTrie.put(rlp.encode(i), tx.serialize(), done) async.eachSeries(this.transactions, function(tx, done) { self = this var i = 0,Block.prototype.genTxTrie = function(cb) { */ * @param {Function} cb * @method genTxTrie * be validated * Generate transaction trie. The tx trie must be generated before the block can/**} return rlpEncode ? rlp.encode(raw) : raw }) raw[2].push(uncle.raw) this.uncleHeaders.forEach(function(uncle) { }) raw[1].push(tx.raw) this.transactions.forEach(function(tx) { rlpEncode = true if (typeof rlpEncode === 'undefined') //rlpEnode defaults to true ] [] var raw = [this.header.raw, [],Block.prototype.serialize = function(rlpEncode) { */ * @param {Boolean} rlpEncode whether to rlp encode the block or not * @method serialize * Produces a serialization of the block./**} return this.header.isGenesis()Block.prototype.isGenesis = function(){ */ * @return Boolean * @method isGenisis * Determines if a given block is the genesis block/**} return this.header.hash()Block.prototype.hash = function() { */ * @method hash * Produces a hash the RLP of the block/**}; } this.transactions.push(new Tx(rawTransactions[i])) for (i = 0; i < rawTransactions.length; i++) { //parse transactions this.uncleHeaders.push(new BlockHeader(rawUncleHeaders[i])) for (var i = 0; i < rawUncleHeaders.length; i++) //parse uncle headers } rawUncleHeaders = data.uncleHeaders rawTransactions = data.transactions this.header = new BlockHeader(data.header) } else { rawUncleHeaders = data[2] rawTransactions = data[1] this.header = new BlockHeader(data[0]) if (Array.isArray(data)) { data = rlp.decode(data) if (Buffer.isBuffer(data)) data = [[], [], []] if (!data) //defaults var rawTransactions, rawUncleHeaders }) } return this.serialize(false) get: function() { Object.defineProperty(this, 'raw', { this.txTrie = new Trie() this._inBlockChain = false this.uncleHeaders = [] this.transactions = []var Block = module.exports = function(data) { */ * @param {Array} data raw data, deserialized * @constructor * Represents a block/**const BlockHeader = require('./header')const async = require('async')const rlp = ethUtil.rlpconst BN = ethUtil.BNconst Trie = require('merkle-patricia-tree')const Tx = require('ethereumjs-tx')const ethUtil = require('ethereumjs-util')require('es6-shim')ad/cmI+fe@  U < 7 6  r b a O N +   [ 9 8  D . ^ K 9 - "      `O?}|O&} } return ethUtil.baToJSON(this.raw) } else { return obj }) obj.uncleHeaders.push(uh.toJSON()) this.uncleHeaders.forEach(function(uh) { }) obj.transactions.push(tx.toJSON(labeled)) this.transactions.forEach(function(tx) { } uncleHeaders: [] transactions: [], header: this.header.toJSON(true), var obj = { if (labeled) {Block.prototype.toJSON = function(labeled) { */ * @param {Bool} array whether to create a object or an array * @method toJSON * Converts the block toJSON/**} }, cb) ], cb2) } }) } cb3() } else { cb3(err || 'uncle already included') if (blockInfo && blockInfo.isUncle) { //TODO: remove uncles from BC blockChain.getDetails(uncle.hash(), function(err, blockInfo) { function(cb3) { //check to make sure the uncle is not already in the blockchain uncle.validate.bind(uncle, blockChain, height), async.parallel([ var height = new BN(self.header.number) async.each(self.uncleHeaders, function(uncle, cb2) { return cb('dublicate unlces') if(!((new Set(uncleHashes)).size === uncleHashes.length)) }) return header.hash().toString('hex') var uncleHashes = self.uncleHeaders.map(function(header){ return cb('too many uncle headers') if(self.uncleHeaders.length > 2) var self = this return cb() if(this.isGenesis())Block.prototype.validateUncles = function(blockChain, cb) {} return ethUtil.sha3(raw).toString('hex') === this.header.uncleHash.toString('hex') raw = rlp.encode(raw) }) raw.push(uncle.raw) this.uncleHeaders.forEach(function(uncle) { var raw = []Block.prototype.validateUnclesHash = function(){} }) cb(err) self.parentBlock = self.header.parentBlock if(!err) } err = 'invild uncle hash' if(!self.validateUnclesHash()) err = 'invalid transaction' if(!self.validateTransactions()) err = 'invalid transaction true' if(!self.validateTransactionsTrie()) if(!err){ ], function(err) { self.genTxTrie.bind(self) //generate the transaction trie self.header.validate.bind(self.header, blockChain), //validate block self.validateUncles.bind(self, blockChain), //validate uncles