rosetta-lbry/services/types.go

111 lines
3 KiB
Go
Raw Normal View History

2020-09-16 21:03:14 +02:00
// Copyright 2020 Coinbase, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package services
import (
"context"
2020-11-17 09:20:36 +01:00
"github.com/lbryio/rosetta-lbry/lbry"
2020-09-16 21:03:14 +02:00
2020-11-17 09:20:36 +01:00
"github.com/lbryio/rosetta-sdk-go/types"
2020-09-16 21:03:14 +02:00
)
2020-09-21 00:20:34 +02:00
const (
// NodeVersion is the version of
2020-11-17 09:20:36 +01:00
// lbry core we are using.
NodeVersion = "0.17.4.6"
// HistoricalBalanceLookup indicates
// that historical balance lookup is supported.
HistoricalBalanceLookup = true
2020-10-27 20:42:58 +01:00
// inlineFetchLimit is the maximum number
// of transactions to fetch inline.
inlineFetchLimit = 100
2020-09-21 00:20:34 +02:00
)
var (
// MiddlewareVersion is the version
2020-11-17 09:20:36 +01:00
// of rosetta-lbry. We set this as a
2020-09-21 00:20:34 +02:00
// variable instead of a constant because
// we typically need the pointer of this
// value.
2020-10-28 20:20:30 +01:00
MiddlewareVersion = "0.0.6"
2020-09-21 00:20:34 +02:00
)
2020-09-16 21:03:14 +02:00
// Client is used by the servicers to get Peer information
// and to submit transactions.
type Client interface {
GetPeers(context.Context) ([]*types.Peer, error)
2020-09-16 21:03:14 +02:00
SendRawTransaction(context.Context, string) (string, error)
SuggestedFeeRate(context.Context, int64) (float64, error)
2020-09-19 03:04:37 +02:00
RawMempool(context.Context) ([]string, error)
2020-09-16 21:03:14 +02:00
}
// Indexer is used by the servicers to get block and account data.
type Indexer interface {
2020-10-27 18:25:02 +01:00
GetBlockLazy(
context.Context,
*types.PartialBlockIdentifier,
) (*types.BlockResponse, error)
2020-09-16 21:03:14 +02:00
GetBlockTransaction(
context.Context,
*types.BlockIdentifier,
*types.TransactionIdentifier,
) (*types.Transaction, error)
GetCoins(
context.Context,
*types.AccountIdentifier,
) ([]*types.Coin, *types.BlockIdentifier, error)
GetScriptPubKeys(
context.Context,
[]*types.Coin,
2020-11-17 09:20:36 +01:00
) ([]*lbry.ScriptPubKey, error)
2020-10-27 18:25:02 +01:00
GetBalance(
context.Context,
*types.AccountIdentifier,
*types.Currency,
*types.PartialBlockIdentifier,
) (*types.Amount, *types.BlockIdentifier, error)
2020-09-16 21:03:14 +02:00
}
type unsignedTransaction struct {
2020-11-17 09:20:36 +01:00
Transaction string `json:"transaction"`
ScriptPubKeys []*lbry.ScriptPubKey `json:"scriptPubKeys"`
InputAmounts []string `json:"input_amounts"`
InputAddresses []string `json:"input_addresses"`
2020-09-16 21:03:14 +02:00
}
type preprocessOptions struct {
Coins []*types.Coin `json:"coins"`
EstimatedSize float64 `json:"estimated_size"`
FeeMultiplier *float64 `json:"fee_multiplier,omitempty"`
}
type constructionMetadata struct {
2020-11-17 09:20:36 +01:00
ScriptPubKeys []*lbry.ScriptPubKey `json:"script_pub_keys"`
2020-09-16 21:03:14 +02:00
}
type signedTransaction struct {
Transaction string `json:"transaction"`
InputAmounts []string `json:"input_amounts"`
}
// ParseOperationMetadata is returned from
// ConstructionParse.
type ParseOperationMetadata struct {
2020-11-17 09:20:36 +01:00
ScriptPubKey *lbry.ScriptPubKey `json:"scriptPubKey"`
2020-09-16 21:03:14 +02:00
}