Skip to content

Host PaymentProcessor

Peter-Jan Brone requested to merge 3865-payment into master

MERGE REQUEST

Overview

This MR introduces one side of the Payment interface. One of the most important changes happens in modules/payment.go which introduces the following interface. This MR implements one side, the PaymentProcessor interface, on the host.

// PaymentProvider contains the methods required to provide payment for an rpc.
type PaymentProvider interface {
	ProvidePayment(rpc types.Specifier, amount types.Currency, stream siamux.Stream, height types.BlockHeight) (types.Currency, error)
}

// PaymentProcessor is the interface implemented when receiving payment for an
// RPC.
type PaymentProcessor interface {
	ProcessPayment(stream siamux.Stream) (types.Currency, error)
}

A PaymentProcessor takes a stream and handles the payment request and response objects. It returns to the caller how much was paid, which can then be used by the calling RPC.

This MR only introduces the code, covered by a unit test. It is not hooked up to anything in network.go. This will change when we follow up with RPCs that will effectively handle payment.

Example for Visual changes (ie Screenshot)

N/A

Issues Closed

Closes #3865 (closed)

Checklist

Review and complete the checklist to ensure that the MR is complete before assigned to an approver.

  • All new methods, or updating methods have clear docstrings
  • Testing added or updated for new methods
  • Any new packages are added to Makefile and .gitlab-ci.yml
  • API documentation updated for API updates
  • Module README.md updated for changes to work flow
  • Issue added to Sia-UI repo for new supporting features
  • Changelog updated
Edited by Peter-Jan Brone

Merge request reports