8
8
"github.com/gogo/protobuf/proto"
9
9
apptypes "github.com/ovrclk/akash/app/types"
10
10
"github.com/ovrclk/akash/keys"
11
- "github.com/ovrclk/akash/state"
11
+ appstate "github.com/ovrclk/akash/state"
12
12
"github.com/ovrclk/akash/types"
13
13
"github.com/ovrclk/akash/types/code"
14
14
tmtypes "github.com/tendermint/abci/types"
@@ -23,23 +23,23 @@ type app struct {
23
23
* apptypes.BaseApp
24
24
}
25
25
26
- func NewApp (state state. State , logger log.Logger ) (apptypes.Application , error ) {
27
- return & app {apptypes .NewBaseApp (Name , state , logger )}, nil
26
+ func NewApp (logger log.Logger ) (apptypes.Application , error ) {
27
+ return & app {apptypes .NewBaseApp (Name , logger )}, nil
28
28
}
29
29
30
30
func (a * app ) AcceptQuery (req tmtypes.RequestQuery ) bool {
31
- return strings .HasPrefix (req .GetPath (), state .AccountPath )
31
+ return strings .HasPrefix (req .GetPath (), appstate .AccountPath )
32
32
}
33
33
34
- func (a * app ) Query (req tmtypes.RequestQuery ) tmtypes.ResponseQuery {
34
+ func (a * app ) Query (state appstate. State , req tmtypes.RequestQuery ) tmtypes.ResponseQuery {
35
35
36
36
if ! a .AcceptQuery (req ) {
37
37
return tmtypes.ResponseQuery {
38
38
Code : code .UNKNOWN_QUERY ,
39
39
Log : "invalid key" ,
40
40
}
41
41
}
42
- id := strings .TrimPrefix (req .Path , state .AccountPath )
42
+ id := strings .TrimPrefix (req .Path , appstate .AccountPath )
43
43
key , err := keys .ParseAccountPath (id )
44
44
if err != nil {
45
45
return tmtypes.ResponseQuery {
@@ -48,7 +48,7 @@ func (a *app) Query(req tmtypes.RequestQuery) tmtypes.ResponseQuery {
48
48
}
49
49
}
50
50
51
- acct , err := a . State () .Account ().Get (key .ID ())
51
+ acct , err := state .Account ().Get (key .ID ())
52
52
if err != nil {
53
53
return tmtypes.ResponseQuery {
54
54
Code : code .ERROR ,
@@ -73,7 +73,7 @@ func (a *app) Query(req tmtypes.RequestQuery) tmtypes.ResponseQuery {
73
73
74
74
return tmtypes.ResponseQuery {
75
75
Value : bytes ,
76
- Height : int64 ( a . State (). Version () ),
76
+ Height : state . Version (),
77
77
}
78
78
}
79
79
@@ -85,29 +85,29 @@ func (a *app) AcceptTx(ctx apptypes.Context, tx interface{}) bool {
85
85
return false
86
86
}
87
87
88
- func (a * app ) CheckTx (ctx apptypes.Context , tx interface {}) tmtypes.ResponseCheckTx {
88
+ func (a * app ) CheckTx (state appstate. State , ctx apptypes.Context , tx interface {}) tmtypes.ResponseCheckTx {
89
89
switch tx := tx .(type ) {
90
90
case * types.TxPayload_TxSend :
91
- return a .doCheckTx (ctx , tx .TxSend )
91
+ return a .doCheckTx (state , ctx , tx .TxSend )
92
92
}
93
93
return tmtypes.ResponseCheckTx {
94
94
Code : code .UNKNOWN_TRANSACTION ,
95
95
Log : "unknown transaction" ,
96
96
}
97
97
}
98
98
99
- func (a * app ) DeliverTx (ctx apptypes.Context , tx interface {}) tmtypes.ResponseDeliverTx {
99
+ func (a * app ) DeliverTx (state appstate. State , ctx apptypes.Context , tx interface {}) tmtypes.ResponseDeliverTx {
100
100
switch tx := tx .(type ) {
101
101
case * types.TxPayload_TxSend :
102
- return a .doDeliverTx (ctx , tx .TxSend )
102
+ return a .doDeliverTx (state , ctx , tx .TxSend )
103
103
}
104
104
return tmtypes.ResponseDeliverTx {
105
105
Code : code .UNKNOWN_TRANSACTION ,
106
106
Log : "unknown transaction" ,
107
107
}
108
108
}
109
109
110
- func (a * app ) doCheckTx (ctx apptypes.Context , tx * types.TxSend ) tmtypes.ResponseCheckTx {
110
+ func (a * app ) doCheckTx (state appstate. State , ctx apptypes.Context , tx * types.TxSend ) tmtypes.ResponseCheckTx {
111
111
112
112
if ! bytes .Equal (ctx .Signer ().Address (), tx .From ) {
113
113
return tmtypes.ResponseCheckTx {
@@ -123,7 +123,7 @@ func (a *app) doCheckTx(ctx apptypes.Context, tx *types.TxSend) tmtypes.Response
123
123
}
124
124
}
125
125
126
- acct , err := a . State () .Account ().Get (tx .From )
126
+ acct , err := state .Account ().Get (tx .From )
127
127
if err != nil {
128
128
return tmtypes.ResponseCheckTx {
129
129
Code : code .INVALID_TRANSACTION ,
@@ -147,17 +147,17 @@ func (a *app) doCheckTx(ctx apptypes.Context, tx *types.TxSend) tmtypes.Response
147
147
return tmtypes.ResponseCheckTx {}
148
148
}
149
149
150
- func (a * app ) doDeliverTx (ctx apptypes.Context , tx * types.TxSend ) tmtypes.ResponseDeliverTx {
150
+ func (a * app ) doDeliverTx (state appstate. State , ctx apptypes.Context , tx * types.TxSend ) tmtypes.ResponseDeliverTx {
151
151
152
- cresp := a .doCheckTx (ctx , tx )
152
+ cresp := a .doCheckTx (state , ctx , tx )
153
153
if ! cresp .IsOK () {
154
154
return tmtypes.ResponseDeliverTx {
155
155
Code : cresp .Code ,
156
156
Log : cresp .Log ,
157
157
}
158
158
}
159
159
160
- acct , err := a . State () .Account ().Get (tx .From )
160
+ acct , err := state .Account ().Get (tx .From )
161
161
if err != nil {
162
162
return tmtypes.ResponseDeliverTx {
163
163
Code : code .INVALID_TRANSACTION ,
@@ -171,7 +171,7 @@ func (a *app) doDeliverTx(ctx apptypes.Context, tx *types.TxSend) tmtypes.Respon
171
171
}
172
172
}
173
173
174
- toacct , err := a . State () .Account ().Get (tx .To )
174
+ toacct , err := state .Account ().Get (tx .To )
175
175
if err != nil {
176
176
return tmtypes.ResponseDeliverTx {
177
177
Code : code .INVALID_TRANSACTION ,
@@ -188,14 +188,14 @@ func (a *app) doDeliverTx(ctx apptypes.Context, tx *types.TxSend) tmtypes.Respon
188
188
acct .Balance -= tx .Amount
189
189
toacct .Balance += tx .Amount
190
190
191
- if err := a . State () .Account ().Save (acct ); err != nil {
191
+ if err := state .Account ().Save (acct ); err != nil {
192
192
return tmtypes.ResponseDeliverTx {
193
193
Code : code .INVALID_TRANSACTION ,
194
194
Log : err .Error (),
195
195
}
196
196
}
197
197
198
- if err := a . State () .Account ().Save (toacct ); err != nil {
198
+ if err := state .Account ().Save (toacct ); err != nil {
199
199
return tmtypes.ResponseDeliverTx {
200
200
Code : code .INVALID_TRANSACTION ,
201
201
Log : err .Error (),
0 commit comments