diff --git a/packages/go-kosu/abci/order.go b/packages/go-kosu/abci/order.go index 3dc2b5a2..719c85de 100644 --- a/packages/go-kosu/abci/order.go +++ b/packages/go-kosu/abci/order.go @@ -70,7 +70,7 @@ func (app *App) deliverOrderTx(tx *types.TransactionOrder) abci.ResponseDeliverT return abci.ResponseDeliverTx{ Code: 0, Events: []abci.Event{ - {Type: "tags", Attributes: NewTagsFromOrderInfo(orderID, posterAddress, poster.Limit)}, + {Type: "tags", Attributes: NewKVPairFromOrderInfo(orderID, posterAddress, poster.Limit)}, }, } } diff --git a/packages/go-kosu/abci/tags.go b/packages/go-kosu/abci/tags.go index a718622c..c7383668 100644 --- a/packages/go-kosu/abci/tags.go +++ b/packages/go-kosu/abci/tags.go @@ -19,8 +19,8 @@ func NewTagsFromRoundInfo(info *types.RoundInfo) []common.KVPair { } } -// NewRoundInfoFromTags parses a set of tags and returns a state.RoundInfo -func NewRoundInfoFromTags(tags map[string]string) (*types.RoundInfo, error) { +// NewRoundInfoFromEvents parses a set of tags and returns a state.RoundInfo +func NewRoundInfoFromEvents(events map[string][]string) (*types.RoundInfo, error) { var info types.RoundInfo var err error @@ -28,13 +28,18 @@ func NewRoundInfoFromTags(tags map[string]string) (*types.RoundInfo, error) { tag string val *uint64 }{ - {"round.number", &info.Number}, - {"round.start", &info.StartsAt}, - {"round.end", &info.EndsAt}, + {"tags.round.number", &info.Number}, + {"tags.round.start", &info.StartsAt}, + {"tags.round.end", &info.EndsAt}, } for _, field := range fields { - *field.val, err = strconv.ParseUint(tags[field.tag], 10, 64) + tags := events[field.tag] + if len(tags) == 0 { + continue + } + + *field.val, err = strconv.ParseUint(tags[0], 10, 64) if err != nil { return nil, err } @@ -43,8 +48,8 @@ func NewRoundInfoFromTags(tags map[string]string) (*types.RoundInfo, error) { return &info, nil } -// NewTagsFromOrderInfo returns the KVPairs necessary to make up Order transaction tags -func NewTagsFromOrderInfo(orderID []byte, posterAddress store.Address, newLimit uint64) []common.KVPair { +// NewKVPairFromOrderInfo returns the KVPairs necessary to make up Order transaction tags +func NewKVPairFromOrderInfo(orderID []byte, posterAddress store.Address, newLimit uint64) []common.KVPair { return []common.KVPair{ {Key: []byte("tx.type"), Value: []byte("order")}, {Key: []byte("order.id"), Value: orderID}, diff --git a/packages/go-kosu/go.mod b/packages/go-kosu/go.mod index f8fd81fb..f693348d 100644 --- a/packages/go-kosu/go.mod +++ b/packages/go-kosu/go.mod @@ -33,7 +33,7 @@ require ( github.com/spf13/cobra v0.0.5 github.com/spf13/viper v1.3.2 github.com/stretchr/testify v1.3.0 - github.com/tendermint/tendermint v0.32.2 + github.com/tendermint/tendermint v0.32.3 github.com/tendermint/tm-db v0.1.1 github.com/tidwall/gjson v1.3.0 golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 diff --git a/packages/go-kosu/go.sum b/packages/go-kosu/go.sum index 9a2329b1..d7119990 100644 --- a/packages/go-kosu/go.sum +++ b/packages/go-kosu/go.sum @@ -261,6 +261,7 @@ github.com/tendermint/tendermint v0.32.1/go.mod h1:jmPDAKuNkev9793/ivn/fTBnfpA9m github.com/tendermint/tendermint v0.32.2 h1:FvZWdksfDg/65vKKr5Lgo57keARFnmhrUEXHwyrV1QY= github.com/tendermint/tendermint v0.32.2/go.mod h1:NwMyx58S8VJ7tEpFKqRVlVWKO9N9zjTHu+Dx96VsnOE= github.com/tendermint/tendermint v0.32.3 h1:GEnWpGQ795h5oTFNbfBLsY0LW/CW2j6p6HtiYNfxsgg= +github.com/tendermint/tendermint v0.32.3/go.mod h1:ZK2c29jl1QRYznIRyRWRDsmm1yvtPzBRT00x4t1JToY= github.com/tendermint/tm-db v0.1.1 h1:G3Xezy3sOk9+ekhjZ/kjArYIs1SmwV+1OUgNkj7RgV0= github.com/tendermint/tm-db v0.1.1/go.mod h1:0cPKWu2Mou3IlxecH+MEUSYc1Ch537alLe6CpFrKzgw= github.com/tidwall/gjson v1.3.0 h1:kfpsw1W3trbg4Xm6doUtqSl9+LhLB6qJ9PkltVAQZYs= diff --git a/packages/go-kosu/package.json b/packages/go-kosu/package.json index 3dea869e..8aef5c6c 100644 --- a/packages/go-kosu/package.json +++ b/packages/go-kosu/package.json @@ -1,7 +1,7 @@ { "name": "@kosu/go-kosu", "private": true, - "version": "0.1.0-beta.3", + "version": "0.1.1-beta.3", "description": "Development and CI docker images and supporting scripts for Kosu.", "repository": "https://github.com/ParadigmFoundation/kosu-monorepo/blob/master/packages/go-kosu", "license": "MIT", diff --git a/packages/go-kosu/witness/witness.go b/packages/go-kosu/witness/witness.go index b16baa90..1f5ffcfb 100644 --- a/packages/go-kosu/witness/witness.go +++ b/packages/go-kosu/witness/witness.go @@ -3,7 +3,6 @@ package witness import ( "context" "encoding/hex" - "fmt" "os" "sync" @@ -112,15 +111,11 @@ func (w *Witness) subscribe(ctx context.Context) error { go func() { for e := range sub { - fmt.Printf("e.Events = %+v\n", e.Events) - /* - info, err := abci.NewRoundInfoFromTags(e.Events["tags"]) - if err != nil { - w.log.Error("subscribe: invalid tags", "err", err) - continue - } - */ - info := &types.RoundInfo{} + info, err := abci.NewRoundInfoFromEvents(e.Events) + if err != nil { + w.log.Error("subscribe: invalid tags", "err", err) + continue + } // TODO: validate that n == this.round + 1 w.roundMutex.Lock()