fix okx user
This commit is contained in:
96
internal/example/cmd/main.go
Normal file
96
internal/example/cmd/main.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
parser "github.com/thloyi/pump-parser"
|
||||
example "github.com/thloyi/pump-parser/internal/example"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//pool, err := ants.NewPool(100, ants.WithPreAlloc(true), ants.WithNonblocking(true))
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
//xt := tracker.NewTwitterTracker(nil) // Initialize Twitter tracker if needed
|
||||
// laserstream-mainnet-slc.helius-rpc.com:80
|
||||
|
||||
ch := make(chan example.SubscriptionMessage, 1)
|
||||
go example.RunLoopWithReConnect(context.Background(), "127.0.0.1:10001", parser.SolProgramPump, ch)
|
||||
// var tokenTxs = make(map[string]*types.Tx)
|
||||
// currentBlock := uint64(0)
|
||||
for msg := range ch {
|
||||
if msg.Tx == nil {
|
||||
block := msg.Block
|
||||
if block.Slot%100 == 0 {
|
||||
fmt.Printf("slot: %d, hash: %s, time: %s, height: %d, estimate delay second: %d\n",
|
||||
block.Slot, block.BlockHash, time.Unix(block.BlockTime, 0).Format("2006-01-02 15:04:05"), block.Height, msg.EstimateDelaySecond)
|
||||
}
|
||||
continue
|
||||
}
|
||||
ptx := msg.Tx
|
||||
//data, _ := json.Marshal(tx)
|
||||
//fmt.Println(string(data))
|
||||
//continue
|
||||
|
||||
//if tx.Token0Address != "HRHLDjqFBhNeyTXUuZQE9gTy5z2112qeQBS9U79NHyyp" {
|
||||
// continue
|
||||
//}
|
||||
//if tx.Program != parser.SolProgramPump {
|
||||
// continue
|
||||
//}
|
||||
//if currentBlock == ptx.Block {
|
||||
// continue
|
||||
//}
|
||||
|
||||
// 处理交易
|
||||
txErr, ok := ptx.Err.(*parser.TransactionError)
|
||||
var customerErrCode uint32
|
||||
var instructorErrIndex uint8
|
||||
if ok {
|
||||
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)
|
||||
if len(txs) == 0 {
|
||||
fmt.Printf("tx is empty, block: %d, tx %s \n", ptx.Block, ptx.GetTxHash())
|
||||
continue
|
||||
}
|
||||
printed := false
|
||||
for _, tx := range txs {
|
||||
//if tx.Program != parser.SolProgramPump {
|
||||
// continue
|
||||
//}
|
||||
//if tx.Token1Amount.GreaterThanOrEqual(decimal.NewFromFloat(0.1)) || tx.Event != "buy" {
|
||||
// continue
|
||||
//}
|
||||
printed = true
|
||||
fmt.Printf("t: %s, block: %d, hash: %s, maker: %s, program: %s, event: %s, token0: %s, entryContract: %s, token balance: %s, \n",
|
||||
time.Now().Format(time.RFC3339Nano),
|
||||
tx.Block, tx.GetTxHash(), tx.Maker, tx.Program, tx.Event, tx.Token0Amount, tx.EntryContract, tx.AfterSignerToken0Balance)
|
||||
//break
|
||||
}
|
||||
if !printed {
|
||||
continue
|
||||
}
|
||||
//fmt.Printf("t: %s, block: %d, hash: %s, signer: %s, program: %s, event: %s, token0: %s, token1: %s, signer before sol :%s, after sol: %s, after token: %s, tokencreator: %s, tokenprogram: %s, mayhem: %t\n",
|
||||
// time.Now().Format(time.RFC3339Nano),
|
||||
// tx.Block, tx.GetTxHash(), tx.Maker, tx.Program, tx.Event, tx.Token0Amount.String(), tx.Token1Amount.String(),
|
||||
// tx.BeforeSolBalance, tx.AfterSOLBalance, tx.AfterSignerToken0Balance, tx.TokenCreator, tx.Token0Program, tx.Mayhem)
|
||||
|
||||
}
|
||||
// currentBlock = ptx.Block
|
||||
//
|
||||
//if tx.Event == "create" {
|
||||
// if err := pool.Submit(func() {
|
||||
// now := time.Now()
|
||||
// xt.AddToken(tx.Token)
|
||||
// log.Printf("Add token %s, cost: %s %s %v %v", tx.Token.Address, time.Since(now), tx.Token.Twitter, xt.DuplicateCount(tx.Token.Address), xt.HasTwitter(tx.Token.Address))
|
||||
// }); err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user