2014-08-11 07:23:17 -07:00
|
|
|
package ethstate
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"math/big"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Object manifest
|
|
|
|
//
|
|
|
|
// The object manifest is used to keep changes to the state so we can keep track of the changes
|
|
|
|
// that occurred during a state transitioning phase.
|
|
|
|
type Manifest struct {
|
2014-08-14 15:25:16 -07:00
|
|
|
Messages Messages
|
2014-08-11 07:23:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewManifest() *Manifest {
|
2014-08-15 07:19:10 -07:00
|
|
|
m := &Manifest{}
|
2014-08-11 07:23:17 -07:00
|
|
|
m.Reset()
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Manifest) Reset() {
|
2014-08-15 07:19:10 -07:00
|
|
|
m.Messages = nil
|
2014-08-11 07:23:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *Manifest) AddMessage(msg *Message) *Message {
|
|
|
|
self.Messages = append(self.Messages, msg)
|
|
|
|
|
|
|
|
return msg
|
|
|
|
}
|
|
|
|
|
2014-08-14 15:25:16 -07:00
|
|
|
type Messages []*Message
|
2014-08-11 07:23:17 -07:00
|
|
|
type Message struct {
|
|
|
|
To, From []byte
|
|
|
|
Input []byte
|
|
|
|
Output []byte
|
|
|
|
Path int
|
|
|
|
Origin []byte
|
|
|
|
Timestamp int64
|
|
|
|
Coinbase []byte
|
|
|
|
Block []byte
|
|
|
|
Number *big.Int
|
2014-08-18 01:17:45 -07:00
|
|
|
Value *big.Int
|
2014-08-15 07:19:10 -07:00
|
|
|
|
|
|
|
ChangedAddresses [][]byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *Message) AddStorageChange(addr []byte) {
|
|
|
|
self.ChangedAddresses = append(self.ChangedAddresses, addr)
|
2014-08-11 07:23:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *Message) String() string {
|
2014-08-18 01:17:45 -07:00
|
|
|
return fmt.Sprintf("Message{to: %x from: %x input: %x output: %x origin: %x coinbase: %x block: %x number: %v timestamp: %d path: %d value: %v", self.To, self.From, self.Input, self.Output, self.Origin, self.Coinbase, self.Block, self.Number, self.Timestamp, self.Path, self.Value)
|
2014-08-11 07:23:17 -07:00
|
|
|
}
|