From 342cc122b43f01301d0188de1e333c32ed64ae8c Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 4 Aug 2014 16:25:53 +0200 Subject: Added general Pipe API --- ethpipe/world.go | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 ethpipe/world.go (limited to 'ethpipe/world.go') diff --git a/ethpipe/world.go b/ethpipe/world.go new file mode 100644 index 000000000..507391521 --- /dev/null +++ b/ethpipe/world.go @@ -0,0 +1,60 @@ +package ethpipe + +import ( + "container/list" + + "github.com/ethereum/eth-go/ethstate" +) + +type world struct { + pipe *Pipe + cfg *config +} + +func NewWorld(pipe *Pipe) *world { + world := &world{pipe, nil} + world.cfg = &config{pipe} + + return world +} + +func (self *Pipe) World() *world { + return self.world +} + +func (self *world) State() *ethstate.State { + return self.pipe.stateManager.CurrentState() +} + +func (self *world) Get(addr []byte) *ethstate.StateObject { + return self.State().GetStateObject(addr) +} + +func (self *world) safeGet(addr []byte) *ethstate.StateObject { + object := self.Get(addr) + if object != nil { + return object + } + + return ethstate.NewStateObject(addr) +} + +func (self *world) Coinbase() *ethstate.StateObject { + return nil +} + +func (self *world) IsMining() bool { + return self.pipe.obj.IsMining() +} + +func (self *world) IsListening() bool { + return self.pipe.obj.IsListening() +} + +func (self *world) Peers() *list.List { + return self.obj.Peers() +} + +func (self *world) Config() *config { + return self.cfg +} -- cgit From c215bbadf13ec70e4d1b65e67d4ff4568d644542 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 5 Aug 2014 10:17:26 +0200 Subject: pipe --- ethpipe/world.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ethpipe/world.go') diff --git a/ethpipe/world.go b/ethpipe/world.go index 507391521..42e19fe00 100644 --- a/ethpipe/world.go +++ b/ethpipe/world.go @@ -52,7 +52,7 @@ func (self *world) IsListening() bool { } func (self *world) Peers() *list.List { - return self.obj.Peers() + return self.pipe.obj.Peers() } func (self *world) Config() *config { -- cgit From 4f0bda403ea332eeb477f8e56457423628772b19 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 5 Aug 2014 11:10:24 +0200 Subject: Added vm options for object execution --- ethpipe/world.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ethpipe/world.go') diff --git a/ethpipe/world.go b/ethpipe/world.go index 42e19fe00..25e2a1952 100644 --- a/ethpipe/world.go +++ b/ethpipe/world.go @@ -26,17 +26,17 @@ func (self *world) State() *ethstate.State { return self.pipe.stateManager.CurrentState() } -func (self *world) Get(addr []byte) *ethstate.StateObject { - return self.State().GetStateObject(addr) +func (self *world) Get(addr []byte) *object { + return &object{self.State().GetStateObject(addr)} } func (self *world) safeGet(addr []byte) *ethstate.StateObject { - object := self.Get(addr) - if object != nil { - return object + object := self.State().GetStateObject(addr) + if object == nil { + object = ethstate.NewStateObject(addr) } - return ethstate.NewStateObject(addr) + return object } func (self *world) Coinbase() *ethstate.StateObject { -- cgit From e71b198e3d8df1bd8b73bae9bc934b778a3115bf Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 5 Aug 2014 11:26:12 +0200 Subject: Renamed object to Object --- ethpipe/world.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ethpipe/world.go') diff --git a/ethpipe/world.go b/ethpipe/world.go index 25e2a1952..2a07f340c 100644 --- a/ethpipe/world.go +++ b/ethpipe/world.go @@ -26,8 +26,8 @@ func (self *world) State() *ethstate.State { return self.pipe.stateManager.CurrentState() } -func (self *world) Get(addr []byte) *object { - return &object{self.State().GetStateObject(addr)} +func (self *world) Get(addr []byte) *Object { + return &Object{self.State().GetStateObject(addr)} } func (self *world) safeGet(addr []byte) *ethstate.StateObject { -- cgit From 3c78e418fbe70cfb574302f00962cf7fac50f69e Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 5 Aug 2014 11:30:12 +0200 Subject: world => World --- ethpipe/world.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'ethpipe/world.go') diff --git a/ethpipe/world.go b/ethpipe/world.go index 2a07f340c..2c6b0b4b9 100644 --- a/ethpipe/world.go +++ b/ethpipe/world.go @@ -6,31 +6,31 @@ import ( "github.com/ethereum/eth-go/ethstate" ) -type world struct { +type World struct { pipe *Pipe cfg *config } -func NewWorld(pipe *Pipe) *world { - world := &world{pipe, nil} +func NewWorld(pipe *Pipe) *World { + world := &World{pipe, nil} world.cfg = &config{pipe} return world } -func (self *Pipe) World() *world { +func (self *Pipe) World() *World { return self.world } -func (self *world) State() *ethstate.State { +func (self *World) State() *ethstate.State { return self.pipe.stateManager.CurrentState() } -func (self *world) Get(addr []byte) *Object { +func (self *World) Get(addr []byte) *Object { return &Object{self.State().GetStateObject(addr)} } -func (self *world) safeGet(addr []byte) *ethstate.StateObject { +func (self *World) safeGet(addr []byte) *ethstate.StateObject { object := self.State().GetStateObject(addr) if object == nil { object = ethstate.NewStateObject(addr) @@ -39,22 +39,22 @@ func (self *world) safeGet(addr []byte) *ethstate.StateObject { return object } -func (self *world) Coinbase() *ethstate.StateObject { +func (self *World) Coinbase() *ethstate.StateObject { return nil } -func (self *world) IsMining() bool { +func (self *World) IsMining() bool { return self.pipe.obj.IsMining() } -func (self *world) IsListening() bool { +func (self *World) IsListening() bool { return self.pipe.obj.IsListening() } -func (self *world) Peers() *list.List { +func (self *World) Peers() *list.List { return self.pipe.obj.Peers() } -func (self *world) Config() *config { +func (self *World) Config() *config { return self.cfg } -- cgit From 4edf7cfb0543555921a79f572c749615c4997ea7 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 5 Aug 2014 11:31:39 +0200 Subject: config => Config --- ethpipe/world.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ethpipe/world.go') diff --git a/ethpipe/world.go b/ethpipe/world.go index 2c6b0b4b9..72e116d09 100644 --- a/ethpipe/world.go +++ b/ethpipe/world.go @@ -8,12 +8,12 @@ import ( type World struct { pipe *Pipe - cfg *config + cfg *Config } func NewWorld(pipe *Pipe) *World { world := &World{pipe, nil} - world.cfg = &config{pipe} + world.cfg = &Config{pipe} return world } @@ -55,6 +55,6 @@ func (self *World) Peers() *list.List { return self.pipe.obj.Peers() } -func (self *World) Config() *config { +func (self *World) Config() *Config { return self.cfg } -- cgit From d701b232304149f5e9035213d1710ab71cc4a01d Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 15 Aug 2014 13:05:13 +0200 Subject: Reworking the public js interface (pub) => (pipe) --- ethpipe/world.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ethpipe/world.go') diff --git a/ethpipe/world.go b/ethpipe/world.go index 72e116d09..4666362f9 100644 --- a/ethpipe/world.go +++ b/ethpipe/world.go @@ -30,6 +30,10 @@ func (self *World) Get(addr []byte) *Object { return &Object{self.State().GetStateObject(addr)} } +func (self *World) SafeGet(addr []byte) *Object { + return &Object{self.safeGet(addr)} +} + func (self *World) safeGet(addr []byte) *ethstate.StateObject { object := self.State().GetStateObject(addr) if object == nil { -- cgit