File tree Expand file tree Collapse file tree 5 files changed +18
-8
lines changed
protocol/localtxsubmission Expand file tree Collapse file tree 5 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ module github.com/cloudstruct/go-ouroboros-network
33go 1.17
44
55require (
6- github.com/cloudstruct/go-cardano-ledger v0.1 .0
6+ github.com/cloudstruct/go-cardano-ledger v0.4 .0
77 github.com/fxamacker/cbor/v2 v2.4.0
88)
99
Original file line number Diff line number Diff line change 1- github.com/cloudstruct/go-cardano-ledger v0.1 .0 h1:HUyXl00je5aexGyrsZJ6D1gMUs0gIic8FVbQwlF6v3M =
2- github.com/cloudstruct/go-cardano-ledger v0.1 .0 /go.mod h1:EBB9JG+3nBs3IV0p751yz1468XYkzJce1/A2X+xH8L8 =
1+ github.com/cloudstruct/go-cardano-ledger v0.4 .0 h1:4BZvwZSM82r/Bt+W4XHTstJEABg0jXcougcZgDmZBo0 =
2+ github.com/cloudstruct/go-cardano-ledger v0.4 .0 /go.mod h1:EBB9JG+3nBs3IV0p751yz1468XYkzJce1/A2X+xH8L8 =
33github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88 =
44github.com/fxamacker/cbor/v2 v2.4.0 /go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo =
55github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM =
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package localtxsubmission
22
33import (
44 "fmt"
5+ "github.com/cloudstruct/go-cardano-ledger"
56 "github.com/cloudstruct/go-ouroboros-network/protocol"
67 "sync"
78)
@@ -75,7 +76,12 @@ func (c *Client) handleAcceptTx() error {
7576
7677func (c * Client ) handleRejectTx (msg protocol.Message ) error {
7778 msgRejectTx := msg .(* MsgRejectTx )
78- err := TransactionRejectedError {
79+ rejectErr , err := ledger .NewTxSubmitErrorFromCbor (msgRejectTx .Reason )
80+ if err != nil {
81+ return err
82+ }
83+ err = TransactionRejectedError {
84+ Reason : rejectErr ,
7985 ReasonCbor : []byte (msgRejectTx .Reason ),
8086 }
8187 c .submitResultChan <- err
Original file line number Diff line number Diff line change @@ -6,8 +6,13 @@ import (
66
77type TransactionRejectedError struct {
88 ReasonCbor []byte
9+ Reason error
910}
1011
1112func (e TransactionRejectedError ) Error () string {
12- return fmt .Sprintf ("transaction rejected: CBOR reason hex: %x" , e .ReasonCbor )
13+ if e .Reason != nil {
14+ return e .Reason .Error ()
15+ } else {
16+ return fmt .Sprintf ("transaction rejected: CBOR reason hex: %x" , e .ReasonCbor )
17+ }
1318}
Original file line number Diff line number Diff line change @@ -80,9 +80,8 @@ func NewMsgAcceptTx() *MsgAcceptTx {
8080
8181type MsgRejectTx struct {
8282 protocol.MessageBase
83- // TODO: find a better way to handle this
84- // We use RawMessage here because the failure reason can often contain
85- // structures that we can't currently parse, such as maps with []uint8 keys
83+ // We use RawMessage here because the failure reason can be numerous different
84+ // structures, and we'll need to do further processing
8685 Reason cbor.RawMessage
8786}
8887
You can’t perform that action at this time.
0 commit comments