func (self *worker) commitUncle(work *Work, uncle *types.Header) error { hash := uncle.Hash() if work.uncles.Has(hash) { return core.UncleError("Uncle not unique") } if !work.ancestors.Has(uncle.ParentHash) { return core.UncleError(fmt.Sprintf("Uncle's parent unknown (%x)", uncle.ParentHash[0:4])) } if work.family.Has(hash) { return core.UncleError(fmt.Sprintf("Uncle already in family (%x)", hash)) } work.uncles.Add(uncle.Hash()) return nil }
func NewUncleRes(h *types.Header) *UncleRes { if h == nil { return nil } var v = new(UncleRes) v.BlockNumber = newHexNum(h.Number) v.BlockHash = newHexData(h.Hash()) v.ParentHash = newHexData(h.ParentHash) v.Sha3Uncles = newHexData(h.UncleHash) v.Nonce = newHexData(h.Nonce[:]) v.LogsBloom = newHexData(h.Bloom) v.TransactionRoot = newHexData(h.TxHash) v.StateRoot = newHexData(h.Root) v.Miner = newHexData(h.Coinbase) v.Difficulty = newHexNum(h.Difficulty) v.ExtraData = newHexData(h.Extra) v.GasLimit = newHexNum(h.GasLimit) v.GasUsed = newHexNum(h.GasUsed) v.UnixTimestamp = newHexNum(h.Time) v.ReceiptHash = newHexData(h.ReceiptHash) return v }