DERO Homomorphic Encryption Testnet Release7

This commit is contained in:
Captain 2020-12-30 04:39:59 +00:00
parent 531269103e
commit 0d393224ec
No known key found for this signature in database
GPG Key ID: 18CDB3ED5E85D2D4
4 changed files with 48 additions and 5 deletions

View File

@ -20,4 +20,4 @@ import "github.com/blang/semver"
// right now it has to be manually changed // right now it has to be manually changed
// do we need to include git commitsha?? // 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")

View File

@ -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 // 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 // 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 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 // get our top block
rlog.Infof("rewinding status our %d peer %d", chain.Load_TOPO_HEIGHT(), response.Start_topoheight) rlog.Infof("rewinding status our %d peer %d", chain.Load_TOPO_HEIGHT(), response.Start_topoheight)
pop_count := chain.Load_TOPO_HEIGHT() - response.Start_topoheight pop_count := chain.Load_TOPO_HEIGHT() - response.Start_topoheight
@ -84,7 +84,12 @@ func (connection *Connection) Handle_ChainResponse(buf []byte) {
connection.Send_ChainRequest() connection.Send_ChainRequest()
return 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 // response only 128 blocks at a time
max_blocks_to_queue := 128 max_blocks_to_queue := 128
@ -93,7 +98,8 @@ func (connection *Connection) Handle_ChainResponse(buf []byte) {
rlog.Infof("response block list %d\n", len(response.Block_list)) rlog.Infof("response block list %d\n", len(response.Block_list))
for i := range 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]) //queue_block(request.Block_list[i])
if max_blocks_to_queue >= 0 { if max_blocks_to_queue >= 0 {
max_blocks_to_queue-- max_blocks_to_queue--

View File

@ -18,7 +18,7 @@ package p2p
//import "fmt" //import "fmt"
//import "net" //import "net"
//import "sync" import "sync/atomic"
import "time" import "time"
import "encoding/binary" 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 // check if we can add ourselves to chain
if err, ok := chain.Add_Complete_Block(&cbl); ok { // if block addition was successfil if err, ok := chain.Add_Complete_Block(&cbl); ok { // if block addition was successfil
// notify all peers // notify all peers

View File

@ -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) 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 for i := 0; i < len(response.CBlocks); i++ { // process incoming full blocks
var cbl block.Complete_Block // parse incoming block and deserialize it var cbl block.Complete_Block // parse incoming block and deserialize it
var bl block.Block var bl block.Block