From f51ad3cf9b984494075b5ab2a0e188a477b4d139 Mon Sep 17 00:00:00 2001 From: zhouop0 <11733741+zhouop0@users.noreply.github.com> Date: Fri, 2 Feb 2024 14:20:52 +0800 Subject: [PATCH] format --- internal/handler/checkstatus.go | 1 - internal/handler/handler.go | 20 ++++++++++---------- internal/handler/inscribe.go | 4 ++-- internal/handler/latestBlockNumber.go | 3 ++- internal/types/config.go | 8 +++----- pkg/b2node/b2node.go | 7 ++++--- pkg/btcapi/btcapi.go | 3 ++- pkg/btcapi/mempool/client.go | 6 +++--- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/internal/handler/checkstatus.go b/internal/handler/checkstatus.go index f891952..9e1137a 100644 --- a/internal/handler/checkstatus.go +++ b/internal/handler/checkstatus.go @@ -59,6 +59,5 @@ func CheckStatusTimeOut(ctx *svc.ServiceContext) { } time.Sleep(2 * time.Second) } - } } diff --git a/internal/handler/handler.go b/internal/handler/handler.go index f9f38ba..6483a25 100644 --- a/internal/handler/handler.go +++ b/internal/handler/handler.go @@ -7,18 +7,18 @@ import ( func Run(ctx *svc.ServiceContext) { //// 最新高度 go LatestBlackNumber(ctx) - //// 同步区块 - //go SyncBlock(ctx) - //// 同步事件 - //go SyncEvent(ctx) - //执行committer - //go Committer(ctx) + // 同步区块 + go SyncBlock(ctx) + // 同步事件 + go SyncEvent(ctx) + // 执行committer + go Committer(ctx) // 检查vote状态 - //go CheckStatus(ctx) - //// 检查并铭刻 + go CheckStatus(ctx) + // 检查并铭刻 go Inscribe(ctx) - //// check time out - //go CheckStatusTimeOut(ctx) + // check time out + go CheckStatusTimeOut(ctx) //// 检查 // go CheckBlock(ctx) diff --git a/internal/handler/inscribe.go b/internal/handler/inscribe.go index bada45c..1dc7d9f 100644 --- a/internal/handler/inscribe.go +++ b/internal/handler/inscribe.go @@ -2,9 +2,10 @@ package handler import ( "encoding/json" + "time" + "github.com/b2network/b2committer/pkg/btcapi" btcmempool "github.com/b2network/b2committer/pkg/btcapi/mempool" - "time" "github.com/b2network/b2committer/pkg/inscribe" @@ -76,7 +77,6 @@ func Inscribe(ctx *svc.ServiceContext) { continue } } - } } } diff --git a/internal/handler/latestBlockNumber.go b/internal/handler/latestBlockNumber.go index b56b311..e8becd2 100644 --- a/internal/handler/latestBlockNumber.go +++ b/internal/handler/latestBlockNumber.go @@ -2,9 +2,10 @@ package handler import ( "context" + "time" + "github.com/b2network/b2committer/pkg/btcapi" btcmempool "github.com/b2network/b2committer/pkg/btcapi/mempool" - "time" "github.com/b2network/b2committer/pkg/log" diff --git a/internal/types/config.go b/internal/types/config.go index df2aaf5..e51624b 100644 --- a/internal/types/config.go +++ b/internal/types/config.go @@ -32,12 +32,10 @@ type B2NODEConfig struct { } type BitcoinRPCConfig struct { - NetworkName string `env:"NETWORK_NAME" envDefault:"signet"` - PrivateKey string `env:"BITCOIN_PRIVATE_KEY" envDefault:"c545a409ff7f2e66b4bc863a59dcccf0f4387668a92152a058446bcb58a57027"` // signet tb1p2rfzw7mdyvkashtls5z6y7e5wlwdfzvjyay9mk2xgsdmzt5zwykq2e0rq8 + NetworkName string `env:"NETWORK_NAME" envDefault:"signet"` + PrivateKey string `env:"BITCOIN_PRIVATE_KEY" envDefault:"c545a409ff7f2e66b4bc863a59dcccf0f4387668a92152a058446bcb58a57027"` + // signet tb1p2rfzw7mdyvkashtls5z6y7e5wlwdfzvjyay9mk2xgsdmzt5zwykq2e0rq8 DestinationAddress string `env:"COMMITTER_DESTINATION_ADDRESS" envDefault:"tb1pvhr4e58yatk9uve22rr5umxs0jh9g0j0gtcj0ry2wf23lddhjptsf6c360"` - //c5b87dffa5ada5e75d72413cf5570a26f9a432b10ab3ef8708c00ca75b96dc74 - //tb1pvhr4e58yatk9uve22rr5umxs0jh9g0j0gtcj0ry2wf23lddhjptsf6c360 - } var ( diff --git a/pkg/b2node/b2node.go b/pkg/b2node/b2node.go index b34604a..a0f0e9c 100644 --- a/pkg/b2node/b2node.go +++ b/pkg/b2node/b2node.go @@ -5,9 +5,10 @@ import ( "encoding/hex" "encoding/json" "fmt" - "github.com/b2network/b2committer/pkg/rpc" "strconv" + "github.com/b2network/b2committer/pkg/rpc" + sdkmath "cosmossdk.io/math" clientTx "github.com/cosmos/cosmos-sdk/client/tx" @@ -41,7 +42,7 @@ type GasPriceRsp struct { Result string `json:"result"` } -func NewNodeClient(privateKeyHex string, chainID string, address string, grpcConn *grpc.ClientConn, rpcUrl string) *NodeClient { +func NewNodeClient(privateKeyHex string, chainID string, address string, grpcConn *grpc.ClientConn, rpcURL string) *NodeClient { privatekeyBytes, err := hex.DecodeString(privateKeyHex) if nil != err { panic(err) @@ -53,7 +54,7 @@ func NewNodeClient(privateKeyHex string, chainID string, address string, grpcCon Address: address, ChainID: chainID, GrpcConn: grpcConn, - RPCUrl: rpcUrl, + RPCUrl: rpcURL, } } diff --git a/pkg/btcapi/btcapi.go b/pkg/btcapi/btcapi.go index 409491b..4e62243 100644 --- a/pkg/btcapi/btcapi.go +++ b/pkg/btcapi/btcapi.go @@ -2,10 +2,11 @@ package btcapi import ( "fmt" - "github.com/btcsuite/btcd/chaincfg" "io" "net/http" + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" diff --git a/pkg/btcapi/mempool/client.go b/pkg/btcapi/mempool/client.go index 50727cd..ae179d9 100644 --- a/pkg/btcapi/mempool/client.go +++ b/pkg/btcapi/mempool/client.go @@ -73,8 +73,8 @@ func (c *Client) BroadcastTx(tx *wire.MsgTx) (*chainhash.Hash, error) { return txHash, nil } -func (c *Client) GetTransactionByID(ID string) (*btcapi.Transaction, error) { - res, err := c.request(http.MethodGet, fmt.Sprintf("/tx/%s", ID), nil) +func (c *Client) GetTransactionByID(id string) (*btcapi.Transaction, error) { + res, err := c.request(http.MethodGet, fmt.Sprintf("/tx/%s", id), nil) if err != nil { return nil, err } @@ -87,7 +87,7 @@ func (c *Client) GetTransactionByID(ID string) (*btcapi.Transaction, error) { } func (c *Client) GetCurrentBlockHash() (int64, error) { - res, err := c.request(http.MethodGet, fmt.Sprintf("/blocks/tip/height"), nil) + res, err := c.request(http.MethodGet, "/blocks/tip/height", nil) if err != nil { return 0, err }