diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-22 02:44:22 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-22 02:44:22 +0800 |
commit | 0467a6ceec4973b00c344d2a724f7fb01a6b0aee (patch) | |
tree | 66e010270bdf25fa0058c89fb31f6df8cf7f7829 /core/vm | |
parent | dba15d9c3609bcddfc7a4f0fe8f01c48a8bbfbc8 (diff) | |
parent | 5b0ee8ec304663898073b7a4c659e1def23716df (diff) | |
download | go-tangerine-0467a6ceec4973b00c344d2a724f7fb01a6b0aee.tar go-tangerine-0467a6ceec4973b00c344d2a724f7fb01a6b0aee.tar.gz go-tangerine-0467a6ceec4973b00c344d2a724f7fb01a6b0aee.tar.bz2 go-tangerine-0467a6ceec4973b00c344d2a724f7fb01a6b0aee.tar.lz go-tangerine-0467a6ceec4973b00c344d2a724f7fb01a6b0aee.tar.xz go-tangerine-0467a6ceec4973b00c344d2a724f7fb01a6b0aee.tar.zst go-tangerine-0467a6ceec4973b00c344d2a724f7fb01a6b0aee.zip |
Merge pull request #1889 from karalabe/fast-sync-rebase
eth/63 fast synchronization algorithm
Diffstat (limited to 'core/vm')
-rw-r--r-- | core/vm/log.go | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/core/vm/log.go b/core/vm/log.go index 354f0ad35..191e3a253 100644 --- a/core/vm/log.go +++ b/core/vm/log.go @@ -25,42 +25,47 @@ import ( ) type Log struct { + // Consensus fields Address common.Address Topics []common.Hash Data []byte - Number uint64 - TxHash common.Hash - TxIndex uint - BlockHash common.Hash - Index uint + // Derived fields (don't reorder!) + BlockNumber uint64 + TxHash common.Hash + TxIndex uint + BlockHash common.Hash + Index uint } func NewLog(address common.Address, topics []common.Hash, data []byte, number uint64) *Log { - return &Log{Address: address, Topics: topics, Data: data, Number: number} + return &Log{Address: address, Topics: topics, Data: data, BlockNumber: 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, as 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, - }) -} |