Post
Topic
Board Services
Re: Python Programmer
by
JobCreator
on 08/06/2015, 12:48:56 UTC
More details about the design as requested.  Anyone is free to submit feedback and offer suggestions.

BlockChain
Interface for implementation of PrimaryBlockChain and AuxiluryBlockChain objects.  This is already complete (source will be provided), these methods should be implemented when extending this object.

Code:
def Submit(self, solution):
def Update(self):
def GetData(self):
def Set_OnSubmit(self, _call_back):
def Set_OnUpdate(self, _call_back):

PrimaryBlockChain
Implements a BlockChain Interface.  It is used by the Engineer object as a means of data retrieval and block submission for the network where PoW is being performed.  

Public Methods

Submit
The engineer will 'submit' a solution (aka: share/block) to the PrimaryBlockChain object using this method.  The solution has already been validated and finalized into a submittable block by the Engineer.  
This should be a deferred method where the program does not block execution while the PrimaryBlockChain processes the submission.  When the block is accepted/rejected the method specified by 'Set_OnSubmit' should be called with the resulting information.
If the block is accepted, the PrimaryBlockChain object should perform an update request.

Update
The engineer may call this method upon program initialization for initial construction of a block template.  It's also possible that this method may be called by the engineer via an external process (such as a new block notification mechanism)
This should be a  deferred where the program does not block execution while the PrimaryBlockChain waits for data.  Once data is received the method specified by 'Set_OnUpdate' should be called with the resulting information.

GetData
Allows the on demand retrieval of the currently loaded data (cached)  from when the last update was run.  This method may be called by the Engineer when checking for block candidates and may be called by the Poller when comparing cached data with live data.

Set_OnSubmit
This method allows the Engineer to set a callback method to be executed upon a successful or failed block submission.

Set_OnUpdate
This method allows the Engineer to set a callback method to be executed any time new data is received from the upstream network.

Call Backs
These are the callbacks as set by the 'Set_OnXXXX' public methods.


Return an indication of a successful or failed block submission with block hash and height as additional information.  If submission failed, then no additional data is provided.


Returns a data package containing all the information necessary to construct a block template.  Basically it should be whatever the 'getblocktemplate' RPC call returns.

Object Initialization
The constructor should require that an RPC object be provided during initialization.

Updater
Internal object responsible for retrieving data via the 'getblocktemplate' RPC call.  Used by BlockChain implementing objects and Poller.  

Public Methods

Update
This is what begins the actual 'update' process.  An optional parameter is passed indicating if this should be a 'forced' update (false by default).

Object Initialization
The constructor should require that an RPC object be provided during initialization.

Poller
Internal object responsible for manually comparing the 'prevhash' to detect a new block and/or update the Merkle tree.  

Public Methods

SetInterval
Self Explanatory, allows the ability to specify a polling interval.

Object Initialization
The constructor should require that an RPC object be provided during initialization.

RPC
The Updater, Poller, and PrimaryBlockChain objects utilize this as a means of communicating with the upstream network.  This is already implemented, the following methods are exposed:

Code:
def call(self, method, params):
def submitblock(self, block_hex, hash_hex, raw_hex, method, num_retries):
def getinfo(self):
def getblocktemplate(self, num_retries):
def prevhash(self):
def validateaddress(self, address):
def getdifficulty(self):
def blockexists(self, hash_hex):
def set_getblocktemplate_pollformat(self, format):
def set_has_submitblock(self, enabled):