ledgerservice

package
v0.0.0-...-9742f5a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_PACKING_ATTEMPTS = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application interface {
	common.StarterShutdowner
}

func NewApplication

func NewApplication(l *logrus.Logger, p *LedgerService, db *sql.DB, conf *ConfigFile) (Application, error)

XXX: Should this take p as an argument, or be responsible for setting it up?

type ConfigFile

type ConfigFile struct {
	LedgerProtocolAddr string
	StatusAddr         string

	Database string `json:"database"`
	Insecure bool   `json:"insecure"`
}

func (*ConfigFile) FillDefaults

func (c *ConfigFile) FillDefaults()

FillDefaults fills in defaults in the config file.

type LedgerClient

type LedgerClient struct {
	GrpcClient ccmsg.LedgerClient
	// contains filtered or unexported fields
}

LedgerClient provides access to the ledger over GRPC

func NewLedgerClient

func NewLedgerClient(l *logrus.Logger, addr string, insecure bool) (*LedgerClient, error)

NewLedgerClient creates a new LedgerClient

type LedgerClientMock

type LedgerClientMock struct {
	mock.Mock
}

func NewLedgerClientMock

func NewLedgerClientMock() *LedgerClientMock

func (*LedgerClientMock) GetBlocks

func (*LedgerClientMock) PostTransaction

type LedgerDatabase

type LedgerDatabase struct{}

func NewLedgerDatabase

func NewLedgerDatabase() *LedgerDatabase

func (*LedgerDatabase) DeleteMempoolTX

func (m *LedgerDatabase) DeleteMempoolTX(ctx context.Context, txid ledger_models.TXID) error

func (*LedgerDatabase) DeleteUtxo

func (m *LedgerDatabase) DeleteUtxo(ctx context.Context, outpoint ledger.OutpointKey) error

func (*LedgerDatabase) HighestBlock

func (m *LedgerDatabase) HighestBlock(ctx context.Context) (*models.Block, error)

func (*LedgerDatabase) InsertBlock

func (m *LedgerDatabase) InsertBlock(ctx context.Context, blockModel *models.Block) error

func (*LedgerDatabase) InsertUtxo

func (m *LedgerDatabase) InsertUtxo(ctx context.Context, utxo *models.Utxo) error

func (*LedgerDatabase) MempoolTXs

func (m *LedgerDatabase) MempoolTXs(ctx context.Context) ([]*models.MempoolTransaction, error)

func (*LedgerDatabase) QueueTX

func (*LedgerDatabase) UpdateAuditLog

func (m *LedgerDatabase) UpdateAuditLog(ctx context.Context, txid ledger_models.TXID, status string) error

func (*LedgerDatabase) Utxo

func (m *LedgerDatabase) Utxo(ctx context.Context, outpoint ledger.OutpointKey) (*models.Utxo, error)

type LedgerMemory

type LedgerMemory struct {
	// contains filtered or unexported fields
}

func NewLedgerMemory

func NewLedgerMemory() *LedgerMemory

func (*LedgerMemory) DeleteMempoolTX

func (m *LedgerMemory) DeleteMempoolTX(ctx context.Context, txid ledger_models.TXID) error

func (*LedgerMemory) DeleteUtxo

func (m *LedgerMemory) DeleteUtxo(ctx context.Context, outpoint ledger.OutpointKey) error

func (*LedgerMemory) HighestBlock

func (m *LedgerMemory) HighestBlock(ctx context.Context) (*models.Block, error)

func (*LedgerMemory) InsertBlock

func (m *LedgerMemory) InsertBlock(ctx context.Context, blockModel *models.Block) error

func (*LedgerMemory) InsertUtxo

func (m *LedgerMemory) InsertUtxo(ctx context.Context, utxo *models.Utxo) error

func (*LedgerMemory) MempoolTXs

func (m *LedgerMemory) MempoolTXs(ctx context.Context) ([]*models.MempoolTransaction, error)

func (*LedgerMemory) QueueTX

func (*LedgerMemory) UpdateAuditLog

func (m *LedgerMemory) UpdateAuditLog(ctx context.Context, txid ledger_models.TXID, status string) error

func (*LedgerMemory) Utxo

func (m *LedgerMemory) Utxo(ctx context.Context, outpoint ledger.OutpointKey) (*models.Utxo, error)

type LedgerMiner

type LedgerMiner struct {
	NewTxChan    chan struct{}
	Interval     time.Duration
	CurrentBlock *models.Block
	// contains filtered or unexported fields
}

func NewLedgerMiner

func NewLedgerMiner(l *logrus.Logger, storage LedgerStorage, kp *keypair.KeyPair) (*LedgerMiner, error)

func (*LedgerMiner) AddOutputsToDatabase

func (m *LedgerMiner) AddOutputsToDatabase(ctx context.Context, txid ledger_models.TXID, outputs []ledger.TransactionOutput) error

func (*LedgerMiner) ApplyBlock

func (m *LedgerMiner) ApplyBlock(ctx context.Context, block *ledger.Block, spentUtxos []ledger.OutpointKey) (*ledger.Block, error)

func (*LedgerMiner) BlockScheduler

func (m *LedgerMiner) BlockScheduler(ctx context.Context) bool

func (*LedgerMiner) BlockSchedulerImmediate

func (m *LedgerMiner) BlockSchedulerImmediate(ctx context.Context) bool

func (*LedgerMiner) BlockSchedulerTimer

func (m *LedgerMiner) BlockSchedulerTimer(ctx context.Context) bool

func (*LedgerMiner) FillBlock

func (m *LedgerMiner) FillBlock(ctx context.Context, state *ledger.SpendingState, mempoolTXs []*models.MempoolTransaction) ([]*models.MempoolTransaction, error)

func (*LedgerMiner) GenerateBlock

func (m *LedgerMiner) GenerateBlock(ctx context.Context) (*ledger.Block, error)

func (*LedgerMiner) GetUtxo

func (*LedgerMiner) InitGenesisBlock

func (m *LedgerMiner) InitGenesisBlock(ctx context.Context, totalCoins uint32) (*ledger.Block, error)

func (*LedgerMiner) QueueTX

func (m *LedgerMiner) QueueTX(ctx context.Context, tx *ledger.Transaction) error

func (*LedgerMiner) Run

func (m *LedgerMiner) Run(ctx context.Context)

func (*LedgerMiner) SetupCurrentBlock

func (m *LedgerMiner) SetupCurrentBlock(ctx context.Context, totalCoins uint32) error

func (*LedgerMiner) ValidateTX

func (m *LedgerMiner) ValidateTX(ctx context.Context, tx ledger.Transaction, state *ledger.SpendingState) error

type LedgerService

type LedgerService struct {
	// contains filtered or unexported fields
}

func NewLedgerService

func NewLedgerService(l *logrus.Logger, kp *keypair.KeyPair, newTxChan *chan struct{}) (*LedgerService, error)

func (*LedgerService) GetBlocks

func (*LedgerService) PostTransaction

func (s *LedgerService) PostTransaction(ctx context.Context, req *ccmsg.PostTransactionRequest) (ptr *ccmsg.PostTransactionResponse, finalErr error)

type LedgerStorage

type LedgerStorage interface {
	MempoolTXs(ctx context.Context) ([]*models.MempoolTransaction, error)
	Utxo(ctx context.Context, outpoint ledger.OutpointKey) (*models.Utxo, error)
	HighestBlock(ctx context.Context) (*models.Block, error)
	InsertBlock(ctx context.Context, blockModel *models.Block) error
	DeleteMempoolTX(ctx context.Context, txid ledger_models.TXID) error
	UpdateAuditLog(ctx context.Context, txid ledger_models.TXID, status string) error
	DeleteUtxo(ctx context.Context, outpoint ledger.OutpointKey) error
	InsertUtxo(ctx context.Context, utxo *models.Utxo) error
	QueueTX(ctx context.Context, tx *models.MempoolTransaction) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL