Commit 7383d3dc authored by Adam Uhlíř's avatar Adam Uhlíř Committed by GitHub

fix: marshal bigint as string (#1735)

parent e1025971
...@@ -34,6 +34,11 @@ components: ...@@ -34,6 +34,11 @@ components:
pssPublicKey: pssPublicKey:
$ref: "#/components/schemas/PublicKey" $ref: "#/components/schemas/PublicKey"
BigInt:
description: Numeric string that represents integer which might exceeds `Number.MAX_SAFE_INTEGER` limit (2^53-1)
type: string
example: "1000000000000000000"
ReserveState: ReserveState:
type: object type: object
properties: properties:
...@@ -42,9 +47,9 @@ components: ...@@ -42,9 +47,9 @@ components:
available: available:
type: integer type: integer
outer: outer:
type: integer $ref: "#/components/schemas/BigInt"
inner: inner:
type: integer $ref: "#/components/schemas/BigInt"
ChainState: ChainState:
type: object type: object
...@@ -62,7 +67,7 @@ components: ...@@ -62,7 +67,7 @@ components:
peer: peer:
$ref: "#/components/schemas/SwarmAddress" $ref: "#/components/schemas/SwarmAddress"
balance: balance:
type: integer $ref: "#/components/schemas/BigInt"
Balances: Balances:
type: object type: object
...@@ -109,7 +114,7 @@ components: ...@@ -109,7 +114,7 @@ components:
chequebook: chequebook:
$ref: "#/components/schemas/EthereumAddress" $ref: "#/components/schemas/EthereumAddress"
payout: payout:
type: integer $ref: "#/components/schemas/BigInt"
ChequeAllPeersResponse: ChequeAllPeersResponse:
type: object type: object
...@@ -134,9 +139,9 @@ components: ...@@ -134,9 +139,9 @@ components:
type: object type: object
properties: properties:
totalBalance: totalBalance:
type: integer $ref: "#/components/schemas/BigInt"
availableBalance: availableBalance:
type: integer $ref: "#/components/schemas/BigInt"
ChequebookAddress: ChequebookAddress:
type: object type: object
...@@ -159,7 +164,7 @@ components: ...@@ -159,7 +164,7 @@ components:
type: string type: string
pattern: "^[A-Fa-f0-9]{40}$" pattern: "^[A-Fa-f0-9]{40}$"
example: "36b7efd913ca4cf880b8eeac5093fa27b0825906" example: "36b7efd913ca4cf880b8eeac5093fa27b0825906"
FileName: FileName:
type: string type: string
...@@ -388,7 +393,7 @@ components: ...@@ -388,7 +393,7 @@ components:
recipient: recipient:
$ref: "#/components/schemas/EthereumAddress" $ref: "#/components/schemas/EthereumAddress"
lastPayout: lastPayout:
type: integer $ref: "#/components/schemas/BigInt"
bounced: bounced:
type: boolean type: boolean
...@@ -404,7 +409,7 @@ components: ...@@ -404,7 +409,7 @@ components:
result: result:
$ref: "#/components/schemas/SwapCashoutResult" $ref: "#/components/schemas/SwapCashoutResult"
uncashedAmount: uncashedAmount:
type: integer $ref: "#/components/schemas/BigInt"
TagName: TagName:
type: string type: string
......
// Copyright 2021 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package bigint
import (
"encoding/json"
"fmt"
"math/big"
)
type BigInt struct {
*big.Int
}
func (i *BigInt) MarshalJSON() ([]byte, error) {
if i.Int == nil {
return []byte("null"), nil
}
return []byte(fmt.Sprintf(`"%s"`, i.String())), nil
}
func (i *BigInt) UnmarshalJSON(b []byte) error {
var val string
err := json.Unmarshal(b, &val)
if err != nil {
return err
}
if i.Int == nil {
i.Int = new(big.Int)
}
i.SetString(val, 10)
return nil
}
//Wrap wraps big.Int pointer into BigInt struct.
func Wrap(i *big.Int) *BigInt {
return &BigInt{Int: i}
}
// Copyright 2021 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package bigint_test
import (
"encoding/json"
"github.com/ethersphere/bee/pkg/bigint"
"math"
"math/big"
"reflect"
"testing"
)
func TestMarshaling(t *testing.T) {
mar, err := json.Marshal(struct {
Bg *bigint.BigInt
}{
Bg: bigint.Wrap(new(big.Int).Mul(big.NewInt(math.MaxInt64), big.NewInt(math.MaxInt64))),
})
if err != nil {
t.Errorf("Marshaling failed: %v", err)
}
if !reflect.DeepEqual(mar, []byte("{\"Bg\":\"85070591730234615847396907784232501249\"}")) {
t.Errorf("Wrongly marshaled data")
}
}
...@@ -6,10 +6,10 @@ package debugapi ...@@ -6,10 +6,10 @@ package debugapi
import ( import (
"errors" "errors"
"math/big"
"net/http" "net/http"
"github.com/ethersphere/bee/pkg/accounting" "github.com/ethersphere/bee/pkg/accounting"
"github.com/ethersphere/bee/pkg/bigint"
"github.com/ethersphere/bee/pkg/jsonhttp" "github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/swarm" "github.com/ethersphere/bee/pkg/swarm"
"github.com/gorilla/mux" "github.com/gorilla/mux"
...@@ -23,8 +23,8 @@ var ( ...@@ -23,8 +23,8 @@ var (
) )
type balanceResponse struct { type balanceResponse struct {
Peer string `json:"peer"` Peer string `json:"peer"`
Balance *big.Int `json:"balance"` Balance *bigint.BigInt `json:"balance"`
} }
type balancesResponse struct { type balancesResponse struct {
...@@ -45,7 +45,7 @@ func (s *Service) balancesHandler(w http.ResponseWriter, r *http.Request) { ...@@ -45,7 +45,7 @@ func (s *Service) balancesHandler(w http.ResponseWriter, r *http.Request) {
for k := range balances { for k := range balances {
balResponses[i] = balanceResponse{ balResponses[i] = balanceResponse{
Peer: k, Peer: k,
Balance: balances[k], Balance: bigint.Wrap(balances[k]),
} }
i++ i++
} }
...@@ -77,7 +77,7 @@ func (s *Service) peerBalanceHandler(w http.ResponseWriter, r *http.Request) { ...@@ -77,7 +77,7 @@ func (s *Service) peerBalanceHandler(w http.ResponseWriter, r *http.Request) {
jsonhttp.OK(w, balanceResponse{ jsonhttp.OK(w, balanceResponse{
Peer: peer.String(), Peer: peer.String(),
Balance: balance, Balance: bigint.Wrap(balance),
}) })
} }
...@@ -95,7 +95,7 @@ func (s *Service) compensatedBalancesHandler(w http.ResponseWriter, r *http.Requ ...@@ -95,7 +95,7 @@ func (s *Service) compensatedBalancesHandler(w http.ResponseWriter, r *http.Requ
for k := range balances { for k := range balances {
balResponses[i] = balanceResponse{ balResponses[i] = balanceResponse{
Peer: k, Peer: k,
Balance: balances[k], Balance: bigint.Wrap(balances[k]),
} }
i++ i++
} }
...@@ -127,6 +127,6 @@ func (s *Service) compensatedPeerBalanceHandler(w http.ResponseWriter, r *http.R ...@@ -127,6 +127,6 @@ func (s *Service) compensatedPeerBalanceHandler(w http.ResponseWriter, r *http.R
jsonhttp.OK(w, balanceResponse{ jsonhttp.OK(w, balanceResponse{
Peer: peer.String(), Peer: peer.String(),
Balance: balance, Balance: bigint.Wrap(balance),
}) })
} }
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
"github.com/ethersphere/bee/pkg/accounting" "github.com/ethersphere/bee/pkg/accounting"
"github.com/ethersphere/bee/pkg/accounting/mock" "github.com/ethersphere/bee/pkg/accounting/mock"
"github.com/ethersphere/bee/pkg/bigint"
"github.com/ethersphere/bee/pkg/debugapi" "github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/jsonhttp" "github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
...@@ -35,15 +36,15 @@ func TestBalances(t *testing.T) { ...@@ -35,15 +36,15 @@ func TestBalances(t *testing.T) {
[]debugapi.BalanceResponse{ []debugapi.BalanceResponse{
{ {
Peer: "DEAD", Peer: "DEAD",
Balance: big.NewInt(1000000000000000000), Balance: bigint.Wrap(big.NewInt(1000000000000000000)),
}, },
{ {
Peer: "BEEF", Peer: "BEEF",
Balance: big.NewInt(-100000000000000000), Balance: bigint.Wrap(big.NewInt(-100000000000000000)),
}, },
{ {
Peer: "PARTY", Peer: "PARTY",
Balance: big.NewInt(0), Balance: bigint.Wrap(big.NewInt(0)),
}, },
}, },
} }
...@@ -89,7 +90,7 @@ func TestBalancesPeers(t *testing.T) { ...@@ -89,7 +90,7 @@ func TestBalancesPeers(t *testing.T) {
jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/balances/"+peer, http.StatusOK, jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/balances/"+peer, http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.BalanceResponse{ jsonhttptest.WithExpectedJSONResponse(debugapi.BalanceResponse{
Peer: peer, Peer: peer,
Balance: big.NewInt(100000000000000000), Balance: bigint.Wrap(big.NewInt(100000000000000000)),
}), }),
) )
} }
...@@ -188,15 +189,15 @@ func TestConsumedBalances(t *testing.T) { ...@@ -188,15 +189,15 @@ func TestConsumedBalances(t *testing.T) {
[]debugapi.BalanceResponse{ []debugapi.BalanceResponse{
{ {
Peer: "DEAD", Peer: "DEAD",
Balance: big.NewInt(1000000000000000000), Balance: bigint.Wrap(big.NewInt(1000000000000000000)),
}, },
{ {
Peer: "BEEF", Peer: "BEEF",
Balance: big.NewInt(-100000000000000000), Balance: bigint.Wrap(big.NewInt(-100000000000000000)),
}, },
{ {
Peer: "PARTY", Peer: "PARTY",
Balance: big.NewInt(0), Balance: bigint.Wrap(big.NewInt(0)),
}, },
}, },
} }
...@@ -242,7 +243,7 @@ func TestConsumedPeers(t *testing.T) { ...@@ -242,7 +243,7 @@ func TestConsumedPeers(t *testing.T) {
jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/consumed/"+peer, http.StatusOK, jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/consumed/"+peer, http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.BalanceResponse{ jsonhttptest.WithExpectedJSONResponse(debugapi.BalanceResponse{
Peer: peer, Peer: peer,
Balance: big.NewInt(1000000000000000000), Balance: bigint.Wrap(big.NewInt(1000000000000000000)),
}), }),
) )
} }
......
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"strconv" "strconv"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/pkg/bigint"
"github.com/ethersphere/bee/pkg/jsonhttp" "github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/sctx" "github.com/ethersphere/bee/pkg/sctx"
"github.com/ethersphere/bee/pkg/settlement/swap/chequebook" "github.com/ethersphere/bee/pkg/settlement/swap/chequebook"
...@@ -39,8 +40,8 @@ var ( ...@@ -39,8 +40,8 @@ var (
) )
type chequebookBalanceResponse struct { type chequebookBalanceResponse struct {
TotalBalance *big.Int `json:"totalBalance"` TotalBalance *bigint.BigInt `json:"totalBalance"`
AvailableBalance *big.Int `json:"availableBalance"` AvailableBalance *bigint.BigInt `json:"availableBalance"`
} }
type chequebookAddressResponse struct { type chequebookAddressResponse struct {
...@@ -48,9 +49,9 @@ type chequebookAddressResponse struct { ...@@ -48,9 +49,9 @@ type chequebookAddressResponse struct {
} }
type chequebookLastChequePeerResponse struct { type chequebookLastChequePeerResponse struct {
Beneficiary string `json:"beneficiary"` Beneficiary string `json:"beneficiary"`
Chequebook string `json:"chequebook"` Chequebook string `json:"chequebook"`
Payout *big.Int `json:"payout"` Payout *bigint.BigInt `json:"payout"`
} }
type chequebookLastChequesPeerResponse struct { type chequebookLastChequesPeerResponse struct {
...@@ -80,7 +81,7 @@ func (s *Service) chequebookBalanceHandler(w http.ResponseWriter, r *http.Reques ...@@ -80,7 +81,7 @@ func (s *Service) chequebookBalanceHandler(w http.ResponseWriter, r *http.Reques
return return
} }
jsonhttp.OK(w, chequebookBalanceResponse{TotalBalance: balance, AvailableBalance: availableBalance}) jsonhttp.OK(w, chequebookBalanceResponse{TotalBalance: bigint.Wrap(balance), AvailableBalance: bigint.Wrap(availableBalance)})
} }
func (s *Service) chequebookAddressHandler(w http.ResponseWriter, r *http.Request) { func (s *Service) chequebookAddressHandler(w http.ResponseWriter, r *http.Request) {
...@@ -110,7 +111,7 @@ func (s *Service) chequebookLastPeerHandler(w http.ResponseWriter, r *http.Reque ...@@ -110,7 +111,7 @@ func (s *Service) chequebookLastPeerHandler(w http.ResponseWriter, r *http.Reque
lastSentResponse = &chequebookLastChequePeerResponse{ lastSentResponse = &chequebookLastChequePeerResponse{
Beneficiary: lastSent.Cheque.Beneficiary.String(), Beneficiary: lastSent.Cheque.Beneficiary.String(),
Chequebook: lastSent.Cheque.Chequebook.String(), Chequebook: lastSent.Cheque.Chequebook.String(),
Payout: lastSent.Cheque.CumulativePayout, Payout: bigint.Wrap(lastSent.Cheque.CumulativePayout),
} }
} }
...@@ -126,7 +127,7 @@ func (s *Service) chequebookLastPeerHandler(w http.ResponseWriter, r *http.Reque ...@@ -126,7 +127,7 @@ func (s *Service) chequebookLastPeerHandler(w http.ResponseWriter, r *http.Reque
lastReceivedResponse = &chequebookLastChequePeerResponse{ lastReceivedResponse = &chequebookLastChequePeerResponse{
Beneficiary: lastReceived.Cheque.Beneficiary.String(), Beneficiary: lastReceived.Cheque.Beneficiary.String(),
Chequebook: lastReceived.Cheque.Chequebook.String(), Chequebook: lastReceived.Cheque.Chequebook.String(),
Payout: lastReceived.Cheque.CumulativePayout, Payout: bigint.Wrap(lastReceived.Cheque.CumulativePayout),
} }
} }
...@@ -160,7 +161,7 @@ func (s *Service) chequebookAllLastHandler(w http.ResponseWriter, r *http.Reques ...@@ -160,7 +161,7 @@ func (s *Service) chequebookAllLastHandler(w http.ResponseWriter, r *http.Reques
LastSent: &chequebookLastChequePeerResponse{ LastSent: &chequebookLastChequePeerResponse{
Beneficiary: j.Cheque.Beneficiary.String(), Beneficiary: j.Cheque.Beneficiary.String(),
Chequebook: j.Cheque.Chequebook.String(), Chequebook: j.Cheque.Chequebook.String(),
Payout: j.Cheque.CumulativePayout, Payout: bigint.Wrap(j.Cheque.CumulativePayout),
}, },
LastReceived: nil, LastReceived: nil,
} }
...@@ -171,7 +172,7 @@ func (s *Service) chequebookAllLastHandler(w http.ResponseWriter, r *http.Reques ...@@ -171,7 +172,7 @@ func (s *Service) chequebookAllLastHandler(w http.ResponseWriter, r *http.Reques
t.LastReceived = &chequebookLastChequePeerResponse{ t.LastReceived = &chequebookLastChequePeerResponse{
Beneficiary: j.Cheque.Beneficiary.String(), Beneficiary: j.Cheque.Beneficiary.String(),
Chequebook: j.Cheque.Chequebook.String(), Chequebook: j.Cheque.Chequebook.String(),
Payout: j.Cheque.CumulativePayout, Payout: bigint.Wrap(j.Cheque.CumulativePayout),
} }
lcr[i] = t lcr[i] = t
} else { } else {
...@@ -181,7 +182,7 @@ func (s *Service) chequebookAllLastHandler(w http.ResponseWriter, r *http.Reques ...@@ -181,7 +182,7 @@ func (s *Service) chequebookAllLastHandler(w http.ResponseWriter, r *http.Reques
LastReceived: &chequebookLastChequePeerResponse{ LastReceived: &chequebookLastChequePeerResponse{
Beneficiary: j.Cheque.Beneficiary.String(), Beneficiary: j.Cheque.Beneficiary.String(),
Chequebook: j.Cheque.Chequebook.String(), Chequebook: j.Cheque.Chequebook.String(),
Payout: j.Cheque.CumulativePayout, Payout: bigint.Wrap(j.Cheque.CumulativePayout),
}, },
} }
} }
...@@ -246,7 +247,7 @@ func (s *Service) swapCashoutHandler(w http.ResponseWriter, r *http.Request) { ...@@ -246,7 +247,7 @@ func (s *Service) swapCashoutHandler(w http.ResponseWriter, r *http.Request) {
type swapCashoutStatusResult struct { type swapCashoutStatusResult struct {
Recipient common.Address `json:"recipient"` Recipient common.Address `json:"recipient"`
LastPayout *big.Int `json:"lastPayout"` LastPayout *bigint.BigInt `json:"lastPayout"`
Bounced bool `json:"bounced"` Bounced bool `json:"bounced"`
} }
...@@ -255,7 +256,7 @@ type swapCashoutStatusResponse struct { ...@@ -255,7 +256,7 @@ type swapCashoutStatusResponse struct {
Cheque *chequebookLastChequePeerResponse `json:"lastCashedCheque"` Cheque *chequebookLastChequePeerResponse `json:"lastCashedCheque"`
TransactionHash *common.Hash `json:"transactionHash"` TransactionHash *common.Hash `json:"transactionHash"`
Result *swapCashoutStatusResult `json:"result"` Result *swapCashoutStatusResult `json:"result"`
UncashedAmount *big.Int `json:"uncashedAmount"` UncashedAmount *bigint.BigInt `json:"uncashedAmount"`
} }
func (s *Service) swapCashoutStatusHandler(w http.ResponseWriter, r *http.Request) { func (s *Service) swapCashoutStatusHandler(w http.ResponseWriter, r *http.Request) {
...@@ -295,13 +296,13 @@ func (s *Service) swapCashoutStatusHandler(w http.ResponseWriter, r *http.Reques ...@@ -295,13 +296,13 @@ func (s *Service) swapCashoutStatusHandler(w http.ResponseWriter, r *http.Reques
if status.Last.Result != nil { if status.Last.Result != nil {
result = &swapCashoutStatusResult{ result = &swapCashoutStatusResult{
Recipient: status.Last.Result.Recipient, Recipient: status.Last.Result.Recipient,
LastPayout: status.Last.Result.TotalPayout, LastPayout: bigint.Wrap(status.Last.Result.TotalPayout),
Bounced: status.Last.Result.Bounced, Bounced: status.Last.Result.Bounced,
} }
} }
chequeResponse = &chequebookLastChequePeerResponse{ chequeResponse = &chequebookLastChequePeerResponse{
Chequebook: status.Last.Cheque.Chequebook.String(), Chequebook: status.Last.Cheque.Chequebook.String(),
Payout: status.Last.Cheque.CumulativePayout, Payout: bigint.Wrap(status.Last.Cheque.CumulativePayout),
Beneficiary: status.Last.Cheque.Beneficiary.String(), Beneficiary: status.Last.Cheque.Beneficiary.String(),
} }
txHash = &status.Last.TxHash txHash = &status.Last.TxHash
...@@ -312,7 +313,7 @@ func (s *Service) swapCashoutStatusHandler(w http.ResponseWriter, r *http.Reques ...@@ -312,7 +313,7 @@ func (s *Service) swapCashoutStatusHandler(w http.ResponseWriter, r *http.Reques
TransactionHash: txHash, TransactionHash: txHash,
Cheque: chequeResponse, Cheque: chequeResponse,
Result: result, Result: result,
UncashedAmount: status.UncashedAmount, UncashedAmount: bigint.Wrap(status.UncashedAmount),
}) })
} }
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
"testing" "testing"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/pkg/bigint"
"github.com/ethersphere/bee/pkg/debugapi" "github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/jsonhttp" "github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
...@@ -44,8 +45,8 @@ func TestChequebookBalance(t *testing.T) { ...@@ -44,8 +45,8 @@ func TestChequebookBalance(t *testing.T) {
}) })
expected := &debugapi.ChequebookBalanceResponse{ expected := &debugapi.ChequebookBalanceResponse{
TotalBalance: returnedBalance, TotalBalance: bigint.Wrap(returnedBalance),
AvailableBalance: returnedAvailableBalance, AvailableBalance: bigint.Wrap(returnedAvailableBalance),
} }
var got *debugapi.ChequebookBalanceResponse var got *debugapi.ChequebookBalanceResponse
...@@ -339,12 +340,12 @@ func TestChequebookLastCheques(t *testing.T) { ...@@ -339,12 +340,12 @@ func TestChequebookLastCheques(t *testing.T) {
LastReceived: &debugapi.ChequebookLastChequePeerResponse{ LastReceived: &debugapi.ChequebookLastChequePeerResponse{
Beneficiary: beneficiary.String(), Beneficiary: beneficiary.String(),
Chequebook: chequebookAddress1.String(), Chequebook: chequebookAddress1.String(),
Payout: cumulativePayout4, Payout: bigint.Wrap(cumulativePayout4),
}, },
LastSent: &debugapi.ChequebookLastChequePeerResponse{ LastSent: &debugapi.ChequebookLastChequePeerResponse{
Beneficiary: beneficiary1.String(), Beneficiary: beneficiary1.String(),
Chequebook: chequebookAddress1.String(), Chequebook: chequebookAddress1.String(),
Payout: cumulativePayout1, Payout: bigint.Wrap(cumulativePayout1),
}, },
}, },
{ {
...@@ -353,7 +354,7 @@ func TestChequebookLastCheques(t *testing.T) { ...@@ -353,7 +354,7 @@ func TestChequebookLastCheques(t *testing.T) {
LastSent: &debugapi.ChequebookLastChequePeerResponse{ LastSent: &debugapi.ChequebookLastChequePeerResponse{
Beneficiary: beneficiary2.String(), Beneficiary: beneficiary2.String(),
Chequebook: chequebookAddress2.String(), Chequebook: chequebookAddress2.String(),
Payout: cumulativePayout2, Payout: bigint.Wrap(cumulativePayout2),
}, },
}, },
{ {
...@@ -362,7 +363,7 @@ func TestChequebookLastCheques(t *testing.T) { ...@@ -362,7 +363,7 @@ func TestChequebookLastCheques(t *testing.T) {
LastSent: &debugapi.ChequebookLastChequePeerResponse{ LastSent: &debugapi.ChequebookLastChequePeerResponse{
Beneficiary: beneficiary3.String(), Beneficiary: beneficiary3.String(),
Chequebook: chequebookAddress3.String(), Chequebook: chequebookAddress3.String(),
Payout: cumulativePayout3, Payout: bigint.Wrap(cumulativePayout3),
}, },
}, },
{ {
...@@ -370,7 +371,7 @@ func TestChequebookLastCheques(t *testing.T) { ...@@ -370,7 +371,7 @@ func TestChequebookLastCheques(t *testing.T) {
LastReceived: &debugapi.ChequebookLastChequePeerResponse{ LastReceived: &debugapi.ChequebookLastChequePeerResponse{
Beneficiary: beneficiary.String(), Beneficiary: beneficiary.String(),
Chequebook: chequebookAddress4.String(), Chequebook: chequebookAddress4.String(),
Payout: cumulativePayout5, Payout: bigint.Wrap(cumulativePayout5),
}, },
LastSent: nil, LastSent: nil,
}, },
...@@ -379,7 +380,7 @@ func TestChequebookLastCheques(t *testing.T) { ...@@ -379,7 +380,7 @@ func TestChequebookLastCheques(t *testing.T) {
LastReceived: &debugapi.ChequebookLastChequePeerResponse{ LastReceived: &debugapi.ChequebookLastChequePeerResponse{
Beneficiary: beneficiary.String(), Beneficiary: beneficiary.String(),
Chequebook: chequebookAddress5.String(), Chequebook: chequebookAddress5.String(),
Payout: cumulativePayout6, Payout: bigint.Wrap(cumulativePayout6),
}, },
LastSent: nil, LastSent: nil,
}, },
...@@ -450,12 +451,12 @@ func TestChequebookLastChequesPeer(t *testing.T) { ...@@ -450,12 +451,12 @@ func TestChequebookLastChequesPeer(t *testing.T) {
LastReceived: &debugapi.ChequebookLastChequePeerResponse{ LastReceived: &debugapi.ChequebookLastChequePeerResponse{
Beneficiary: beneficiary0.String(), Beneficiary: beneficiary0.String(),
Chequebook: chequebookAddress.String(), Chequebook: chequebookAddress.String(),
Payout: cumulativePayout2, Payout: bigint.Wrap(cumulativePayout2),
}, },
LastSent: &debugapi.ChequebookLastChequePeerResponse{ LastSent: &debugapi.ChequebookLastChequePeerResponse{
Beneficiary: beneficiary1.String(), Beneficiary: beneficiary1.String(),
Chequebook: chequebookAddress.String(), Chequebook: chequebookAddress.String(),
Payout: cumulativePayout1, Payout: bigint.Wrap(cumulativePayout1),
}, },
} }
...@@ -589,15 +590,15 @@ func TestChequebookCashoutStatus(t *testing.T) { ...@@ -589,15 +590,15 @@ func TestChequebookCashoutStatus(t *testing.T) {
TransactionHash: &actionTxHash, TransactionHash: &actionTxHash,
Cheque: &debugapi.ChequebookLastChequePeerResponse{ Cheque: &debugapi.ChequebookLastChequePeerResponse{
Chequebook: chequebookAddress.String(), Chequebook: chequebookAddress.String(),
Payout: cumulativePayout, Payout: bigint.Wrap(cumulativePayout),
Beneficiary: cheque.Beneficiary.String(), Beneficiary: cheque.Beneficiary.String(),
}, },
Result: &debugapi.SwapCashoutStatusResult{ Result: &debugapi.SwapCashoutStatusResult{
Recipient: recipientAddress, Recipient: recipientAddress,
LastPayout: totalPayout, LastPayout: bigint.Wrap(totalPayout),
Bounced: false, Bounced: false,
}, },
UncashedAmount: uncashedAmount, UncashedAmount: bigint.Wrap(uncashedAmount),
} }
var got *debugapi.SwapCashoutStatusResponse var got *debugapi.SwapCashoutStatusResponse
...@@ -633,11 +634,11 @@ func TestChequebookCashoutStatus(t *testing.T) { ...@@ -633,11 +634,11 @@ func TestChequebookCashoutStatus(t *testing.T) {
TransactionHash: &actionTxHash, TransactionHash: &actionTxHash,
Cheque: &debugapi.ChequebookLastChequePeerResponse{ Cheque: &debugapi.ChequebookLastChequePeerResponse{
Chequebook: chequebookAddress.String(), Chequebook: chequebookAddress.String(),
Payout: cumulativePayout, Payout: bigint.Wrap(cumulativePayout),
Beneficiary: cheque.Beneficiary.String(), Beneficiary: cheque.Beneficiary.String(),
}, },
Result: nil, Result: nil,
UncashedAmount: uncashedAmount, UncashedAmount: bigint.Wrap(uncashedAmount),
} }
var got *debugapi.SwapCashoutStatusResponse var got *debugapi.SwapCashoutStatusResponse
...@@ -668,7 +669,7 @@ func TestChequebookCashoutStatus(t *testing.T) { ...@@ -668,7 +669,7 @@ func TestChequebookCashoutStatus(t *testing.T) {
TransactionHash: nil, TransactionHash: nil,
Cheque: nil, Cheque: nil,
Result: nil, Result: nil,
UncashedAmount: uncashedAmount, UncashedAmount: bigint.Wrap(uncashedAmount),
} }
var got *debugapi.SwapCashoutStatusResponse var got *debugapi.SwapCashoutStatusResponse
......
...@@ -26,6 +26,8 @@ type ( ...@@ -26,6 +26,8 @@ type (
SwapCashoutStatusResponse = swapCashoutStatusResponse SwapCashoutStatusResponse = swapCashoutStatusResponse
SwapCashoutStatusResult = swapCashoutStatusResult SwapCashoutStatusResult = swapCashoutStatusResult
TagResponse = tagResponse TagResponse = tagResponse
ReserveStateResponse = reserveStateResponse
ChainStateResponse = chainStateResponse
) )
var ( var (
......
...@@ -7,14 +7,41 @@ package debugapi ...@@ -7,14 +7,41 @@ package debugapi
import ( import (
"net/http" "net/http"
"github.com/ethersphere/bee/pkg/bigint"
"github.com/ethersphere/bee/pkg/jsonhttp" "github.com/ethersphere/bee/pkg/jsonhttp"
) )
type reserveStateResponse struct {
Radius uint8 `json:"radius"`
Available int64 `json:"available"`
Outer *bigint.BigInt `json:"outer"` // lower value limit for outer layer = the further half of chunks
Inner *bigint.BigInt `json:"inner"`
}
type chainStateResponse struct {
Block uint64 `json:"block"` // The block number of the last postage event.
TotalAmount *bigint.BigInt `json:"totalAmount"` // Cumulative amount paid per stamp.
CurrentPrice *bigint.BigInt `json:"currentPrice"` // Bzz/chunk/block normalised price.
}
func (s *Service) reserveStateHandler(w http.ResponseWriter, _ *http.Request) { func (s *Service) reserveStateHandler(w http.ResponseWriter, _ *http.Request) {
jsonhttp.OK(w, s.batchStore.GetReserveState()) state := s.batchStore.GetReserveState()
jsonhttp.OK(w, reserveStateResponse{
Radius: state.Radius,
Available: state.Available,
Outer: bigint.Wrap(state.Outer),
Inner: bigint.Wrap(state.Inner),
})
} }
// chainStateHandler returns the current chain state. // chainStateHandler returns the current chain state.
func (s *Service) chainStateHandler(w http.ResponseWriter, _ *http.Request) { func (s *Service) chainStateHandler(w http.ResponseWriter, _ *http.Request) {
jsonhttp.OK(w, s.batchStore.GetChainState()) state := s.batchStore.GetChainState()
jsonhttp.OK(w, chainStateResponse{
Block: state.Block,
TotalAmount: bigint.Wrap(state.TotalAmount),
CurrentPrice: bigint.Wrap(state.CurrentPrice),
})
} }
...@@ -9,6 +9,8 @@ import ( ...@@ -9,6 +9,8 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/ethersphere/bee/pkg/bigint"
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
"github.com/ethersphere/bee/pkg/postage" "github.com/ethersphere/bee/pkg/postage"
"github.com/ethersphere/bee/pkg/postage/batchstore/mock" "github.com/ethersphere/bee/pkg/postage/batchstore/mock"
...@@ -19,11 +21,15 @@ func TestReserveState(t *testing.T) { ...@@ -19,11 +21,15 @@ func TestReserveState(t *testing.T) {
ts := newTestServer(t, testServerOptions{ ts := newTestServer(t, testServerOptions{
BatchStore: mock.New(mock.WithReserveState(&postage.ReserveState{ BatchStore: mock.New(mock.WithReserveState(&postage.ReserveState{
Radius: 5, Radius: 5,
Outer: big.NewInt(5),
Inner: big.NewInt(5),
})), })),
}) })
jsonhttptest.Request(t, ts.Client, http.MethodGet, "/reservestate", http.StatusOK, jsonhttptest.Request(t, ts.Client, http.MethodGet, "/reservestate", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(&postage.ReserveState{ jsonhttptest.WithExpectedJSONResponse(&debugapi.ReserveStateResponse{
Radius: 5, Radius: 5,
Outer: bigint.Wrap(big.NewInt(5)),
Inner: bigint.Wrap(big.NewInt(5)),
}), }),
) )
}) })
...@@ -32,7 +38,7 @@ func TestReserveState(t *testing.T) { ...@@ -32,7 +38,7 @@ func TestReserveState(t *testing.T) {
BatchStore: mock.New(), BatchStore: mock.New(),
}) })
jsonhttptest.Request(t, ts.Client, http.MethodGet, "/reservestate", http.StatusOK, jsonhttptest.Request(t, ts.Client, http.MethodGet, "/reservestate", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(&postage.ReserveState{}), jsonhttptest.WithExpectedJSONResponse(&debugapi.ReserveStateResponse{}),
) )
}) })
} }
...@@ -48,7 +54,11 @@ func TestChainState(t *testing.T) { ...@@ -48,7 +54,11 @@ func TestChainState(t *testing.T) {
BatchStore: mock.New(mock.WithChainState(cs)), BatchStore: mock.New(mock.WithChainState(cs)),
}) })
jsonhttptest.Request(t, ts.Client, http.MethodGet, "/chainstate", http.StatusOK, jsonhttptest.Request(t, ts.Client, http.MethodGet, "/chainstate", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(cs), jsonhttptest.WithExpectedJSONResponse(&debugapi.ChainStateResponse{
Block: 123456,
TotalAmount: bigint.Wrap(big.NewInt(50)),
CurrentPrice: bigint.Wrap(big.NewInt(5)),
}),
) )
}) })
...@@ -57,7 +67,7 @@ func TestChainState(t *testing.T) { ...@@ -57,7 +67,7 @@ func TestChainState(t *testing.T) {
BatchStore: mock.New(), BatchStore: mock.New(),
}) })
jsonhttptest.Request(t, ts.Client, http.MethodGet, "/chainstate", http.StatusOK, jsonhttptest.Request(t, ts.Client, http.MethodGet, "/chainstate", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(&postage.ChainState{}), jsonhttptest.WithExpectedJSONResponse(&debugapi.ChainStateResponse{}),
) )
}) })
} }
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"math/big" "math/big"
"net/http" "net/http"
"github.com/ethersphere/bee/pkg/bigint"
"github.com/ethersphere/bee/pkg/jsonhttp" "github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/settlement" "github.com/ethersphere/bee/pkg/settlement"
"github.com/ethersphere/bee/pkg/swarm" "github.com/ethersphere/bee/pkg/swarm"
...@@ -21,14 +22,14 @@ var ( ...@@ -21,14 +22,14 @@ var (
) )
type settlementResponse struct { type settlementResponse struct {
Peer string `json:"peer"` Peer string `json:"peer"`
SettlementReceived *big.Int `json:"received"` SettlementReceived *bigint.BigInt `json:"received"`
SettlementSent *big.Int `json:"sent"` SettlementSent *bigint.BigInt `json:"sent"`
} }
type settlementsResponse struct { type settlementsResponse struct {
TotalSettlementReceived *big.Int `json:"totalReceived"` TotalSettlementReceived *bigint.BigInt `json:"totalReceived"`
TotalSettlementSent *big.Int `json:"totalSent"` TotalSettlementSent *bigint.BigInt `json:"totalSent"`
Settlements []settlementResponse `json:"settlements"` Settlements []settlementResponse `json:"settlements"`
} }
...@@ -57,8 +58,8 @@ func (s *Service) settlementsHandler(w http.ResponseWriter, r *http.Request) { ...@@ -57,8 +58,8 @@ func (s *Service) settlementsHandler(w http.ResponseWriter, r *http.Request) {
for a, b := range settlementsSent { for a, b := range settlementsSent {
settlementResponses[a] = settlementResponse{ settlementResponses[a] = settlementResponse{
Peer: a, Peer: a,
SettlementSent: b, SettlementSent: bigint.Wrap(b),
SettlementReceived: big.NewInt(0), SettlementReceived: bigint.Wrap(big.NewInt(0)),
} }
totalSent.Add(b, totalSent) totalSent.Add(b, totalSent)
} }
...@@ -66,13 +67,13 @@ func (s *Service) settlementsHandler(w http.ResponseWriter, r *http.Request) { ...@@ -66,13 +67,13 @@ func (s *Service) settlementsHandler(w http.ResponseWriter, r *http.Request) {
for a, b := range settlementsReceived { for a, b := range settlementsReceived {
if _, ok := settlementResponses[a]; ok { if _, ok := settlementResponses[a]; ok {
t := settlementResponses[a] t := settlementResponses[a]
t.SettlementReceived = b t.SettlementReceived = bigint.Wrap(b)
settlementResponses[a] = t settlementResponses[a] = t
} else { } else {
settlementResponses[a] = settlementResponse{ settlementResponses[a] = settlementResponse{
Peer: a, Peer: a,
SettlementSent: big.NewInt(0), SettlementSent: bigint.Wrap(big.NewInt(0)),
SettlementReceived: b, SettlementReceived: bigint.Wrap(b),
} }
} }
totalReceived.Add(b, totalReceived) totalReceived.Add(b, totalReceived)
...@@ -85,7 +86,7 @@ func (s *Service) settlementsHandler(w http.ResponseWriter, r *http.Request) { ...@@ -85,7 +86,7 @@ func (s *Service) settlementsHandler(w http.ResponseWriter, r *http.Request) {
i++ i++
} }
jsonhttp.OK(w, settlementsResponse{TotalSettlementReceived: totalReceived, TotalSettlementSent: totalSent, Settlements: settlementResponsesArray}) jsonhttp.OK(w, settlementsResponse{TotalSettlementReceived: bigint.Wrap(totalReceived), TotalSettlementSent: bigint.Wrap(totalSent), Settlements: settlementResponsesArray})
} }
func (s *Service) peerSettlementsHandler(w http.ResponseWriter, r *http.Request) { func (s *Service) peerSettlementsHandler(w http.ResponseWriter, r *http.Request) {
...@@ -139,8 +140,8 @@ func (s *Service) peerSettlementsHandler(w http.ResponseWriter, r *http.Request) ...@@ -139,8 +140,8 @@ func (s *Service) peerSettlementsHandler(w http.ResponseWriter, r *http.Request)
jsonhttp.OK(w, settlementResponse{ jsonhttp.OK(w, settlementResponse{
Peer: peer.String(), Peer: peer.String(),
SettlementReceived: received, SettlementReceived: bigint.Wrap(received),
SettlementSent: sent, SettlementSent: bigint.Wrap(sent),
}) })
} }
...@@ -169,8 +170,8 @@ func (s *Service) settlementsHandlerPseudosettle(w http.ResponseWriter, r *http. ...@@ -169,8 +170,8 @@ func (s *Service) settlementsHandlerPseudosettle(w http.ResponseWriter, r *http.
for a, b := range settlementsSent { for a, b := range settlementsSent {
settlementResponses[a] = settlementResponse{ settlementResponses[a] = settlementResponse{
Peer: a, Peer: a,
SettlementSent: b, SettlementSent: bigint.Wrap(b),
SettlementReceived: big.NewInt(0), SettlementReceived: bigint.Wrap(big.NewInt(0)),
} }
totalSent.Add(b, totalSent) totalSent.Add(b, totalSent)
} }
...@@ -178,13 +179,13 @@ func (s *Service) settlementsHandlerPseudosettle(w http.ResponseWriter, r *http. ...@@ -178,13 +179,13 @@ func (s *Service) settlementsHandlerPseudosettle(w http.ResponseWriter, r *http.
for a, b := range settlementsReceived { for a, b := range settlementsReceived {
if _, ok := settlementResponses[a]; ok { if _, ok := settlementResponses[a]; ok {
t := settlementResponses[a] t := settlementResponses[a]
t.SettlementReceived = b t.SettlementReceived = bigint.Wrap(b)
settlementResponses[a] = t settlementResponses[a] = t
} else { } else {
settlementResponses[a] = settlementResponse{ settlementResponses[a] = settlementResponse{
Peer: a, Peer: a,
SettlementSent: big.NewInt(0), SettlementSent: bigint.Wrap(big.NewInt(0)),
SettlementReceived: b, SettlementReceived: bigint.Wrap(b),
} }
} }
totalReceived.Add(b, totalReceived) totalReceived.Add(b, totalReceived)
...@@ -197,5 +198,5 @@ func (s *Service) settlementsHandlerPseudosettle(w http.ResponseWriter, r *http. ...@@ -197,5 +198,5 @@ func (s *Service) settlementsHandlerPseudosettle(w http.ResponseWriter, r *http.
i++ i++
} }
jsonhttp.OK(w, settlementsResponse{TotalSettlementReceived: totalReceived, TotalSettlementSent: totalSent, Settlements: settlementResponsesArray}) jsonhttp.OK(w, settlementsResponse{TotalSettlementReceived: bigint.Wrap(totalReceived), TotalSettlementSent: bigint.Wrap(totalSent), Settlements: settlementResponsesArray})
} }
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/ethersphere/bee/pkg/bigint"
"github.com/ethersphere/bee/pkg/debugapi" "github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/jsonhttp" "github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" "github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
...@@ -40,28 +41,28 @@ func TestSettlements(t *testing.T) { ...@@ -40,28 +41,28 @@ func TestSettlements(t *testing.T) {
}) })
expected := &debugapi.SettlementsResponse{ expected := &debugapi.SettlementsResponse{
TotalSettlementReceived: big.NewInt(15000), TotalSettlementReceived: bigint.Wrap(big.NewInt(15000)),
TotalSettlementSent: big.NewInt(80000), TotalSettlementSent: bigint.Wrap(big.NewInt(80000)),
Settlements: []debugapi.SettlementResponse{ Settlements: []debugapi.SettlementResponse{
{ {
Peer: "DEAD", Peer: "DEAD",
SettlementReceived: big.NewInt(0), SettlementReceived: bigint.Wrap(big.NewInt(0)),
SettlementSent: big.NewInt(10000), SettlementSent: bigint.Wrap(big.NewInt(10000)),
}, },
{ {
Peer: "BEEF", Peer: "BEEF",
SettlementReceived: big.NewInt(10000), SettlementReceived: bigint.Wrap(big.NewInt(10000)),
SettlementSent: big.NewInt(20000), SettlementSent: bigint.Wrap(big.NewInt(20000)),
}, },
{ {
Peer: "FFFF", Peer: "FFFF",
SettlementReceived: big.NewInt(0), SettlementReceived: bigint.Wrap(big.NewInt(0)),
SettlementSent: big.NewInt(50000), SettlementSent: bigint.Wrap(big.NewInt(50000)),
}, },
{ {
Peer: "EEEE", Peer: "EEEE",
SettlementReceived: big.NewInt(5000), SettlementReceived: bigint.Wrap(big.NewInt(5000)),
SettlementSent: big.NewInt(0), SettlementSent: bigint.Wrap(big.NewInt(0)),
}, },
}, },
} }
...@@ -107,8 +108,8 @@ func TestSettlementsPeers(t *testing.T) { ...@@ -107,8 +108,8 @@ func TestSettlementsPeers(t *testing.T) {
jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/settlements/"+peer, http.StatusOK, jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/settlements/"+peer, http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.SettlementResponse{ jsonhttptest.WithExpectedJSONResponse(debugapi.SettlementResponse{
Peer: peer, Peer: peer,
SettlementSent: big.NewInt(1000000000000000000), SettlementSent: bigint.Wrap(big.NewInt(1000000000000000000)),
SettlementReceived: big.NewInt(0), SettlementReceived: bigint.Wrap(big.NewInt(0)),
}), }),
) )
} }
...@@ -133,8 +134,8 @@ func TestSettlementsPeersNoSettlements(t *testing.T) { ...@@ -133,8 +134,8 @@ func TestSettlementsPeersNoSettlements(t *testing.T) {
jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/settlements/"+peer, http.StatusOK, jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/settlements/"+peer, http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.SettlementResponse{ jsonhttptest.WithExpectedJSONResponse(debugapi.SettlementResponse{
Peer: peer, Peer: peer,
SettlementSent: big.NewInt(0), SettlementSent: bigint.Wrap(big.NewInt(0)),
SettlementReceived: big.NewInt(1000000000000000000), SettlementReceived: bigint.Wrap(big.NewInt(1000000000000000000)),
}), }),
) )
}) })
...@@ -150,8 +151,8 @@ func TestSettlementsPeersNoSettlements(t *testing.T) { ...@@ -150,8 +151,8 @@ func TestSettlementsPeersNoSettlements(t *testing.T) {
jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/settlements/"+peer, http.StatusOK, jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/settlements/"+peer, http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.SettlementResponse{ jsonhttptest.WithExpectedJSONResponse(debugapi.SettlementResponse{
Peer: peer, Peer: peer,
SettlementSent: big.NewInt(1000000000000000000), SettlementSent: bigint.Wrap(big.NewInt(1000000000000000000)),
SettlementReceived: big.NewInt(0), SettlementReceived: bigint.Wrap(big.NewInt(0)),
}), }),
) )
}) })
...@@ -217,11 +218,11 @@ func equalSettlements(a, b *debugapi.SettlementsResponse) bool { ...@@ -217,11 +218,11 @@ func equalSettlements(a, b *debugapi.SettlementsResponse) bool {
} }
} }
if a.TotalSettlementReceived.Cmp(b.TotalSettlementReceived) != 0 { if a.TotalSettlementReceived.Cmp(b.TotalSettlementReceived.Int) != 0 {
return false return false
} }
if a.TotalSettlementSent.Cmp(b.TotalSettlementSent) != 0 { if a.TotalSettlementSent.Cmp(b.TotalSettlementSent.Int) != 0 {
return false return false
} }
......
...@@ -8,7 +8,7 @@ import "math/big" ...@@ -8,7 +8,7 @@ import "math/big"
// ChainState contains data the batch service reads from the chain. // ChainState contains data the batch service reads from the chain.
type ChainState struct { type ChainState struct {
Block uint64 `json:"block"` // The block number of the last postage event. Block uint64 // The block number of the last postage event.
TotalAmount *big.Int `json:"totalAmount"` // Cumulative amount paid per stamp. TotalAmount *big.Int // Cumulative amount paid per stamp.
CurrentPrice *big.Int `json:"currentPrice"` // Bzz/chunk/block normalised price. CurrentPrice *big.Int // Bzz/chunk/block normalised price.
} }
...@@ -7,8 +7,8 @@ package postage ...@@ -7,8 +7,8 @@ package postage
import "math/big" import "math/big"
type ReserveState struct { type ReserveState struct {
Radius uint8 `json:"radius"` Radius uint8
Available int64 `json:"available"` Available int64
Outer *big.Int `json:"outer"` // lower value limit for outer layer = the further half of chunks Outer *big.Int // lower value limit for outer layer = the further half of chunks
Inner *big.Int `json:"inner"` Inner *big.Int
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment