Skip to content

Commit

Permalink
Rename functions
Browse files Browse the repository at this point in the history
  • Loading branch information
edfelten committed Feb 5, 2020
1 parent df19515 commit 1c5f3c1
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/arb-util/common/timeblocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func BlocksFromSeconds(seconds int64) *TimeBlocks {
}

func (tb *TimeBlocks) Duration() time.Duration {
return TimeFromBlockNum(tb).Duration()
return TicksFromBlockNum(tb).Duration()
}

func (tb *TimeBlocks) Cmp(tb2 *TimeBlocks) int {
Expand Down
4 changes: 2 additions & 2 deletions packages/arb-util/common/timeticks.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ type TimeTicks struct {
Val *big.Int
}

func TimeFromBlockNum(blockNum *TimeBlocks) TimeTicks {
func TicksFromBlockNum(blockNum *TimeBlocks) TimeTicks {
return TimeTicks{new(big.Int).Mul(big.NewInt(TicksPerBlock), blockNum.AsInt())}
}

func TimeFromSeconds(seconds int64) TimeTicks {
func TicksFromSeconds(seconds int64) TimeTicks {
return TimeTicks{big.NewInt(int64(time.Duration(seconds*TicksPerBlock) * time.Second / _durationPerBlock))}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/arb-validator/challenges/challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func getNextEventWithTimeout(
if err != nil {
return nil, 0, err
}
if common.TimeFromBlockNum(blockId.Height).Cmp(deadline) >= 0 {
if common.TicksFromBlockNum(blockId.Height).Cmp(deadline) >= 0 {
err := contract.TimeoutChallenge(ctx)
if err != nil {
return nil, 0, err
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-validator/challenges/testHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func testChallenge(
context.Background(),
client1.Address(),
client2.Address(),
common.TimeFromBlockNum(common.NewTimeBlocksInt(5)),
common.TicksFromBlockNum(common.NewTimeBlocksInt(5)),
challengeHash,
new(big.Int).SetUint64(uint64(challengeType)),
)
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-validator/rollup/chainParamsSetting.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func DefaultChainParams() structures.ChainParams {
gracePeriodInBlocks := int64(30)
return structures.ChainParams{
StakeRequirement: big.NewInt(10),
GracePeriod: common.TimeFromBlockNum(common.NewTimeBlocks(big.NewInt(gracePeriodInBlocks))),
GracePeriod: common.TicksFromBlockNum(common.NewTimeBlocks(big.NewInt(gracePeriodInBlocks))),
MaxExecutionSteps: 1000000000,
MaxTimeBoundsWidth: 20,
ArbGasSpeedLimitPerTick: 20000000,
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-validator/rollup/confirmThread.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (chain *ChainObserver) startConfirmThread(ctx context.Context) {
chain.RUnlock()
break
}
confValid, confInvalid := chain.nodeGraph.generateNextConfProof(common.TimeFromBlockNum(chain.latestBlockId.Height))
confValid, confInvalid := chain.nodeGraph.generateNextConfProof(common.TicksFromBlockNum(chain.latestBlockId.Height))
if confValid != nil {
for _, listener := range chain.listeners {
listener.ValidNodeConfirmable(ctx, chain, confValid)
Expand Down
6 changes: 3 additions & 3 deletions packages/arb-validator/rollup/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func NewNodeFromPrev(
assertionTxHash common.Hash,
) *Node {
checkTime := disputable.CheckTime(params)
deadlineTicks := common.TimeFromBlockNum(currentTime).Add(params.GracePeriod)
deadlineTicks := common.TicksFromBlockNum(currentTime).Add(params.GracePeriod)
if deadlineTicks.Cmp(prev.deadline) >= 0 {
deadlineTicks = deadlineTicks.Add(checkTime)
} else {
Expand Down Expand Up @@ -195,7 +195,7 @@ func (node *Node) ChallengeNodeData(params structures.ChainParams) (common.Hash,
node.disputable.MaxPendingTop,
pendingLeft,
)
challengePeriod := params.GracePeriod.Add(common.TimeFromBlockNum(common.NewTimeBlocks(big.NewInt(1))))
challengePeriod := params.GracePeriod.Add(common.TicksFromBlockNum(common.NewTimeBlocks(big.NewInt(1))))
return ret, challengePeriod
case structures.InvalidMessagesChildType:
ret := structures.MessageChallengeDataHash(
Expand All @@ -205,7 +205,7 @@ func (node *Node) ChallengeNodeData(params structures.ChainParams) (common.Hash,
node.disputable.AssertionClaim.ImportedMessagesSlice,
node.disputable.AssertionParams.ImportedMessageCount,
)
challengePeriod := params.GracePeriod.Add(common.TimeFromBlockNum(common.NewTimeBlocks(big.NewInt(1))))
challengePeriod := params.GracePeriod.Add(common.TicksFromBlockNum(common.NewTimeBlocks(big.NewInt(1))))
return ret, challengePeriod
case structures.InvalidExecutionChildType:
ret := structures.ExecutionDataHash(
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-validator/rollup/rollup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func setUpChain(rollupAddress common.Address, checkpointType string, contractPat
checkpointer,
structures.ChainParams{
StakeRequirement: big.NewInt(1),
GracePeriod: common.TimeFromSeconds(60 * 60),
GracePeriod: common.TicksFromSeconds(60 * 60),
MaxExecutionSteps: 1000000,
MaxTimeBoundsWidth: 20,
ArbGasSpeedLimitPerTick: 1000,
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-validator/rollup/stakedNodeGraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (chain *StakedNodeGraph) CreateStake(ev arbbridge.StakeCreatedEvent) {
chain.stakers.Add(&Staker{
ev.Staker,
node,
common.TimeFromBlockNum(ev.BlockId.Height),
common.TicksFromBlockNum(ev.BlockId.Height),
common.Address{},
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-validator/structures/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (cp ChainParams) WithGracePeriod(period common.TimeTicks) ChainParams {
}

func (cp ChainParams) WithGracePeriodBlocks(period common.TimeBlocks) ChainParams {
return cp.WithGracePeriod(common.TimeFromBlockNum(&period))
return cp.WithGracePeriod(common.TicksFromBlockNum(&period))
}

func (cp ChainParams) WithMaxExecutionSteps(steps uint64) ChainParams {
Expand Down

0 comments on commit 1c5f3c1

Please sign in to comment.