fix sfng error
This commit is contained in:
@@ -10,14 +10,13 @@ import (
|
||||
"github.com/gagliardetto/solana-go/programs/address-lookup-table"
|
||||
"github.com/gagliardetto/solana-go/rpc"
|
||||
|
||||
"github.com/samlior/libsam/pkg/shreder"
|
||||
"github.com/samlior/libsam/v2/pkg/shreder"
|
||||
)
|
||||
|
||||
const (
|
||||
rpcURL = "https://staked.helius-rpc.com?api-key=5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d"
|
||||
txSignature = "4YUQzsQcHxt5jA6qKPVBWCgw8VRuE6bZqAoXeiwptbdLwta3QnDbWHzjwP3mY8hJPPerSf1yGbpdL2SdyWZTJ9e1"
|
||||
labelFilter = ""
|
||||
enableStats = true
|
||||
rpcURL = "https://staked.helius-rpc.com?api-key=5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d"
|
||||
txSignature = "3hFamox2W1oWMwbRkfF5r9YiPULsdRsnR2TQsFDVtFCXf6cJ8ijGNgHGFmEbxEbVEryLg21sbt4qoGLwrPfvJ2UC"
|
||||
labelFilter = ""
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -75,7 +74,7 @@ func main() {
|
||||
}
|
||||
|
||||
update := toSubscribeUpdate(tx.Slot, rawTx)
|
||||
signals := shreder.ParseTransaction(update, nil, enableStats)
|
||||
signals := parseSignals(context.Background(), update)
|
||||
if len(signals) == 0 {
|
||||
fmt.Println("no signals parsed")
|
||||
return
|
||||
@@ -83,9 +82,6 @@ func main() {
|
||||
|
||||
printed := false
|
||||
for _, signal := range signals {
|
||||
if signal == nil {
|
||||
continue
|
||||
}
|
||||
if labelFilter != "" && signal.Label != labelFilter {
|
||||
continue
|
||||
}
|
||||
@@ -107,9 +103,6 @@ func main() {
|
||||
fmt.Println("no matching signal parsed, dump all signals:")
|
||||
}
|
||||
for _, signal := range signals {
|
||||
if signal == nil {
|
||||
continue
|
||||
}
|
||||
output, err := json.MarshalIndent(signal, "", " ")
|
||||
if err != nil {
|
||||
log.Fatalf("marshal signal failed: %v", err)
|
||||
@@ -118,6 +111,24 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func parseSignals(ctx context.Context, update *shreder.SubscribeUpdateTransaction) []shreder.TxSignal {
|
||||
signalsCh := make(chan shreder.TxSignal, 64)
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
shreder.ParseTransactionForSubscribe(ctx, update, nil, signalsCh, done)
|
||||
}()
|
||||
go func() {
|
||||
<-done
|
||||
close(signalsCh)
|
||||
}()
|
||||
|
||||
signals := make([]shreder.TxSignal, 0)
|
||||
for signal := range signalsCh {
|
||||
signals = append(signals, signal)
|
||||
}
|
||||
return signals
|
||||
}
|
||||
|
||||
func toSubscribeUpdate(slot uint64, tx *solana.Transaction) *shreder.SubscribeUpdateTransaction {
|
||||
signatures := make([][]byte, len(tx.Signatures))
|
||||
for i, sig := range tx.Signatures {
|
||||
|
||||
Reference in New Issue
Block a user