Skip to content

Commit

Permalink
modify listener
Browse files Browse the repository at this point in the history
  • Loading branch information
goalongway committed Oct 21, 2024
1 parent 0566042 commit 68eaad4
Show file tree
Hide file tree
Showing 98 changed files with 44,129 additions and 1,876 deletions.
788 changes: 30 additions & 758 deletions README.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions applications/cmd/builder/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package main

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/initiates"
"bsquared.network/b2-message-sharing-applications/internal/serves/builder"
"bsquared.network/b2-message-sharing-applications/internal/utils/log"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/initiates"
"bsquared.network/message-sharing-applications/internal/serves/builder"
"bsquared.network/message-sharing-applications/internal/utils/log"
"encoding/json"
"flag"
"fmt"
Expand Down
10 changes: 5 additions & 5 deletions applications/cmd/listener/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/initiates"
"bsquared.network/b2-message-sharing-applications/internal/serves/listener/bitcoin"
"bsquared.network/b2-message-sharing-applications/internal/serves/listener/ethereum"
"bsquared.network/b2-message-sharing-applications/internal/utils/log"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/initiates"
"bsquared.network/message-sharing-applications/internal/serves/listener/bitcoin"
"bsquared.network/message-sharing-applications/internal/serves/listener/ethereum"
"bsquared.network/message-sharing-applications/internal/utils/log"
"encoding/json"
"flag"
"fmt"
Expand Down
10 changes: 5 additions & 5 deletions applications/cmd/proposer/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/initiates"
"bsquared.network/b2-message-sharing-applications/internal/serves/proposer"
"bsquared.network/b2-message-sharing-applications/internal/utils/log"
"bsquared.network/b2-message-sharing-applications/internal/vo"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/initiates"
"bsquared.network/message-sharing-applications/internal/serves/proposer"
"bsquared.network/message-sharing-applications/internal/utils/log"
"bsquared.network/message-sharing-applications/internal/vo"
"encoding/json"
"flag"
"fmt"
Expand Down
10 changes: 5 additions & 5 deletions applications/cmd/validator/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/initiates"
"bsquared.network/b2-message-sharing-applications/internal/serves/validator"
"bsquared.network/b2-message-sharing-applications/internal/utils/log"
"bsquared.network/b2-message-sharing-applications/internal/vo"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/initiates"
"bsquared.network/message-sharing-applications/internal/serves/validator"
"bsquared.network/message-sharing-applications/internal/utils/log"
"bsquared.network/message-sharing-applications/internal/vo"
"encoding/json"
"flag"
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion applications/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module bsquared.network/b2-message-sharing-applications
module bsquared.network/message-sharing-applications

go 1.22

Expand Down
2 changes: 1 addition & 1 deletion applications/internal/config/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"bsquared.network/b2-message-sharing-applications/internal/enums"
"bsquared.network/message-sharing-applications/internal/enums"
"fmt"
"github.com/pkg/errors"
"github.com/spf13/viper"
Expand Down
2 changes: 1 addition & 1 deletion applications/internal/initiates/db.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package initiates

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/config"
"fmt"
"gorm.io/driver/mysql"
"gorm.io/gorm"
Expand Down
2 changes: 1 addition & 1 deletion applications/internal/models/deposit.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package models

import (
"bsquared.network/b2-message-sharing-applications/internal/enums"
"bsquared.network/message-sharing-applications/internal/enums"
"time"
)

Expand Down
2 changes: 1 addition & 1 deletion applications/internal/models/messages.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models

import "bsquared.network/b2-message-sharing-applications/internal/enums"
import "bsquared.network/message-sharing-applications/internal/enums"

type Message struct {
Base
Expand Down
2 changes: 1 addition & 1 deletion applications/internal/models/signatures.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package models

import (
"bsquared.network/b2-message-sharing-applications/internal/enums"
"bsquared.network/message-sharing-applications/internal/enums"
"github.com/shopspring/decimal"
)

Expand Down
2 changes: 1 addition & 1 deletion applications/internal/models/sync_tasks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models

import "bsquared.network/b2-message-sharing-applications/internal/enums"
import "bsquared.network/message-sharing-applications/internal/enums"

type SyncTask struct {
Base
Expand Down
10 changes: 5 additions & 5 deletions applications/internal/serves/builder/builder.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package builder

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/enums"
"bsquared.network/b2-message-sharing-applications/internal/models"
msg "bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/message"
"bsquared.network/b2-message-sharing-applications/internal/utils/log"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/enums"
"bsquared.network/message-sharing-applications/internal/models"
msg "bsquared.network/message-sharing-applications/internal/utils/ethereum/message"
"bsquared.network/message-sharing-applications/internal/utils/log"
"bytes"
"context"
"crypto/ecdsa"
Expand Down
14 changes: 7 additions & 7 deletions applications/internal/serves/listener/bitcoin/bitcoin.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package bitcoin

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/enums"
"bsquared.network/b2-message-sharing-applications/internal/models"
"bsquared.network/b2-message-sharing-applications/internal/types"
"bsquared.network/b2-message-sharing-applications/internal/utils/aa"
"bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/message"
"bsquared.network/b2-message-sharing-applications/internal/utils/log"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/enums"
"bsquared.network/message-sharing-applications/internal/models"
"bsquared.network/message-sharing-applications/internal/types"
"bsquared.network/message-sharing-applications/internal/utils/aa"
"bsquared.network/message-sharing-applications/internal/utils/ethereum/message"
"bsquared.network/message-sharing-applications/internal/utils/log"
"bytes"
"context"
"encoding/hex"
Expand Down
41 changes: 28 additions & 13 deletions applications/internal/serves/listener/ethereum/ethereum.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package ethereum

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/enums"
"bsquared.network/b2-message-sharing-applications/internal/models"
"bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/event"
"bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/event/message"
"bsquared.network/b2-message-sharing-applications/internal/utils/log"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/enums"
"bsquared.network/message-sharing-applications/internal/models"
"bsquared.network/message-sharing-applications/internal/utils/ethereum/event"
"bsquared.network/message-sharing-applications/internal/utils/ethereum/event/message"
"bsquared.network/message-sharing-applications/internal/utils/log"
"context"
"fmt"
"github.com/ethereum/go-ethereum"
Expand Down Expand Up @@ -235,6 +235,7 @@ func (l *EthereumListener) handEvent() {
handles := make(map[string]bool)

var Type enums.MessageType
var FromMessageBridge string
var FromChainId int64
var FromSender string
var FromId string
Expand All @@ -259,6 +260,7 @@ func (l *EthereumListener) handEvent() {
time.Sleep(duration)
continue
}
FromMessageBridge = event.ContractAddress
FromChainId = messageCall.FromChainId
FromSender = messageCall.FromSender
FromId = common.BytesToHash(messageCall.FromId.BigInt().Bytes()).Hex()
Expand All @@ -279,17 +281,30 @@ func (l *EthereumListener) handEvent() {
FromId = common.BytesToHash(messageSend.FromId.BigInt().Bytes()).Hex()
ToChainId = messageSend.ToChainId
ToContractAddress = messageSend.ContractAddress
ToMessageBridge = event.ContractAddress
ToBytes = messageSend.Bytes
Type = enums.MessageTypeSend
status = enums.MessageStatusPending
}

messageBridge, ok := l.bridges[ToChainId]
if ok {
ToMessageBridge = messageBridge
} else {
invalids = append(invalids, event.Id)
continue
if FromMessageBridge == "" {
messageBridge, ok := l.bridges[FromChainId]
if ok {
FromMessageBridge = messageBridge
} else {
invalids = append(invalids, event.Id)
continue
}
}

if ToMessageBridge == "" {
messageBridge, ok := l.bridges[ToChainId]
if ok {
ToMessageBridge = messageBridge
} else {
invalids = append(invalids, event.Id)
continue
}
}

var message models.Message
Expand All @@ -305,7 +320,7 @@ func (l *EthereumListener) handEvent() {
Type: Type,
FromChainId: FromChainId,
FromSender: FromSender,
FromMessageBridge: event.ContractAddress,
FromMessageBridge: FromMessageBridge,
FromId: FromId,
ToChainId: ToChainId,
ToMessageBridge: ToMessageBridge,
Expand Down
14 changes: 7 additions & 7 deletions applications/internal/serves/proposer/proposer.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package proposer

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/enums"
"bsquared.network/b2-message-sharing-applications/internal/models"
"bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/message"
"bsquared.network/b2-message-sharing-applications/internal/utils/log"
"bsquared.network/b2-message-sharing-applications/internal/utils/tx"
"bsquared.network/b2-message-sharing-applications/internal/vo"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/enums"
"bsquared.network/message-sharing-applications/internal/models"
"bsquared.network/message-sharing-applications/internal/utils/ethereum/message"
"bsquared.network/message-sharing-applications/internal/utils/log"
"bsquared.network/message-sharing-applications/internal/utils/tx"
"bsquared.network/message-sharing-applications/internal/vo"
"bufio"
"context"
"crypto/ecdsa"
Expand Down
12 changes: 6 additions & 6 deletions applications/internal/serves/validator/validator.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package validator

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/enums"
"bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/message"
"bsquared.network/b2-message-sharing-applications/internal/utils/log"
"bsquared.network/b2-message-sharing-applications/internal/utils/tx"
"bsquared.network/b2-message-sharing-applications/internal/vo"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/enums"
"bsquared.network/message-sharing-applications/internal/utils/ethereum/message"
"bsquared.network/message-sharing-applications/internal/utils/log"
"bsquared.network/message-sharing-applications/internal/utils/tx"
"bsquared.network/message-sharing-applications/internal/vo"
"bufio"
"context"
"crypto/ecdsa"
Expand Down
2 changes: 1 addition & 1 deletion applications/internal/utils/aa/aa.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package aa

import (
"bsquared.network/b2-message-sharing-applications/internal/utils/particle"
"bsquared.network/message-sharing-applications/internal/utils/particle"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down
2 changes: 1 addition & 1 deletion applications/internal/utils/ethereum/event/message/call.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package message

import (
"bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/event"
"bsquared.network/message-sharing-applications/internal/utils/ethereum/event"
"encoding/json"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down
2 changes: 1 addition & 1 deletion applications/internal/utils/ethereum/event/message/send.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package message

import (
"bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/event"
"bsquared.network/message-sharing-applications/internal/utils/ethereum/event"
"encoding/json"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down
10 changes: 5 additions & 5 deletions applications/internal/utils/tx/tx.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package tx

import (
"bsquared.network/b2-message-sharing-applications/internal/config"
"bsquared.network/b2-message-sharing-applications/internal/types"
"bsquared.network/b2-message-sharing-applications/internal/utils/aa"
"bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/event"
"bsquared.network/b2-message-sharing-applications/internal/utils/ethereum/message"
"bsquared.network/message-sharing-applications/internal/config"
"bsquared.network/message-sharing-applications/internal/types"
"bsquared.network/message-sharing-applications/internal/utils/aa"
"bsquared.network/message-sharing-applications/internal/utils/ethereum/event"
"bsquared.network/message-sharing-applications/internal/utils/ethereum/message"
"bytes"
"context"
"encoding/hex"
Expand Down
2 changes: 1 addition & 1 deletion applications/internal/vo/vo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package vo

import (
"bsquared.network/b2-message-sharing-applications/internal/enums"
"bsquared.network/message-sharing-applications/internal/enums"
"github.com/btcsuite/btcd/rpcclient"
"github.com/ethereum/go-ethereum/ethclient"
)
Expand Down
Loading

0 comments on commit 68eaad4

Please sign in to comment.