more app1 cleanup

This commit is contained in:
Ethan Buchman 2018-06-27 08:11:11 -04:00
parent 6a5a8b4721
commit 0987787896
1 changed files with 31 additions and 32 deletions

View File

@ -378,7 +378,12 @@ The `Tx` just wraps a `[]Msg`, and may include additional authentication data, l
Applications must specify how their `Tx` is decoded, as this is the ultimate input into the application. Applications must specify how their `Tx` is decoded, as this is the ultimate input into the application.
We'll talk more about `Tx` types later, specifically when we introduce the `StdTx`. We'll talk more about `Tx` types later, specifically when we introduce the `StdTx`.
For this example, we have a dead-simple `Tx` type that contains the `MsgSend` and is JSON decoded: In this first application, we won't have any authentication at all. This might
make sense in a private network where access is controlled by alternative means,
like client-side TLS certificates, but in general, we'll want to bake the authentication
right into our state machine. We'll use `Tx` to do that
in the next app. For now, the `Tx` just embeds `MsgSend` and uses JSON:
```go ```go
// Simple tx to wrap the Msg. // Simple tx to wrap the Msg.
@ -402,8 +407,6 @@ func txDecoder(txBytes []byte) (sdk.Tx, sdk.Error) {
} }
``` ```
Thus, transactions in this blockchain are expected to be JSON encoded `MsgSend`.
# BaseApp # BaseApp
Finally, we stitch it all together using the `BaseApp`. Finally, we stitch it all together using the `BaseApp`.
@ -420,7 +423,6 @@ Here is the complete setup for App1:
```go ```go
func NewApp1(logger log.Logger, db dbm.DB) *bapp.BaseApp { func NewApp1(logger log.Logger, db dbm.DB) *bapp.BaseApp {
// TODO: make this an interface or pass in // TODO: make this an interface or pass in
// a TxDecoder instead. // a TxDecoder instead.
cdc := wire.NewCodec() cdc := wire.NewCodec()
@ -468,6 +470,3 @@ We now have a complete implementation of a simple app!
In the next section, we'll add another Msg type and another store. Once we have multiple message types In the next section, we'll add another Msg type and another store. Once we have multiple message types
we'll need a better way of decoding transactions, since we'll need to decode we'll need a better way of decoding transactions, since we'll need to decode
into the `Msg` interface. This is where we introduce Amino, a superior encoding scheme that lets us decode into interface types! into the `Msg` interface. This is where we introduce Amino, a superior encoding scheme that lets us decode into interface types!