@@ -47,8 +47,8 @@ import (
4747// @contact.url https://blinklabs.io
4848// @contact.email [email protected] 4949
50- // @license.name Apache 2.0
51- // @license.url http://www.apache.org/licenses/LICENSE-2.0.html
50+ // @license.name Apache 2.0
51+ // @license.url http://www.apache.org/licenses/LICENSE-2.0.html
5252func Start (cfg * config.Config ) error {
5353 // Disable gin debug and color output
5454 gin .SetMode (gin .ReleaseMode )
@@ -321,13 +321,13 @@ func handleSubmitTx(c *gin.Context) {
321321 oConn .Close ()
322322 }()
323323 // Determine transaction type (era)
324- txType , err := determineTransactionType (txRawBytes )
324+ txType , err := ledger . DetermineTransactionType (txRawBytes )
325325 if err != nil {
326326 c .JSON (400 , "could not parse transaction to determine type" )
327327 return
328328 }
329329 // Submit the transaction
330- if err := oConn .LocalTxSubmission ().Client .SubmitTx (txType , txRawBytes ); err != nil {
330+ if err := oConn .LocalTxSubmission ().Client .SubmitTx (uint16 ( txType ) , txRawBytes ); err != nil {
331331 if c .GetHeader ("Accept" ) == "application/cbor" {
332332 txRejectErr := err .(localtxsubmission.TransactionRejectedError )
333333 c .Data (400 , "application/cbor" , txRejectErr .ReasonCbor )
@@ -343,29 +343,3 @@ func handleSubmitTx(c *gin.Context) {
343343 // Increment custom metric
344344 _ = ginmetrics .GetMonitor ().GetMetric ("tx_submit_count" ).Inc (nil )
345345}
346-
347- func determineTransactionType (data []byte ) (uint16 , error ) {
348- // TODO: uncomment this once the following issue is resolved:
349- // https://github.com/blinklabs-io/gouroboros/issues/206
350- /*
351- if _, err := ledger.NewByronTransactionFromCbor(data); err == nil {
352- return ledger.TX_TYPE_BYRON, nil
353- }
354- */
355- if _ , err := ledger .NewShelleyTransactionFromCbor (data ); err == nil {
356- return ledger .TX_TYPE_SHELLEY , nil
357- }
358- if _ , err := ledger .NewAllegraTransactionFromCbor (data ); err == nil {
359- return ledger .TX_TYPE_ALLEGRA , nil
360- }
361- if _ , err := ledger .NewMaryTransactionFromCbor (data ); err == nil {
362- return ledger .TX_TYPE_MARY , nil
363- }
364- if _ , err := ledger .NewAlonzoTransactionFromCbor (data ); err == nil {
365- return ledger .TX_TYPE_ALONZO , nil
366- }
367- if _ , err := ledger .NewBabbageTransactionFromCbor (data ); err == nil {
368- return ledger .TX_TYPE_BABBAGE , nil
369- }
370- return 0 , fmt .Errorf ("unknown transaction type" )
371- }
0 commit comments