Commit aa1d89df authored by Sharon Urban's avatar Sharon Urban

removed logary, cleanup

parent 1b6a25c4
This diff is collapsed.
......@@ -13,7 +13,6 @@ nuget NetMQ >= 4.0.0.175-pre
nuget FsNetMQ >= 0.2.8.0
nuget MongoDB.Driver
nuget MongoDB.FSharp
nuget Logary
nuget NodaTime 1.3.2 // specific version needed by Logary
source https://www.myget.org/F/zenprotocol/api/v2
......
......@@ -36,7 +36,7 @@ let private activate() = result {
if activatedContractId <> contractId then
return! Error "error activating contract"
else
info "contract activated"
printfn "contract activated"
}
let private extend() = result {
......@@ -50,7 +50,7 @@ let private extend() = result {
|> getUri
|> (contractExtendRequestJson address config.yaml.acs.extend).Request
) "error extending contract"
<@> fun _ -> info "contract executed"
<@> fun _ -> printfn "contract extended"
}
let private getTip() =
......@@ -64,28 +64,26 @@ let private getTip() =
<@> fun info -> info.Blocks
let ensureActive() = result {
let getActivationState() =
getResponseBody (fun _ ->
let! activationState =
getResponseBody (fun _ ->
Http.Request(
getUri "contract/active",
httpMethod = "GET"
))
"error getting ACS"
"trying to get ACS, got:"
>>= parseActiveContractsResponseJson
<@> List.tryFind (fst >> (=) contractId)
<@> Option.map snd
let! activationState = getActivationState()
match activationState with
| None ->
info "contract is not active - activating..."
printfn "contract is not active - activating..."
do! activate()
| Some activationState ->
let! tip = getTip()
if activationState - tip < config.yaml.acs.threshold then
info <| sprintf "contract active for %d blocks, extending..." (activationState - tip)
printfn "contract active for %d blocks, extending..." (activationState - tip)
do! extend()
}
......@@ -94,4 +92,4 @@ let execute action json =
getUri action
|> (json:JsonValue).Request
) "error executing contract"
<@> fun _ -> info "contract executed"
\ No newline at end of file
<@> fun _ -> printfn "contract executed"
\ No newline at end of file
......@@ -19,22 +19,17 @@ type RawResultJson = JsonProvider<"""
]
}""">
type AuditPathResponseJson = JsonProvider<"""
{
"auditPath": [
"abcd123"
]
}""">
let parseRawResultJson raw =
Exception.resultWrap<RawResultJson.Root> (fun _ ->
RawResultJson.Parse(raw))
"error parsing provider data"
"error parsing provider data"
<@> (fun root -> root.Data)
<@> Array.map (fun data -> data.Identifier, data.Value)
let parseActiveContractsResponseJson raw =
Exception.resultWrap<ActiveContractsResponseJson.Root[]> (fun _ ->
ActiveContractsResponseJson.Parse(raw))
"error parsing ACS response"
"error parsing ACS response"
<@> Array.map (fun root -> ContractId.fromString root.ContractId, root.Expire)
<@> Array.toList
>>= traverseResultM (fun (contractId, exiry) ->
......@@ -45,7 +40,7 @@ let parseActiveContractsResponseJson raw =
let parseContractActivateResponseJson raw =
Exception.resultWrap<ContractActivateResponseJson.Root> (fun _ ->
ContractActivateResponseJson.Parse(raw))
"error parsing contract activation response"
"error parsing contract activation response"
<@> fun root -> root.ContractId
<@> ContractId.fromString
>>= ofOption "error parsing contractid of activation response"
......@@ -53,7 +48,7 @@ let parseContractActivateResponseJson raw =
let parseBlockChainInfoJson raw =
Exception.resultWrap<BlockChainInfoJson.Root> (fun _ ->
BlockChainInfoJson.Parse(raw))
"error parsing blockchain info response"
"error parsing blockchain info response"
let contractExecuteRequestJson contractId command provideReturnAddress signingKeyDerivationPath spends messageBody =
(new ContractExecuteRequestJson.Root(
......
......@@ -10,28 +10,12 @@ open Serialization
let result = new ResultBuilder<string>()
let debug message =
eventX message
|> Log.debug
message
let info message =
eventX message
|> Log.info
let error message =
eventX "{message}"
>> setField "message" (message:String)
|> Log.error
let getUri action =
sprintf "http://%s/%s" config.yaml.nodeApi action
|> debug
let getResponseBody request errorMessage = result {
let! response =
Exception.resultWrap<HttpResponse> (fun _ ->
request()) errorMessage
Exception.resultWrap<HttpResponse> request errorMessage
if response.StatusCode <> 200 then
return! Error (sprintf "%s: %d" errorMessage response.StatusCode)
......
......@@ -10,5 +10,4 @@ Consensus
Api
Wallet
MongoDB.Driver
MongoDB.FSharp
Logary
\ No newline at end of file
MongoDB.FSharp
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment