Attempt to catch up from unknown block

This commit is contained in:
obscuren
2014-09-25 16:57:49 +02:00
parent 2458697dad
commit 9ed8dc7384
3 changed files with 15 additions and 3 deletions

View File

@ -23,12 +23,13 @@ type JSBlock struct {
Name string `json:"name"`
GasLimit string `json:"gasLimit"`
GasUsed string `json:"gasUsed"`
PrevHash string `json:"prevHash"`
}
// Creates a new QML Block from a chain block
func NewJSBlock(block *ethchain.Block) *JSBlock {
if block == nil {
return nil
return &JSBlock{}
}
var ptxs []JSTransaction
@ -38,7 +39,14 @@ func NewJSBlock(block *ethchain.Block) *JSBlock {
list := ethutil.NewList(ptxs)
return &JSBlock{ref: block, Size: block.Size().String(), Number: int(block.Number.Uint64()), GasUsed: block.GasUsed.String(), GasLimit: block.GasLimit.String(), Hash: ethutil.Bytes2Hex(block.Hash()), Transactions: list, Time: block.Time, Coinbase: ethutil.Bytes2Hex(block.Coinbase)}
return &JSBlock{
ref: block, Size: block.Size().String(),
Number: int(block.Number.Uint64()), GasUsed: block.GasUsed.String(),
GasLimit: block.GasLimit.String(), Hash: ethutil.Bytes2Hex(block.Hash()),
Transactions: list, Time: block.Time,
Coinbase: ethutil.Bytes2Hex(block.Coinbase),
PrevHash: ethutil.Bytes2Hex(block.PrevHash),
}
}
func (self *JSBlock) ToString() string {