Start on coin handler

This commit is contained in:
Ethan Frey
2017-06-30 18:37:51 +02:00
parent a0f1e5e66a
commit 37796002ae
4 changed files with 96 additions and 3 deletions
+17 -3
View File
@@ -1,9 +1,13 @@
package stack
import (
"strings"
"github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/txs"
"github.com/tendermint/basecoin/types"
wire "github.com/tendermint/go-wire"
"github.com/tendermint/go-wire/data"
)
const (
@@ -45,7 +49,17 @@ func runAll(ctx basecoin.Context, store types.KVStore, txs []basecoin.Tx, next b
return combine(rs), nil
}
func combine(res []basecoin.Result) basecoin.Result {
// TODO: how to combine???
return res[0]
// combines all data bytes as a go-wire array.
// joins all log messages with \n
func combine(all []basecoin.Result) basecoin.Result {
datas := make([]data.Bytes, len(all))
logs := make([]string, len(all))
for i, r := range all {
datas[i] = r.Data
logs[i] = r.Log
}
return basecoin.Result{
Data: wire.BinaryBytes(datas),
Log: strings.Join(logs, "\n"),
}
}