Added different storage notification object

poc8
obscuren 11 years ago
parent 1f6df0cd52
commit 7c91159449
  1. 2
      ethchain/state_manager.go
  2. 6
      ethchain/state_object.go
  3. 12
      ethpub/pub.go
  4. 36
      ethpub/types.go

@ -350,7 +350,7 @@ func (sm *StateManager) notifyChanges() {
for stateObjectAddr, mappedObjects := range sm.manifest.storageChanges {
for addr, value := range mappedObjects {
sm.Ethereum.Reactor().Post("storage:"+stateObjectAddr+":"+addr, value.String())
sm.Ethereum.Reactor().Post("storage:"+stateObjectAddr+":"+addr, &StorageState{[]byte(stateObjectAddr), []byte(addr), value})
}
}
}

@ -186,3 +186,9 @@ type CachedStateObject struct {
Nonce uint64
Object *StateObject
}
type StorageState struct {
StateAddress []byte
Address []byte
Value *big.Int
}

@ -47,6 +47,18 @@ func (lib *PEthereum) GetStateObject(address string) *PStateObject {
return NewPStateObject(nil)
}
func (lib *PEthereum) GetStorage(address, storageAddress string) string {
return lib.GetStateObject(address).GetStorage(storageAddress)
}
func (lib *PEthereum) GetTxCount(address string) int {
return lib.GetStateObject(address).Nonce()
}
func (lib *PEthereum) IsContract(address string) bool {
return lib.GetStateObject(address).IsContract()
}
func (lib *PEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) (*PReceipt, error) {
return lib.createTx(key, recipient, valueStr, gasStr, gasPriceStr, dataStr, "")
}

@ -59,16 +59,6 @@ func NewPReciept(contractCreation bool, creationAddress, hash, address []byte) *
}
}
/*
type PKeyRing struct {
Keys []interface{}
}
func NewPKeyRing(keys []interface{}) *PKeyRing {
return &PKeyRing{Keys: keys}
}
*/
type PStateObject struct {
object *ethchain.StateObject
}
@ -105,3 +95,29 @@ func (c *PStateObject) Address() string {
return ""
}
func (c *PStateObject) Nonce() int {
if c.object != nil {
return int(c.object.Nonce)
}
return 0
}
func (c *PStateObject) IsContract() bool {
if c.object != nil {
return len(c.object.Script()) > 0
}
return false
}
type PStorageState struct {
StateAddress string
Address string
Value string
}
func NewPStorageState(storageObject *ethchain.StorageState) *PStorageState {
return &PStorageState{ethutil.Hex(storageObject.StateAddress), ethutil.Hex(storageObject.Address), storageObject.Value.String()}
}

Loading…
Cancel
Save