punm parser
This commit is contained in:
@@ -54,7 +54,7 @@ func main() {
|
||||
instructorErrIndex, customerErrCode, _ = txErr.GetCustomErrorCode()
|
||||
fmt.Printf("now: %s, block: %d, tx: %s, errInstr Code: %d, errInstrIndex: %d, err: %v\n", time.Now().Format("2006-01-02 15:04:05"), ptx.Block, ptx.GetTxHash(), customerErrCode, instructorErrIndex, ptx.Err)
|
||||
} else {
|
||||
txs := example.FromTx(ptx, msg.RawTx)
|
||||
txs := example.FromTx(ptx)
|
||||
if len(txs) == 0 {
|
||||
fmt.Printf("tx is empty, block: %d, tx %s \n", ptx.Block, ptx.GetTxHash())
|
||||
continue
|
||||
|
||||
@@ -18,5 +18,4 @@ type SubscriptionMessage struct {
|
||||
|
||||
Block *BlockInfo
|
||||
Tx *pump_parser.Tx
|
||||
RawTx *pump_parser.RawTx
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@ import (
|
||||
)
|
||||
|
||||
type PumpHandler struct {
|
||||
callback func(*types.Tx, *types.RawTx)
|
||||
callback func(*types.Tx)
|
||||
}
|
||||
|
||||
func NewPumpHandler(cb func(*types.Tx, *types.RawTx)) *PumpHandler {
|
||||
func NewPumpHandler(cb func(*types.Tx)) *PumpHandler {
|
||||
return &PumpHandler{
|
||||
callback: func(tx *types.Tx, tx2 *types.RawTx) {
|
||||
callback: func(tx *types.Tx) {
|
||||
//tx.Check(tx2)
|
||||
cb(tx, tx2)
|
||||
cb(tx)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -40,11 +40,13 @@ func (h *PumpHandler) HandleMessage(rawTx *types.RawTx) {
|
||||
|
||||
BeforeSolBalance: beforeSolBalance,
|
||||
AfterSOLBalance: afterSolBalance,
|
||||
}, rawTx)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
parsedTx, err := types.Parser(rawTx)
|
||||
var parsedTx = &types.Tx{}
|
||||
parsedTx.SetRawTx(rawTx)
|
||||
err := parsedTx.Parser()
|
||||
if err != nil {
|
||||
fmt.Printf("parser error: %s, block: %d tx: %s\n", err, rawTx.Slot, rawTx.TxHash())
|
||||
return
|
||||
@@ -55,6 +57,6 @@ func (h *PumpHandler) HandleMessage(rawTx *types.RawTx) {
|
||||
}
|
||||
// fmt.Println(parsedTx.GetTxHash(), len(parsedTx.Swaps))
|
||||
if h.callback != nil {
|
||||
h.callback(parsedTx, rawTx)
|
||||
h.callback(parsedTx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ func NewClientWithPumpSwap(endpoint string, ch chan SubscriptionMessage) *Client
|
||||
subStatus: false,
|
||||
subscription: &subscription,
|
||||
}
|
||||
c.handler = NewPumpHandler(func(tx *types.Tx, tx2 *types.RawTx) {
|
||||
c.sendTx(tx, tx2)
|
||||
c.handler = NewPumpHandler(func(tx *types.Tx) {
|
||||
c.sendTx(tx)
|
||||
})
|
||||
return c
|
||||
}
|
||||
@@ -107,8 +107,8 @@ func NewClientWithLaunchLab(endpoint string, ch chan SubscriptionMessage) *Clien
|
||||
subStatus: false,
|
||||
subscription: &subscription,
|
||||
}
|
||||
c.handler = NewPumpHandler(func(tx *types.Tx, tx2 *types.RawTx) {
|
||||
c.sendTx(tx, tx2)
|
||||
c.handler = NewPumpHandler(func(tx *types.Tx) {
|
||||
c.sendTx(tx)
|
||||
})
|
||||
return c
|
||||
}
|
||||
@@ -262,13 +262,12 @@ func (c *Client) computeDelay(slot uint64) int64 {
|
||||
return delay
|
||||
}
|
||||
|
||||
func (c *Client) sendTx(t *types.Tx, tx *types.RawTx) {
|
||||
func (c *Client) sendTx(t *types.Tx) {
|
||||
c.ch <- SubscriptionMessage{
|
||||
Reconnect: c.firstMessage,
|
||||
EstimateDelaySecond: c.computeDelay(tx.Slot),
|
||||
EstimateDelaySecond: c.computeDelay(t.Block),
|
||||
Block: nil,
|
||||
Tx: t,
|
||||
RawTx: tx,
|
||||
}
|
||||
c.firstMessage = false
|
||||
}
|
||||
@@ -287,8 +286,7 @@ func (c *Client) sendBlock(blockMeta *pb.SubscribeUpdateBlockMeta) {
|
||||
BlockHash: c.leastBlock.BlockHash,
|
||||
Height: c.leastBlock.Height,
|
||||
},
|
||||
Tx: nil,
|
||||
RawTx: nil,
|
||||
Tx: nil,
|
||||
}
|
||||
c.firstMessage = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user