github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/node/replications.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package node 4 5 type replications struct { 6 TotalNodesInZone uint32 // not count replicated nodes, just one of them count. 7 Zones []replication // order by near to far to local node. First replication is the replication that node belong to it. 8 OrderedZones []replication // order by nodes replicationID 9 } 10 11 // GetZoneBy returns the node have desire index in best replication. 12 func (n *Nodes) GetZoneBy(recordID [32]byte) (rep *Node) { 13 // var nodeID uint32 = c.FindNodeIDByRecordID(recordID) 14 15 // var i uint8 16 // // Maybe closest Ganjine node not response recently, so check all replications 17 // for i = 0; i < c.Replications.TotalZones; i++ { 18 // if c.Replications[i].Nodes[nodeID].Conn.State == achaemenid.ConnectionState_Open { 19 // return &c.Replications[i].Nodes[nodeID] 20 // } 21 // } 22 23 return 24 } 25 26 // GetNodeByReplicationID returns the node in desire replication. 27 func (n *Nodes) GetNodeByReplicationID(repID uint8, nodeLoc uint32) (node *Node) { 28 return &c.Replications.OrderedZones[repID].Nodes[nodeLoc] 29 } 30 31 // orderZones order Zones by near to far! 32 func (n *Nodes) orderZones() { 33 // TODO::: 34 // Block this goroutine until replications lock change to unlock! 35 // First replication is the replication that node belong to it 36 }