Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase default batch size #129

Merged
merged 8 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"go.sia.tech/hostd/host/metrics"
"go.sia.tech/hostd/host/settings"
"go.sia.tech/hostd/host/storage"
"go.sia.tech/hostd/logging"
"go.sia.tech/hostd/wallet"
"go.sia.tech/jape"
"go.sia.tech/siad/modules"
Expand Down Expand Up @@ -93,12 +92,6 @@ type (
TipState() consensus.State
}

// A LogStore retrieves host logs
LogStore interface {
LogEntries(logging.Filter) ([]logging.Entry, int, error)
Prune(time.Time) error
}

// A TPool manages the transaction pool
TPool interface {
RecommendedFee() (fee types.Currency)
Expand All @@ -119,7 +112,6 @@ type (
contracts ContractManager
volumes VolumeManager
wallet Wallet
logs LogStore
metrics Metrics
settings Settings

Expand All @@ -128,7 +120,7 @@ type (
)

// NewServer initializes the API
func NewServer(name string, hostKey types.PublicKey, a Alerts, g Syncer, chain ChainManager, tp TPool, cm ContractManager, vm VolumeManager, m Metrics, ls LogStore, s Settings, w Wallet, log *zap.Logger) http.Handler {
func NewServer(name string, hostKey types.PublicKey, a Alerts, g Syncer, chain ChainManager, tp TPool, cm ContractManager, vm VolumeManager, m Metrics, s Settings, w Wallet, log *zap.Logger) http.Handler {
api := &api{
hostKey: hostKey,
name: name,
Expand All @@ -144,7 +136,6 @@ func NewServer(name string, hostKey types.PublicKey, a Alerts, g Syncer, chain C
tpool: tp,
contracts: cm,
volumes: vm,
logs: ls,
metrics: m,
settings: s,
wallet: w,
Expand Down Expand Up @@ -195,8 +186,5 @@ func NewServer(name string, hostKey types.PublicKey, a Alerts, g Syncer, chain C
// system endpoints
"GET /system/dir": api.handleGETSystemDir,
"PUT /system/dir": api.handlePUTSystemDir,
// log endpoints
"POST /log/entries": api.handlePOSTLogEntries,
"DELETE /log/entries": api.handleDELETELogEntries,
})
}
15 changes: 0 additions & 15 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"go.sia.tech/hostd/host/metrics"
"go.sia.tech/hostd/host/settings"
"go.sia.tech/hostd/host/storage"
"go.sia.tech/hostd/logging"
"go.sia.tech/hostd/wallet"
"go.sia.tech/jape"
)
Expand Down Expand Up @@ -225,20 +224,6 @@ func (c *Client) MkDir(path string) error {
return c.c.PUT("/system/dir", req)
}

// LogEntries returns log entries matching the filter.
func (c *Client) LogEntries(filter logging.Filter) ([]logging.Entry, int, error) {
var resp LogResponse
if err := c.c.POST("/log/entries", filter, &resp); err != nil {
return nil, 0, err
}
return resp.Entries, resp.Count, nil
}

// LogPrune deletes log entries before the specified time.
func (c *Client) LogPrune(before time.Time) error {
return c.c.DELETE(fmt.Sprintf("/log/entries?before=%s", before.Format(time.RFC3339)))
}

// NewClient creates a new hostd API client.
func NewClient(baseURL, password string) *Client {
return &Client{
Expand Down
33 changes: 0 additions & 33 deletions api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"go.sia.tech/hostd/host/settings"
"go.sia.tech/hostd/host/storage"
"go.sia.tech/hostd/internal/disk"
"go.sia.tech/hostd/logging"
"go.sia.tech/jape"
"go.sia.tech/siad/modules"
"go.uber.org/zap"
Expand Down Expand Up @@ -559,38 +558,6 @@ func (a *api) handleGETTPoolFee(c jape.Context) {
c.Encode(a.tpool.RecommendedFee())
}

func (a *api) handlePOSTLogEntries(c jape.Context) {
var filter logging.Filter
if err := c.Decode(&filter); err != nil {
return
}

// set default limit
if filter.Limit == 0 {
filter.Limit = 1000
}

entries, count, err := a.logs.LogEntries(filter)
if !a.checkServerError(c, "failed to get log entries", err) {
return
} else if entries == nil {
entries = []logging.Entry{} // TODO: remove. prevents null in JSON causing client-side error
}
c.Encode(LogResponse{
Entries: entries,
Count: count,
})
}

func (a *api) handleDELETELogEntries(c jape.Context) {
var timestamp time.Time
if err := c.DecodeForm("before", &timestamp); err != nil {
return
}
err := a.logs.Prune(timestamp)
a.checkServerError(c, "failed to prune logs", err)
}

func parseLimitParams(c jape.Context, defaultLimit, maxLimit int) (limit, offset int) {
if err := c.DecodeForm("limit", &limit); err != nil {
return
Expand Down
7 changes: 0 additions & 7 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"go.sia.tech/core/types"
"go.sia.tech/hostd/host/contracts"
"go.sia.tech/hostd/host/storage"
"go.sia.tech/hostd/logging"
)

// JSON keys for host setting fields
Expand Down Expand Up @@ -141,12 +140,6 @@ type (
CreateDirRequest struct {
Path string `json:"path"`
}

// LogResponse is the response body for the [GET] /log/entries endpoint.
LogResponse struct {
Count int `json:"count"`
Entries []logging.Entry `json:"entries"`
}
)

// MarshalJSON implements json.Marshaler
Expand Down
2 changes: 1 addition & 1 deletion cmd/hostd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func main() {
auth := jape.BasicAuth(config.HTTP.Password)
web := http.Server{
Handler: webRouter{
api: auth(api.NewServer(config.Name, hostKey.PublicKey(), node.a, node.g, node.cm, node.tp, node.contracts, node.storage, node.metrics, node.store, node.settings, node.w, logger.Named("api"))),
api: auth(api.NewServer(config.Name, hostKey.PublicKey(), node.a, node.g, node.cm, node.tp, node.contracts, node.storage, node.metrics, node.settings, node.w, logger.Named("api"))),
ui: hostd.Handler(),
},
ReadTimeout: 30 * time.Second,
Expand Down
9 changes: 0 additions & 9 deletions cmd/hostd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"go.sia.tech/hostd/host/registry"
"go.sia.tech/hostd/host/settings"
"go.sia.tech/hostd/host/storage"
"go.sia.tech/hostd/logging"
"go.sia.tech/hostd/persist/sqlite"
"go.sia.tech/hostd/rhp"
rhpv2 "go.sia.tech/hostd/rhp/v2"
Expand All @@ -30,7 +29,6 @@ import (
"go.sia.tech/siad/modules/transactionpool"
stypes "go.sia.tech/siad/types"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

func convertToSiad(core types.EncoderTo, siad encoding.SiaUnmarshaler) {
Expand Down Expand Up @@ -212,13 +210,6 @@ func newNode(walletKey types.PrivateKey, logger *zap.Logger) (*node, types.Priva
return nil, types.PrivateKey{}, fmt.Errorf("failed to create sqlite store: %w", err)
}

// create a new zap core by combining the current logger and a custom logging core
core := zapcore.NewTee(logger.Core(), logging.Core(db, logger.Level()))
// reinstantiate the logger with the new core
logger = zap.New(core)
// reset the logger so queries are logged to the database
db.SetLogger(logger.Named("sqlite"))

// load the host identity
hostKey := db.HostKey()

Expand Down
2 changes: 1 addition & 1 deletion host/storage/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"go.uber.org/zap"
)

const flushInterval = 10 * time.Second
const flushInterval = 30 * time.Second

type (
sectorAccessRecorder struct {
Expand Down
160 changes: 0 additions & 160 deletions logging/log.go

This file was deleted.

Loading