Skip to content

Commit d212120

Browse files
committed
Push to GH & fixes
1 parent 2bcb38e commit d212120

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

.github/workflows/docker-build.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches:
66
- main
77

8+
permissions:
9+
contents: read
10+
packages: write
11+
812
jobs:
913
build:
1014
runs-on: ubuntu-latest
@@ -19,7 +23,10 @@ jobs:
1923
uses: docker/build-push-action@v5
2024
with:
2125
context: .
22-
push: false
23-
tags: transaction-latency:latest
26+
push: true
27+
tags: ghcr.io/${{ github.repository }}:latest
2428
cache-from: type=gha
25-
cache-to: type=gha,mode=max
29+
cache-to: type=gha,mode=max
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
# transaction-latency
2+
3+
docker build -t transaction-latency .
4+
docker run -v (pwd)/data:/data --env-file .env --rm -it transaction-latency

main.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020
)
2121

2222
type stats struct {
23-
SentAt time.Time
24-
TxnHash string
25-
IncludedInBlock uint64
26-
InclusionDelayMs time.Duration
23+
SentAt time.Time
24+
TxnHash string
25+
IncludedInBlock uint64
26+
InclusionDelay time.Duration
2727
}
2828

2929
func main() {
@@ -123,11 +123,11 @@ func main() {
123123
time.Sleep(time.Duration(rand.Float64() * float64(time.Second)))
124124
}
125125

126-
if err := writeToFile(fmt.Sprintf("flashblocks-%s.csv", region), flashblockTimings); err != nil {
126+
if err := writeToFile(fmt.Sprintf("/data/flashblocks-%s.csv", region), flashblockTimings); err != nil {
127127
log.Fatalf("Failed to write to file: %v", err)
128128
}
129129

130-
if err := writeToFile(fmt.Sprintf("base-%s.csv", region), baseTimings); err != nil {
130+
if err := writeToFile(fmt.Sprintf("/data/base-%s.csv", region), baseTimings); err != nil {
131131
log.Fatalf("Failed to write to file: %v", err)
132132
}
133133
}
@@ -152,7 +152,7 @@ func writeToFile(filename string, data []stats) error {
152152
d.SentAt.String(),
153153
d.TxnHash,
154154
strconv.FormatUint(d.IncludedInBlock, 10),
155-
strconv.FormatInt(d.InclusionDelayMs.Milliseconds(), 10),
155+
strconv.FormatInt(d.InclusionDelay.Milliseconds(), 10),
156156
}
157157
if err := writer.Write(row); err != nil {
158158
log.Fatalf("Failed to write to file: %v", err)
@@ -211,10 +211,10 @@ func timeTransaction(chainId *big.Int, privateKey *ecdsa.PrivateKey, fromAddress
211211
} else {
212212
now := time.Now()
213213
return stats{
214-
SentAt: sentAt,
215-
InclusionDelayMs: now.Sub(sentAt),
216-
TxnHash: tx.Hash().Hex(),
217-
IncludedInBlock: receipt.BlockNumber.Uint64(),
214+
SentAt: sentAt,
215+
InclusionDelay: now.Sub(sentAt),
216+
TxnHash: tx.Hash().Hex(),
217+
IncludedInBlock: receipt.BlockNumber.Uint64(),
218218
}, nil
219219
}
220220
}

0 commit comments

Comments
 (0)