Skip to content

Commit

Permalink
adds RoundInterval to StoreData in client-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
bordalix committed Sep 2, 2024
1 parent e46f2ce commit 3d8d0e3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/client-sdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (a *arkClient) InitWithWallet(
ClientType: args.ClientType,
Network: network,
RoundLifetime: info.RoundLifetime,
RoundInterval: info.RoundInterval,
UnilateralExitDelay: info.UnilateralExitDelay,
MinRelayFee: uint64(info.MinRelayFee),
}
Expand Down Expand Up @@ -161,6 +162,7 @@ func (a *arkClient) Init(
ClientType: args.ClientType,
Network: network,
RoundLifetime: info.RoundLifetime,
RoundInterval: info.RoundInterval,
UnilateralExitDelay: info.UnilateralExitDelay,
MinRelayFee: uint64(info.MinRelayFee),
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/client-sdk/store/file/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type storeData struct {
ClientType string `json:"client_type"`
Network string `json:"network"`
RoundLifetime string `json:"round_lifetime"`
RoundInterval string `json:"round_interval"`
UnilateralExitDelay string `json:"unilateral_exit_delay"`
MinRelayFee string `json:"min_relay_fee"`
}
Expand All @@ -38,6 +39,7 @@ func (d storeData) isEmpty() bool {
func (d storeData) decode() store.StoreData {
network := utils.NetworkFromString(d.Network)
roundLifetime, _ := strconv.Atoi(d.RoundLifetime)
roundInterval, _ := strconv.Atoi(d.RoundInterval)
unilateralExitDelay, _ := strconv.Atoi(d.UnilateralExitDelay)
minRelayFee, _ := strconv.Atoi(d.MinRelayFee)
buf, _ := hex.DecodeString(d.AspPubkey)
Expand All @@ -49,6 +51,7 @@ func (d storeData) decode() store.StoreData {
ClientType: d.ClientType,
Network: network,
RoundLifetime: int64(roundLifetime),
RoundInterval: int64(roundInterval),
UnilateralExitDelay: int64(unilateralExitDelay),
MinRelayFee: uint64(minRelayFee),
}
Expand All @@ -62,6 +65,7 @@ func (d storeData) asMap() map[string]string {
"client_type": d.ClientType,
"network": d.Network,
"round_lifetime": d.RoundLifetime,
"round_interval": d.RoundInterval,
"unilateral_exit_delay": d.UnilateralExitDelay,
"min_relay_fee": d.MinRelayFee,
}
Expand Down Expand Up @@ -106,6 +110,7 @@ func (s *Store) AddData(ctx context.Context, data store.StoreData) error {
ClientType: data.ClientType,
Network: data.Network.Name,
RoundLifetime: fmt.Sprintf("%d", data.RoundLifetime),
RoundInterval: fmt.Sprintf("%d", data.RoundInterval),
UnilateralExitDelay: fmt.Sprintf("%d", data.UnilateralExitDelay),
MinRelayFee: fmt.Sprintf("%d", data.MinRelayFee),
}
Expand Down
1 change: 1 addition & 0 deletions pkg/client-sdk/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type StoreData struct {
ClientType string
Network common.Network
RoundLifetime int64
RoundInterval int64
UnilateralExitDelay int64
MinRelayFee uint64
}
Expand Down
1 change: 1 addition & 0 deletions pkg/client-sdk/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestStore(t *testing.T) {
ClientType: client.GrpcClient,
Network: common.LiquidRegTest,
RoundLifetime: 512,
RoundInterval: 10,
UnilateralExitDelay: 512,
MinRelayFee: 300,
}
Expand Down
1 change: 1 addition & 0 deletions pkg/client-sdk/wallet/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestWallet(t *testing.T) {
ClientType: client.GrpcClient,
Network: common.LiquidRegTest,
RoundLifetime: 512,
RoundInterval: 10,
UnilateralExitDelay: 512,
MinRelayFee: 300,
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/client-sdk/wasm/browser/config_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type storeData struct {
ExplorerURL string `json:"explorer_url"`
Network string `json:"network"`
RoundLifetime string `json:"round_lifetime"`
RoundInterval string `json:"round_interval"`
UnilateralExitDelay string `json:"unilateral_exit_delay"`
MinRelayFee string `json:"min_relay_fee"`
}
Expand Down Expand Up @@ -57,6 +58,7 @@ func (s *localStorageStore) AddData(ctx context.Context, data store.StoreData) e
ClientType: data.ClientType,
Network: data.Network.Name,
RoundLifetime: fmt.Sprintf("%d", data.RoundLifetime),
RoundInterval: fmt.Sprintf("%d", data.RoundInterval),
UnilateralExitDelay: fmt.Sprintf("%d", data.UnilateralExitDelay),
MinRelayFee: fmt.Sprintf("%d", data.MinRelayFee),
}
Expand All @@ -82,6 +84,7 @@ func (s *localStorageStore) GetData(ctx context.Context) (*store.StoreData, erro
}
network := utils.NetworkFromString(s.store.Call("getItem", "network").String())
roundLifetime, _ := strconv.Atoi(s.store.Call("getItem", "round_lifetime").String())
roundInterval, _ := strconv.Atoi(s.store.Call("getItem", "round_interval").String())
unilateralExitDelay, _ := strconv.Atoi(s.store.Call("getItem", "unilateral_exit_delay").String())
minRelayFee, _ := strconv.Atoi(s.store.Call("getItem", "min_relay_fee").String())

Expand All @@ -92,6 +95,7 @@ func (s *localStorageStore) GetData(ctx context.Context) (*store.StoreData, erro
ClientType: s.store.Call("getItem", "client_type").String(),
Network: network,
RoundLifetime: int64(roundLifetime),
RoundInterval: int64(roundInterval),
UnilateralExitDelay: int64(unilateralExitDelay),
MinRelayFee: uint64(minRelayFee),
}, nil
Expand Down

0 comments on commit 3d8d0e3

Please sign in to comment.