File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed
protocol/localtxsubmission Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 55 "encoding/json"
66 "flag"
77 "fmt"
8- ouroboros "github.com/cloudstruct/go-ouroboros-network"
98 "github.com/cloudstruct/go-cardano-ledger"
9+ ouroboros "github.com/cloudstruct/go-ouroboros-network"
1010 "github.com/cloudstruct/go-ouroboros-network/protocol/localtxsubmission"
1111 "io/ioutil"
1212 "os"
@@ -105,8 +105,8 @@ func localTxSubmissionAcceptTxHandler() error {
105105 return nil
106106}
107107
108- func localTxSubmissionRejectTxHandler (reason interface {} ) error {
109- fmt .Printf ("The transaction was rejected: %#v\n " , reason )
108+ func localTxSubmissionRejectTxHandler (reasonCbor [] byte ) error {
109+ fmt .Printf ("The transaction was rejected (reason in hex-encoded CBOR) : %#v\n " , reasonCbor )
110110 os .Exit (1 )
111111 return nil
112112}
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ type CallbackConfig struct {
5959// Callback function types
6060type SubmitTxFunc func (interface {}) error
6161type AcceptTxFunc func () error
62- type RejectTxFunc func (interface {} ) error
62+ type RejectTxFunc func ([] byte ) error
6363type DoneFunc func () error
6464
6565func New (options protocol.ProtocolOptions ) * LocalTxSubmission {
@@ -135,7 +135,7 @@ func (l *LocalTxSubmission) handleRejectTx(msgGeneric protocol.Message) error {
135135 }
136136 msg := msgGeneric .(* MsgRejectTx )
137137 // Call the user callback function
138- return l .callbackConfig .RejectTxFunc (msg .Reason )
138+ return l .callbackConfig .RejectTxFunc ([] byte ( msg .Reason ) )
139139}
140140
141141func (l * LocalTxSubmission ) handleDone () error {
Original file line number Diff line number Diff line change @@ -80,15 +80,18 @@ func NewMsgAcceptTx() *MsgAcceptTx {
8080
8181type MsgRejectTx struct {
8282 protocol.MessageBase
83- Reason interface {}
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
86+ Reason cbor.RawMessage
8487}
8588
86- func NewMsgRejectTx (reason interface {} ) * MsgRejectTx {
89+ func NewMsgRejectTx (reasonCbor [] byte ) * MsgRejectTx {
8790 m := & MsgRejectTx {
8891 MessageBase : protocol.MessageBase {
8992 MessageType : MESSAGE_TYPE_REJECT_TX ,
9093 },
91- Reason : reason ,
94+ Reason : cbor . RawMessage ( reasonCbor ) ,
9295 }
9396 return m
9497}
You can’t perform that action at this time.
0 commit comments