DERO Homomorphic Encryption Testnet Release7
This commit is contained in:
parent
531269103e
commit
0d393224ec
@ -20,4 +20,4 @@ import "github.com/blang/semver"
|
||||
|
||||
// right now it has to be manually changed
|
||||
// do we need to include git commitsha??
|
||||
var Version = semver.MustParse("3.0.0-23.DEROHE.alpha+27122020")
|
||||
var Version = semver.MustParse("3.0.0-24.DEROHE.alpha+30122020")
|
||||
|
@ -74,7 +74,7 @@ func (connection *Connection) Handle_ChainResponse(buf []byte) {
|
||||
// we do not need reorganisation if deviation is less than or equak to 7 blocks
|
||||
// only pop blocks if the system has somehow deviated more than 7 blocks
|
||||
// if the deviation is less than 7 blocks, we internally reorganise everything
|
||||
if chain.Load_TOPO_HEIGHT()-response.Start_topoheight >= config.STABLE_LIMIT && connection.SyncNode {
|
||||
if chain.Get_Height() -response.Start_height > config.STABLE_LIMIT && connection.SyncNode {
|
||||
// get our top block
|
||||
rlog.Infof("rewinding status our %d peer %d", chain.Load_TOPO_HEIGHT(), response.Start_topoheight)
|
||||
pop_count := chain.Load_TOPO_HEIGHT() - response.Start_topoheight
|
||||
@ -84,6 +84,11 @@ func (connection *Connection) Handle_ChainResponse(buf []byte) {
|
||||
connection.Send_ChainRequest()
|
||||
return
|
||||
|
||||
}else if chain.Get_Height()-response.Start_height <= config.STABLE_LIMIT {
|
||||
pop_count := chain.Load_TOPO_HEIGHT() - response.Start_topoheight
|
||||
chain.Rewind_Chain(int(pop_count)) // pop as many blocks as necessary, assumming peer has given us good chain
|
||||
}else{ // we must somehow notify that deviation is way too much and manual interaction is necessary, so as any bug for chain deviationmay be detected
|
||||
|
||||
}
|
||||
|
||||
// response only 128 blocks at a time
|
||||
@ -93,7 +98,8 @@ func (connection *Connection) Handle_ChainResponse(buf []byte) {
|
||||
|
||||
rlog.Infof("response block list %d\n", len(response.Block_list))
|
||||
for i := range response.Block_list {
|
||||
if chain.Load_Block_Topological_order(response.Block_list[i]) == -1 { // if block is not in our chain, add it to request list
|
||||
our_topo_order := chain.Load_Block_Topological_order(response.Block_list[i])
|
||||
if our_topo_order != (int64(i)+ response.Start_topoheight) || chain.Load_Block_Topological_order(response.Block_list[i]) == -1 { // if block is not in our chain, add it to request list
|
||||
//queue_block(request.Block_list[i])
|
||||
if max_blocks_to_queue >= 0 {
|
||||
max_blocks_to_queue--
|
||||
|
@ -18,7 +18,7 @@ package p2p
|
||||
|
||||
//import "fmt"
|
||||
//import "net"
|
||||
//import "sync"
|
||||
import "sync/atomic"
|
||||
import "time"
|
||||
|
||||
import "encoding/binary"
|
||||
@ -179,6 +179,24 @@ func (connection *Connection) Handle_Notification_Block(buf []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
// make sure connection does not timeout and be killed while processing huge blocks
|
||||
processing_complete := make(chan bool)
|
||||
go func() {
|
||||
ticker := time.NewTicker(500 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <- processing_complete: return // complete the loop
|
||||
case <-ticker.C:// give the chain some more time to respond
|
||||
atomic.StoreInt64(&connection.LastObjectRequestTime, time.Now().Unix())
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
processing_complete <- true
|
||||
}()
|
||||
|
||||
// check if we can add ourselves to chain
|
||||
if err, ok := chain.Add_Complete_Block(&cbl); ok { // if block addition was successfil
|
||||
// notify all peers
|
||||
|
@ -69,6 +69,25 @@ func (connection *Connection) Handle_ObjectResponse(buf []byte) {
|
||||
rlog.Warnf("we got %d response for %d requests %s %s", len(response.CBlocks), len(expected.BLID), connection.logid)
|
||||
}
|
||||
|
||||
// make sure connection does not timeout and be killed while processing huge blocks
|
||||
processing_complete := make(chan bool)
|
||||
go func() {
|
||||
ticker := time.NewTicker(500 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <- processing_complete: return // complete the loop
|
||||
case <-ticker.C:// give the chain some more time to respond
|
||||
atomic.StoreInt64(&connection.LastObjectRequestTime, time.Now().Unix())
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
processing_complete <- true
|
||||
}()
|
||||
|
||||
|
||||
for i := 0; i < len(response.CBlocks); i++ { // process incoming full blocks
|
||||
var cbl block.Complete_Block // parse incoming block and deserialize it
|
||||
var bl block.Block
|
||||
|
Loading…
x
Reference in New Issue
Block a user