Skip to content

Commit

Permalink
fix(cosmic-swingset): reduce unnecessary logs (#425)
Browse files Browse the repository at this point in the history
* fix(cosmic-swingset): reduce unnecessary logs

Closes #424
  • Loading branch information
michaelfig authored Jan 16, 2020
1 parent cf62725 commit 8dc31a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
18 changes: 4 additions & 14 deletions packages/cosmic-swingset/lib/ag-chain-cosmos
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ let deliveryFunctionsInitialized = false;
let sPort;

function toSwingSet(action, replier) {
console.log(`toSwingSet`, action, replier);
// console.log(`toSwingSet`, action, replier);
return toSwingSet0(action, replier)
.then(ret => {
console.log(`toSwingSet returning:`, ret);
// console.log(`toSwingSet returning:`, ret);
return ret;
}, err => {
console.log('toSwingSet threw error:', err);
Expand Down Expand Up @@ -130,28 +130,18 @@ async function toSwingSet0(action, _replier) {
deliveryFunctionsInitialized = true;
}

let d;
switch (action.type) {
case DELIVER_INBOUND:
d = deliverInbound(
return deliverInbound(
action.peer,
action.messages,
action.ack,
action.blockHeight,
action.blockTime,
);
break;
case BEGIN_BLOCK:
d = deliverStartBlock(action.blockHeight, action.blockTime);
break;
return deliverStartBlock(action.blockHeight, action.blockTime);
default:
throw new Error(`${action.type} not recognized. must be DELIVER_INBOUND or BEGIN_BLOCK`);
}

d.then(undefined,
rej => {
console.log(`${action.type} failed`, rej);
throw rej;
});
return d;
}
21 changes: 11 additions & 10 deletions packages/cosmic-swingset/x/swingset/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,17 @@ func handleMsgDeliverInbound(ctx sdk.Context, keeper Keeper, msg MsgDeliverInbou
if err != nil {
return sdk.ErrInternal(err.Error()).Result()
}
fmt.Fprintln(os.Stderr, "About to call SwingSet")

out, err := CallToNode(string(b))
fmt.Fprintln(os.Stderr, "Returned from SwingSet", out, err)
_, err = CallToNode(string(b))
// fmt.Fprintln(os.Stderr, "Returned from SwingSet", out, err)
UnregisterPortHandler(newPort)
if err != nil {
return sdk.ErrInternal(err.Error()).Result()
}
return sdk.Result{} // return
return sdk.Result{}
}

func handleMsgBeginBlock(ctx sdk.Context, keeper Keeper) {
func handleMsgBeginBlock(ctx sdk.Context, keeper Keeper) sdk.Result {
storageHandler := NewStorageHandler(ctx, keeper)

// Allow the storageHandler to consume unlimited gas.
Expand All @@ -147,13 +146,15 @@ func handleMsgBeginBlock(ctx sdk.Context, keeper Keeper) {
b, err := json.Marshal(action)
if err != nil {
fmt.Fprintln(os.Stderr, "Error marshalling", err)
return
return sdk.ErrInternal(err.Error()).Result()
}

fmt.Fprintln(os.Stderr, "About to call SwingSet")
_, err = CallToNode(string(b))

out, err := CallToNode(string(b))
fmt.Fprintln(os.Stderr, "Returned from SwingSet", out, err)
// fmt.Fprintln(os.Stderr, "Returned from SwingSet", out, err)
UnregisterPortHandler(newPort)
return
if err != nil {
return sdk.ErrInternal(err.Error()).Result()
}
return sdk.Result{}
}

0 comments on commit 8dc31a0

Please sign in to comment.