Cuckoo-miner update - Multiple Plugin mining (#139)

* Adding ability to load multiple mining plugins in parallel via cuckoo miner
* updating with newest cuckoo-miner changes
* revert default config value
* update pow document with link to podcast
This commit is contained in:
Yeastplume
2017-09-26 18:58:56 +01:00
committed by Ignotus Peverell
parent 7d48e1da49
commit 53d9ca630c
14 changed files with 1028 additions and 789 deletions
+23 -17
View File
@@ -46,7 +46,7 @@ impl ApiEndpoint for ChainApi {
fn get(&self, _: String) -> ApiResult<Tip> {
match self.chain.head() {
Ok(tip) => Ok(Tip::from_tip(tip)),
Err(e) => Err(Error::Internal(format!("{:?}", e)))
Err(e) => Err(Error::Internal(format!("{:?}", e))),
}
}
}
@@ -70,12 +70,14 @@ impl ApiEndpoint for OutputApi {
fn get(&self, id: String) -> ApiResult<Output> {
debug!("GET output {}", id);
let c = util::from_hex(id.clone()).map_err(|_| Error::Argument(format!("Not a valid commitment: {}", id)))?;
let c = util::from_hex(id.clone()).map_err(|_| {
Error::Argument(format!("Not a valid commitment: {}", id))
})?;
let commit = Commitment::from_vec(c);
let out = self.chain.get_unspent(&commit)
.map_err(|_| Error::NotFound)?;
let header = self.chain.get_block_header_by_output_commit(&commit)
let out = self.chain.get_unspent(&commit).map_err(|_| Error::NotFound)?;
let header = self.chain
.get_block_header_by_output_commit(&commit)
.map_err(|_| Error::NotFound)?;
Ok(Output::from_output(&out, &header))
@@ -90,7 +92,8 @@ pub struct PoolApi<T> {
}
impl<T> ApiEndpoint for PoolApi<T>
where T: pool::BlockChain + Clone + Send + Sync + 'static
where
T: pool::BlockChain + Clone + Send + Sync + 'static,
{
type ID = String;
type T = PoolInfo;
@@ -116,7 +119,9 @@ impl<T> ApiEndpoint for PoolApi<T>
})?;
let tx: Transaction = ser::deserialize(&mut &tx_bin[..]).map_err(|_| {
Error::Argument("Could not deserialize transaction, invalid format.".to_string())
Error::Argument(
"Could not deserialize transaction, invalid format.".to_string(),
)
})?;
let source = pool::TxSource {
@@ -148,20 +153,21 @@ pub struct TxWrapper {
/// Start all server REST APIs. Just register all of them on a ApiServer
/// instance and runs the corresponding HTTP server.
pub fn start_rest_apis<T>(addr: String,
chain: Arc<chain::Chain>,
tx_pool: Arc<RwLock<pool::TransactionPool<T>>>)
where T: pool::BlockChain + Clone + Send + Sync + 'static
pub fn start_rest_apis<T>(
addr: String,
chain: Arc<chain::Chain>,
tx_pool: Arc<RwLock<pool::TransactionPool<T>>>,
) where
T: pool::BlockChain + Clone + Send + Sync + 'static,
{
thread::spawn(move || {
let mut apis = ApiServer::new("/v1".to_string());
apis.register_endpoint("/chain".to_string(),
ChainApi { chain: chain.clone() });
apis.register_endpoint("/chain/utxo".to_string(),
OutputApi {
chain: chain.clone(),
});
apis.register_endpoint("/chain".to_string(), ChainApi { chain: chain.clone() });
apis.register_endpoint(
"/chain/utxo".to_string(),
OutputApi { chain: chain.clone() },
);
apis.register_endpoint("/pool".to_string(), PoolApi { tx_pool: tx_pool });
apis.start(&addr[..]).unwrap_or_else(|e| {