aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-09-30 00:36:16 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-10-19 15:03:09 +0800
commit42c8afd44006b170c20159abaadc31cc7545bec2 (patch)
tree49f150caef8b09d1584dc9635382b3938fee45e1 /core/vm
parentb99fe27f8b4d37fe3838d52b682e99c85098ee59 (diff)
downloaddexon-42c8afd44006b170c20159abaadc31cc7545bec2.tar
dexon-42c8afd44006b170c20159abaadc31cc7545bec2.tar.gz
dexon-42c8afd44006b170c20159abaadc31cc7545bec2.tar.bz2
dexon-42c8afd44006b170c20159abaadc31cc7545bec2.tar.lz
dexon-42c8afd44006b170c20159abaadc31cc7545bec2.tar.xz
dexon-42c8afd44006b170c20159abaadc31cc7545bec2.tar.zst
dexon-42c8afd44006b170c20159abaadc31cc7545bec2.zip
core: differentiate receipt concensus and storage decoding
Diffstat (limited to 'core/vm')
-rw-r--r--core/vm/log.go37
1 files changed, 20 insertions, 17 deletions
diff --git a/core/vm/log.go b/core/vm/log.go
index 354f0ad35..822476f85 100644
--- a/core/vm/log.go
+++ b/core/vm/log.go
@@ -40,27 +40,30 @@ func NewLog(address common.Address, topics []common.Hash, data []byte, number ui
return &Log{Address: address, Topics: topics, Data: data, Number: number}
}
-func (self *Log) EncodeRLP(w io.Writer) error {
- return rlp.Encode(w, []interface{}{self.Address, self.Topics, self.Data})
+func (l *Log) EncodeRLP(w io.Writer) error {
+ return rlp.Encode(w, []interface{}{l.Address, l.Topics, l.Data})
}
-func (self *Log) String() string {
- return fmt.Sprintf(`log: %x %x %x %x %d %x %d`, self.Address, self.Topics, self.Data, self.TxHash, self.TxIndex, self.BlockHash, self.Index)
+func (l *Log) DecodeRLP(s *rlp.Stream) error {
+ var log struct {
+ Address common.Address
+ Topics []common.Hash
+ Data []byte
+ }
+ if err := s.Decode(&log); err != nil {
+ return err
+ }
+ l.Address, l.Topics, l.Data = log.Address, log.Topics, log.Data
+ return nil
+}
+
+func (l *Log) String() string {
+ return fmt.Sprintf(`log: %x %x %x %x %d %x %d`, l.Address, l.Topics, l.Data, l.TxHash, l.TxIndex, l.BlockHash, l.Index)
}
type Logs []*Log
+// LogForStorage is a wrapper around a Log that flattens and parses the entire
+// content of a log, opposed to only the consensus fields originally (by hiding
+// the rlp interface methods).
type LogForStorage Log
-
-func (self *LogForStorage) EncodeRLP(w io.Writer) error {
- return rlp.Encode(w, []interface{}{
- self.Address,
- self.Topics,
- self.Data,
- self.Number,
- self.TxHash,
- self.TxIndex,
- self.BlockHash,
- self.Index,
- })
-}