Neo OcLib
This commit is contained in:
@@ -138,6 +138,7 @@ func (o *PeerController) Valid() {
|
|||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
return
|
return
|
||||||
} else if l.Data != nil && l.ToPeer().Verify && (l.ToPeer().Relation == peer.MASTER || l.ToPeer().Relation == peer.PENDING_MASTER) {
|
} else if l.Data != nil && l.ToPeer().Verify && (l.ToPeer().Relation == peer.MASTER || l.ToPeer().Relation == peer.PENDING_MASTER) {
|
||||||
|
masterPeerID := l.ToPeer().PeerID
|
||||||
data := req.UpdateOne(map[string]interface{}{
|
data := req.UpdateOne(map[string]interface{}{
|
||||||
"verify": false,
|
"verify": false,
|
||||||
"relation": peer.MASTER,
|
"relation": peer.MASTER,
|
||||||
@@ -152,6 +153,12 @@ func (o *PeerController) Valid() {
|
|||||||
Payload: b,
|
Payload: b,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// This node is now a NANO of the confirmed master: stamp its libp2p PeerID on self.
|
||||||
|
if self, serr := oclib.GetMySelf(); serr == nil && self != nil {
|
||||||
|
oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.PEER), nil).UpdateOne(map[string]interface{}{
|
||||||
|
"master_id": masterPeerID,
|
||||||
|
}, self.GetID())
|
||||||
|
}
|
||||||
o.Data["json"] = data
|
o.Data["json"] = data
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
return
|
return
|
||||||
@@ -280,6 +287,7 @@ func (o *PeerController) changeRelation(id string, dest *peer.Peer, user string,
|
|||||||
if dest.Verify && relation == peer.PENDING_NANO {
|
if dest.Verify && relation == peer.PENDING_NANO {
|
||||||
relation = peer.NANO
|
relation = peer.NANO
|
||||||
}
|
}
|
||||||
|
wasMaster := dest.Relation == peer.MASTER
|
||||||
data := request.UpdateOne(map[string]interface{}{
|
data := request.UpdateOne(map[string]interface{}{
|
||||||
"relation": relation,
|
"relation": relation,
|
||||||
}, dest.GetID())
|
}, dest.GetID())
|
||||||
@@ -293,6 +301,14 @@ func (o *PeerController) changeRelation(id string, dest *peer.Peer, user string,
|
|||||||
Payload: b,
|
Payload: b,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// The peer was our master and is no longer — clear the MasterID on self.
|
||||||
|
if wasMaster {
|
||||||
|
if self, serr := oclib.GetMySelf(); serr == nil && self != nil {
|
||||||
|
oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.PEER), nil).UpdateOne(map[string]interface{}{
|
||||||
|
"master_id": "",
|
||||||
|
}, self.GetID())
|
||||||
|
}
|
||||||
|
}
|
||||||
if rRelation == peer.BLACKLIST {
|
if rRelation == peer.BLACKLIST {
|
||||||
request.UpdateOne(map[string]interface{}{
|
request.UpdateOne(map[string]interface{}{
|
||||||
"relation": rRelation,
|
"relation": rRelation,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module oc-peer
|
|||||||
go 1.25.0
|
go 1.25.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260429095623-9bb3d897b305
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260527135023-cef23b5f307b
|
||||||
github.com/beego/beego/v2 v2.3.8
|
github.com/beego/beego/v2 v2.3.8
|
||||||
github.com/smartystreets/goconvey v1.7.2
|
github.com/smartystreets/goconvey v1.7.2
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20260429050913-47d487ea8011 h1:owV5pQ+mS5xDC
|
|||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260429050913-47d487ea8011/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260429050913-47d487ea8011/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260429095623-9bb3d897b305 h1:1A6enYMMjK+2nFd187doD8LOMbnHxl+8EZRf6gqs8Yw=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260429095623-9bb3d897b305 h1:1A6enYMMjK+2nFd187doD8LOMbnHxl+8EZRf6gqs8Yw=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260429095623-9bb3d897b305/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260429095623-9bb3d897b305/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260527135023-cef23b5f307b h1:TWhmHeurbBmdyevREh4+mHWOBehO2AK587RCIjCfvOc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260527135023-cef23b5f307b/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
|
|||||||
Reference in New Issue
Block a user