Skip to content

Commit

Permalink
feat: hook gateway simulator within client messages
Browse files Browse the repository at this point in the history
  • Loading branch information
xendarboh committed Sep 20, 2023
1 parent e5d55f7 commit 263e5f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"runtime"
"sync"

"github.com/simonlangowski/lightning1/cmd/xtrellis/gateway"
"github.com/simonlangowski/lightning1/config"
coord "github.com/simonlangowski/lightning1/coordinator/messages"
"github.com/simonlangowski/lightning1/crypto/token"
Expand Down Expand Up @@ -125,6 +126,12 @@ func (c *ClientRunner) ClientStart(_ context.Context, i *coord.RoundInfo) (*coor
}
m := make([]byte, i.MessageSize)
binary.LittleEndian.PutUint64(m, uint64(id))

// gateway simulation
if gateway.Enable {
m, _ = gateway.GetMessageForClient(i, id)
}

done <- cli.SendLightningMessage(c.Caller, cli.PathKeys, m)
}
}(id)
Expand Down
13 changes: 12 additions & 1 deletion coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"sync"
"time"

"github.com/simonlangowski/lightning1/cmd/xtrellis/gateway"
"github.com/simonlangowski/lightning1/cmd/xtrellis/utils"
"github.com/simonlangowski/lightning1/config"
coord "github.com/simonlangowski/lightning1/coordinator/messages"
"github.com/simonlangowski/lightning1/crypto"
Expand Down Expand Up @@ -145,6 +147,7 @@ func (c *Coordinator) DoAction(exp *Experiment) error {
return err
}
}
utils.DebugLog("exp.Info. PathEstablishment=%t; ReceiptLayer=%d; Round=%d", exp.Info.PathEstablishment, exp.Info.ReceiptLayer, exp.Info.Round)
if exp.Info.PathEstablishment {
if exp.Info.ReceiptLayer == 0 && exp.Info.Round != 0 {
err := c.Net.CheckClientReceipt(exp.Info, exp.NumMessages)
Expand Down Expand Up @@ -180,7 +183,15 @@ func (c *Coordinator) DoAction(exp *Experiment) error {
log.Printf("Get messages")
return err
}
exp.Passed = c.Check(messages, exp.NumMessages)

if gateway.Enable {
// give final messages to gateway and check them
exp.Passed = gateway.CheckFinalMessages(messages, exp.NumMessages)
utils.DebugLog("exp.Passed = gateway.CheckFinalMessages = %t", exp.Passed)
} else {
exp.Passed = c.Check(messages, exp.NumMessages)
}

}
endTime := time.Now()
exp.ServerRoundTime = endTime.Sub(roundStartTime)
Expand Down

0 comments on commit 263e5f9

Please sign in to comment.