diff --git a/pkgs/constants.go b/pkgs/constants.go index e2a9238..9854686 100644 --- a/pkgs/constants.go +++ b/pkgs/constants.go @@ -1,8 +1,10 @@ package pkgs const ( - CurrentEpoch = "CurrentEpoch" - CurrentBatchId = "CurrentBatchId" - EpochsInADay = "EpochsInADay" - SlotCounter = "SlotCounter" + CurrentEpoch = "CurrentEpoch" + CurrentBatchId = "CurrentBatchId" + EpochsInADay = "EpochsInADay" + SlotCounter = "SlotCounter" + EPOCH_SIZE = "EPOCH_SIZE" + SOURCE_CHAIN_BLOCK_TIME = "SOURCE_CHAIN_BLOCK_TIME" ) diff --git a/pkgs/prost/contract.go b/pkgs/prost/contract.go index 7850109..73151e8 100644 --- a/pkgs/prost/contract.go +++ b/pkgs/prost/contract.go @@ -18,6 +18,7 @@ import ( listenerCommon "protocol-state-cacher/pkgs/common" "protocol-state-cacher/pkgs/contract" "protocol-state-cacher/pkgs/redis" + "strconv" "sync" "time" ) @@ -71,7 +72,7 @@ func MustQuery[K any](ctx context.Context, call func(opts *bind.CallOpts) (val K func ColdSyncMappings() { for { coldSyncAllSlots() - time.Sleep(1 * time.Minute) + time.Sleep(60 * time.Minute) } } @@ -170,6 +171,16 @@ func PopulateStateVars() { key := redis.ContractStateVariable(pkgs.EpochsInADay) PersistState(context.Background(), key, output.String()) } + + if output, err := Instance.EPOCHSIZE(&bind.CallOpts{}, DataMarket); output != 0 && err == nil { + key := redis.ContractStateVariable(pkgs.EPOCH_SIZE) + PersistState(context.Background(), key, strconv.Itoa(int(output))) + } + + if output, err := Instance.SOURCECHAINBLOCKTIME(&bind.CallOpts{}, DataMarket); output != nil && err == nil { + key := redis.ContractStateVariable(pkgs.SOURCE_CHAIN_BLOCK_TIME) + PersistState(context.Background(), key, strconv.Itoa(int(output.Int64()))) + } } func PersistState(ctx context.Context, key string, val string) { diff --git a/protocol-state-cacher.iml b/protocol-state-cacher.iml new file mode 100644 index 0000000..8021953 --- /dev/null +++ b/protocol-state-cacher.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file