From b660adfd784f0c4a2e91ad33882140770f537022 Mon Sep 17 00:00:00 2001 From: Captain Date: Mon, 9 May 2022 15:31:19 +0000 Subject: [PATCH] Release74: Sync issues and other minor bugs fixes. --- blockchain/blockchain.go | 14 ++++++++++++++ config/version.go | 2 +- p2p/controller.go | 24 +++++++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 59d16141..e6c1edc0 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -205,6 +205,20 @@ func Blockchain_Start(params map[string]interface{}) (*Blockchain, error) { chain.Initialise_Chain_From_DB() // load the chain from the disk +try_again: + version, err := chain.ReadBlockSnapshotVersion(chain.Get_Top_ID()) + if err != nil { + panic(err) + } + // this case happens when chain syncs from rsync and if rsync takes more time than block_time + // basically this can also be fixed, if topo.map file is renamed to name starting with 'a' + // it should be the first file to be synced, but instead of renaming file as fix + // we are fixing it by checking how much we have progressed and skip those block + if _, err = chain.Load_Merkle_Hash(version); err != nil { + chain.Rewind_Chain(1) // rewind 1 block + goto try_again + } + if chain.Pruned >= 1 { logger.Info("Chain Pruned till", "topoheight", chain.Pruned) } diff --git a/config/version.go b/config/version.go index 4a27a745..bdc577d1 100644 --- a/config/version.go +++ b/config/version.go @@ -20,4 +20,4 @@ import "github.com/blang/semver/v4" // right now it has to be manually changed // do we need to include git commitsha?? -var Version = semver.MustParse("3.4.141-73.DEROHE.STARGATE+26022022") +var Version = semver.MustParse("3.4.141-74.DEROHE.STARGATE+26022022") diff --git a/p2p/controller.go b/p2p/controller.go index 6761d74d..2c9600a9 100644 --- a/p2p/controller.go +++ b/p2p/controller.go @@ -120,6 +120,14 @@ func P2P_Init(params map[string]interface{}) error { logger.Info("", "BW_FACTOR", bw_factor) } + if os.Getenv("UDP_READ_BUF_CONN") != "" { + size, _ := strconv.Atoi(os.Getenv("UDP_READ_BUF_CONN")) + if size <= 64*1024 { + size = 64 * 1024 + } + logger.Info("", "UDP_READ_BUF_CONN", size) + } + // permanently unban any seed nodes if globals.IsMainnet() { for i := range config.Mainnet_seed_nodes { @@ -271,6 +279,20 @@ func tunekcp(conn *kcp.UDPSession) { } else { conn.SetNoDelay(0, 40, 0, 0) // tuning paramters for local } + + size := 1 * 1024 * 1024 // set the buffer size max possible upto 1 MB, default is 1 MB + if os.Getenv("UDP_READ_BUF_CONN") != "" { + size, _ = strconv.Atoi(os.Getenv("UDP_READ_BUF_CONN")) + if size <= 64*1024 { + size = 64 * 1024 + } + } + for size >= 64*1024 { + if err := conn.SetReadBuffer(size); err == nil { + break + } + size = size - (64 * 1024) + } } // will try to connect with given endpoint @@ -617,7 +639,7 @@ func getc(client *rpc2.Client) *Connection { if ci, found := client.State.Get("c"); found { return ci.(*Connection) } else { - panic("no connection attached") + //panic("no connection attached") // automatically handled by higher layers return nil } }