Skip to content

Commit

Permalink
Revert "Small changes (#51)"
Browse files Browse the repository at this point in the history
This reverts commit d3da9d4.
  • Loading branch information
VHPL-UIS authored Sep 16, 2023
1 parent d3da9d4 commit 23e7ee7
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 26 deletions.
1 change: 0 additions & 1 deletion config/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type baseOptions struct {
AddressChangeThreshold int `yaml:"AddressChangeThreshold"`
OriginatorShuffleProbability float32 `yaml:"OriginatorShuffleProbability"`
NonOriginatorShuffleProbability float32 `yaml:"NonOriginatorShuffleProbability"`
ShufflingPeriod int `yaml:"ShufflingPeriod"`
AddressRange int
StorageDepth int
}
Expand Down
1 change: 0 additions & 1 deletion config/default_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func getDefaultConfig() Config {
AddressChangeThreshold: 0, // non-positive means no limit
OriginatorShuffleProbability: 0.0, // 0.0
NonOriginatorShuffleProbability: 0.0, // 0.0
ShufflingPeriod: 0, // 0
ReplicationFactor: 4,
AdjustableThresholdExponent: 3,
OutputOptions: outputOptions{
Expand Down
4 changes: 0 additions & 4 deletions config/get_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ func GetNonOriginatorShuffleProbability() float32 {
return theconfig.BaseOptions.NonOriginatorShuffleProbability
}

func GetShufflingPeriod() int {
return theconfig.BaseOptions.ShufflingPeriod
}

func IsForgivenessEnabled() bool {
return theconfig.ExperimentOptions.ForgivenessEnabled
}
Expand Down
1 change: 0 additions & 1 deletion model/parts/types/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func (network *Network) node(nodeId NodeId) *Node {
RerouteMutex: &sync.Mutex{},
},
AdjLock: sync.RWMutex{},
CreationEpoch: 0,
}
if len(network.NodesMap) == 0 {
network.NodesMap = make(map[NodeId]*Node)
Expand Down
1 change: 0 additions & 1 deletion model/parts/types/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type Node struct {
PendingStruct PendingStruct
RerouteStruct RerouteStruct
AdjLock sync.RWMutex
CreationEpoch int
}

// Adds a one-way connection from node to other
Expand Down
4 changes: 1 addition & 3 deletions model/parts/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ func (s *State) GetOriginatorId(originatorIndex int) NodeId {
if node == nil {
panic("Node not found")
}
if node.CreationEpoch + config.GetShufflingPeriod() <= s.Epoch {

if node.OriginatorStruct.RequestCount > config.GetAddressChangeThreshold() {
newNode, err := s.Graph.NewNode()
if err != nil {
panic(err)
}
// The new node is not going to get requests
newNode.Deactivate()
newNode.CreationEpoch = s.Epoch
s.Originators[originatorIndex] = newNode.Id
}
}
Expand Down
18 changes: 10 additions & 8 deletions model/parts/update/update_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,28 @@ func Graph(state *types.State, requestResult types.RequestResult, curTimeStep in
edgeData1 := state.Graph.GetEdgeData(payment.FirstNodeId, payment.PayNextId)
edgeData2 := state.Graph.GetEdgeData(payment.PayNextId, payment.FirstNodeId)
price := utils.PeerPriceChunk(payment.PayNextId, payment.ChunkId)
actualPrice := price
actualPrice := edgeData1.A2B - edgeData2.A2B + price
if config.IsPayOnlyForCurrentRequest() {
actualPrice = price
}
if actualPrice < 0 {
continue
} else {
if !config.IsPayOnlyForCurrentRequest() {
actualPrice = edgeData1.A2B - edgeData2.A2B + price
newEdgeData1 := edgeData1
newEdgeData1.A2B = 0
state.Graph.SetEdgeData(payment.FirstNodeId, payment.PayNextId, newEdgeData1)

newEdgeData2 := edgeData2
newEdgeData2.A2B = 0
state.Graph.SetEdgeData(payment.PayNextId, payment.FirstNodeId, newEdgeData2)
} else {
// Important fix: Reduce debt here, since it debt will be added again below.
// Idea is, paying for the current request should not effect the edge balance.
newEdgeData1 := edgeData1
newEdgeData1.A2B = edgeData1.A2B - price
state.Graph.SetEdgeData(payment.FirstNodeId, payment.PayNextId, newEdgeData1)
}
// Important fix: Reduce debt here, since it debt will be added again below.
// Idea is, paying for the current request with or without the rest of debt
// should not effect the edge balance.
newEdgeData1 := edgeData1
newEdgeData1.A2B = edgeData1.A2B - price
state.Graph.SetEdgeData(payment.FirstNodeId, payment.PayNextId, newEdgeData1)
}
// fmt.Println("Payment from ", payment.FirstNodeId, " to ", payment.PayNextId, " for chunk ", payment.ChunkId, " with price ", actualPrice)
paymentWithPrice = types.PaymentWithPrice{Payment: payment, Price: actualPrice}
Expand Down
7 changes: 0 additions & 7 deletions model/parts/update/update_neighbors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ import (
)

func Neighbors(globalState *types.State) bool {
if config.GetShufflingPeriod() <= 0 {
return true
}
if globalState.Epoch%config.GetShufflingPeriod() != 0 {
return true
}

// Update neighbors with probability p
if config.GetOriginatorShuffleProbability() <= 0 && config.GetNonOriginatorShuffleProbability() <= 0 {
return true
Expand Down

0 comments on commit 23e7ee7

Please sign in to comment.