diff options
author | obscuren <geffobscura@gmail.com> | 2015-05-23 04:44:51 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-05-28 07:00:23 +0800 |
commit | e3253b5d5e65bfb6944ddaabd3c79400fbe06ef8 (patch) | |
tree | 1704eb7e374cd810450f604233cad96461a76755 /core/types | |
parent | 27e0d2a97325edc9a870a747412d0b9a2abd1ed1 (diff) | |
download | go-tangerine-e3253b5d5e65bfb6944ddaabd3c79400fbe06ef8.tar go-tangerine-e3253b5d5e65bfb6944ddaabd3c79400fbe06ef8.tar.gz go-tangerine-e3253b5d5e65bfb6944ddaabd3c79400fbe06ef8.tar.bz2 go-tangerine-e3253b5d5e65bfb6944ddaabd3c79400fbe06ef8.tar.lz go-tangerine-e3253b5d5e65bfb6944ddaabd3c79400fbe06ef8.tar.xz go-tangerine-e3253b5d5e65bfb6944ddaabd3c79400fbe06ef8.tar.zst go-tangerine-e3253b5d5e65bfb6944ddaabd3c79400fbe06ef8.zip |
core: fixed an issue with storing receipts
Diffstat (limited to 'core/types')
-rw-r--r-- | core/types/receipt.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/types/receipt.go b/core/types/receipt.go index 414e4d364..6b4024ada 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -26,10 +26,39 @@ func (self *Receipt) SetLogs(logs state.Logs) { self.logs = logs } +func (self *Receipt) Logs() state.Logs { + return self.logs +} + func (self *Receipt) EncodeRLP(w io.Writer) error { return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs}) } +func (self *Receipt) DecodeRLP(s *rlp.Stream) error { + var r struct { + PostState []byte + CumulativeGasUsed *big.Int + Bloom Bloom + Logs state.Logs + } + if err := s.Decode(&r); err != nil { + return err + } + self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs = r.PostState, r.CumulativeGasUsed, r.Bloom, r.Logs + + return nil +} + +type ReceiptForStorage Receipt + +func (self *ReceiptForStorage) EncodeRLP(w io.Writer) error { + storageLogs := make([]*state.LogForStorage, len(self.logs)) + for i, log := range self.logs { + storageLogs[i] = (*state.LogForStorage)(log) + } + return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, storageLogs}) +} + func (self *Receipt) RlpEncode() []byte { bytes, err := rlp.EncodeToBytes(self) if err != nil { |