Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary patch to 'Unsupported event' #422

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (c *CollapseResultsLogger) Log(results *collapseResults) {
func (c *CollapseResultsLogger) addTx(mod, event []byte,
timestamp time.Time, tag int,
txID []byte, sender []byte, logError error) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this new line please

o := c.arena.NewObject()

o.Set("mod", c.arena.NewStringBytes(mod))
Expand Down
1 change: 1 addition & 0 deletions wctl/wctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ type Client struct {
// PollTransactions
OnTxApplied
OnTxGossipError
OnTxRejected
OnTxFailed

OnMetrics
Expand Down
9 changes: 9 additions & 0 deletions wctl/ws_callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ type (
}
OnTxApplied = func(TxApplied)

TxRejected struct {
TxID [32]byte `json:"tx_id"`
SenderID [32]byte `json:"sender_id"`
Tag byte `json:"tag"`
Error string `json:"error,omitempty"`
Time time.Time `json:"time"`
}
OnTxRejected = func(TxRejected)

TxGossipError struct {
Error string `json:"error"`
Time time.Time `json:"time"`
Expand Down
27 changes: 27 additions & 0 deletions wctl/ws_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func (c *Client) PollTransactions() (func(), error) {
err = parseTxGossipError(c, o)
case ev == "failed":
err = parseTxFailed(c, o)
case ev == "rejected":
err = parseTxRejected(c, o)
default:
err = errInvalidEvent(o, ev)
}
Expand Down Expand Up @@ -81,6 +83,31 @@ func parseTxGossipError(c *Client, v *fastjson.Value) error {
return nil
}

func parseTxRejected(c *Client, v *fastjson.Value) error {
var t TxRejected

if err := jsonHex(v, t.TxID[:], "tx_id"); err != nil {
return err
}

if err := jsonHex(v, t.SenderID[:], "sender_id"); err != nil {
return err
}

t.Tag = byte(v.GetUint("tag"))
t.Error = jsonString(v, "error")

if err := jsonTime(v, &t.Time, "time"); err != nil {
return err
}

if c.OnTxRejected != nil {
c.OnTxRejected(t)
}

return nil
}

func parseTxFailed(c *Client, v *fastjson.Value) error {
var t TxFailed

Expand Down