Fixed Public block creation. Added block logging

This commit is contained in:
obscuren
2014-05-21 12:09:28 +02:00
parent 07fe00c466
commit 05e4e97276
2 changed files with 14 additions and 13 deletions

View File

@ -8,16 +8,26 @@ import (
// Block interface exposed to QML
type PBlock struct {
ref *ethchain.Block
Number int `json:"number"`
Hash string `json:"hash"`
}
// Creates a new QML Block from a chain block
func NewPBlock(block *ethchain.Block) *PBlock {
info := block.BlockInfo()
hash := hex.EncodeToString(block.Hash())
if block == nil {
return nil
}
return &PBlock{Number: int(info.Number), Hash: hash}
return &PBlock{ref: block, Number: int(block.Number.Uint64()), Hash: ethutil.Hex(block.Hash())}
}
func (self *PBlock) ToString() string {
if self.ref != nil {
return self.ref.String()
}
return ""
}
type PTx struct {