Skip to content

Ergo Adaptor

Moein zargarzadeh edited this page Apr 28, 2021 · 2 revisions

This document describes the methods and functions required to make an adaptor based on interface.go principles.

The following functions are supposed to be called by other modules:

ErgoAdaptor

  • This type is the main struct of the adaptor

ErgoAdapterOption

  • Array of ErgoAdaptors

applyOpts

  • Adds AdapterOptions to ErgoAdaptor
  • Calls validateErgoAdapterOptions method to check option type

validateErgoAdapterOptions

  • Validates that options have the right type and value. (validators are implemented in factory.go)

WithErgoGravityContract

  • To be called in ledger.go as a parameter of NewErgoAdapter

ErgoAdapterWithGhClient

  • To be called in node.go as a parameter of NewErgoAdapter

NewErgoAdapterByOpts

  • Makes new adaptor in factory.go
  • AdapterOptions is used to make an Ergo client
  • applyOpts method is called here.

NewErgoAdapter

  • To be called in ledger.go and node.go to make an Ergo adaptor.

The following functions implement the IBlockchainAdaptor methods expected in interface.go. Since there is no Ergo client available in Golang, the rest-API architecture is used to develop a proxy connecting Gravity to Ergo.

GetHeight

  • Calling /height route of the proxy returns the blockchain's height.
  • The response will be parsed and the suitable result will be returned.

WaitTx

  • This function is used to check whether confirmation is done or not.
  • TxWaitCount is used to wait some time in order to checking the confirmation
  • /numConfirmations route with id as parameter checks whether this id is confirmed or not.
  • This functions returns the number of confirmations if the tx is confirmed, otherwise it returns -1.

Sign

  • In Ergo a variant of Shnorr Signature is being used as the signature method. Therefore, the signature is in form of a (a,z) pair.
  • Sends a post request to /sign route with the body of message hash and secret key, in order to sign the messageHash.

PubKey

  • Ergo Public Key is used to make an Oracle public key.

Clone this wiki locally