Skip to content

Commit 81479ce

Browse files
committed
Getting better
1 parent 7c01211 commit 81479ce

File tree

2 files changed

+16
-34
lines changed

2 files changed

+16
-34
lines changed

src/apps/chifra/pkg/ledger1/get_statements.go

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/ledger10"
1111
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger"
1212
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/normalize"
13-
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc"
1413
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/topics"
1514
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
1615
)
@@ -68,16 +67,7 @@ func (r *Reconciler1) GetStatements1(pos *types.AppPosition, trans *types.Transa
6867
}
6968
}
7069

71-
var err error
72-
if s.PrevBal, s.BegBal, s.EndBal, err = r.opts.Connection.GetReconBalances(&rpc.BalanceOptions{
73-
PrevAppBlk: pos.Prev,
74-
CurrBlk: trans.BlockNumber,
75-
Asset: s.Asset,
76-
Holder: s.AccountedFor,
77-
}); err != nil {
78-
return nil, err
79-
}
80-
reconciled = r.trialBalance(pos, trans, &s)
70+
reconciled, _ = r.trialBalance(pos, trans, &s)
8171
if reconciled && s.IsMaterial() {
8272
results = append(results, s)
8373
}
@@ -88,16 +78,7 @@ func (r *Reconciler1) GetStatements1(pos *types.AppPosition, trans *types.Transa
8878
if s, err := r.getStatementFromTraces(pos, trans, &s); err != nil {
8979
logger.Warn(colors.Yellow+"Statement at ", fmt.Sprintf("%d.%d", trans.BlockNumber, trans.TransactionIndex), " does not reconcile."+colors.Off)
9080
} else {
91-
var err error
92-
if s.PrevBal, s.BegBal, s.EndBal, err = r.opts.Connection.GetReconBalances(&rpc.BalanceOptions{
93-
PrevAppBlk: pos.Prev,
94-
CurrBlk: trans.BlockNumber,
95-
Asset: s.Asset,
96-
Holder: s.AccountedFor,
97-
}); err != nil {
98-
return nil, err
99-
}
100-
_ = r.trialBalance(pos, trans, s)
81+
_, _ = r.trialBalance(pos, trans, s)
10182
results = append(results, *s)
10283
}
10384
}
@@ -109,17 +90,7 @@ func (r *Reconciler1) GetStatements1(pos *types.AppPosition, trans *types.Transa
10990
} else {
11091
receiptStatements := make([]types.Statement, 0, len(statements))
11192
for _, s := range statements {
112-
var err error
113-
if s.PrevBal, s.BegBal, s.EndBal, err = r.opts.Connection.GetReconBalances(&rpc.BalanceOptions{
114-
PrevAppBlk: pos.Prev,
115-
CurrBlk: trans.BlockNumber,
116-
Asset: s.Asset,
117-
Holder: s.AccountedFor,
118-
}); err != nil {
119-
return nil, err
120-
}
121-
reconciled := r.trialBalance(pos, trans, &s)
122-
93+
reconciled, _ := r.trialBalance(pos, trans, &s)
12394
if reconciled {
12495
id := fmt.Sprintf(" %d.%d.%d", s.BlockNumber, s.TransactionIndex, s.LogIndex)
12596
logger.Progress(true, colors.Green+"Transaction", id, "reconciled "+colors.Off)

src/apps/chifra/pkg/ledger1/reconciler.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger"
1010
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/names"
1111
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/pricing"
12+
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc"
1213
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
1314
)
1415

@@ -63,7 +64,17 @@ type assetHolderKey struct {
6364
// any other reason. If that works and the statement is material (money moved in some way), the
6465
// function tries to price the asset. it then prints optional debugging information. Note that
6566
// the statement may be modified in this function.
66-
func (r *Reconciler1) trialBalance(pos *types.AppPosition, trans *types.Transaction, s *types.Statement) bool {
67+
func (r *Reconciler1) trialBalance(pos *types.AppPosition, trans *types.Transaction, s *types.Statement) (bool, error) {
68+
var err error
69+
if s.PrevBal, s.BegBal, s.EndBal, err = r.opts.Connection.GetReconBalances(&rpc.BalanceOptions{
70+
PrevAppBlk: pos.Prev,
71+
CurrBlk: trans.BlockNumber,
72+
Asset: s.Asset,
73+
Holder: s.AccountedFor,
74+
}); err != nil {
75+
return false, err
76+
}
77+
6778
var okay bool
6879
if okay = s.Reconciled(); !okay {
6980
if !s.IsEth() {
@@ -78,7 +89,7 @@ func (r *Reconciler1) trialBalance(pos *types.AppPosition, trans *types.Transact
7889
s.DebugStatement(pos)
7990
}
8091

81-
return s.Reconciled()
92+
return s.Reconciled(), nil
8293
}
8394

8495
func (r *Reconciler1) correctForSomethingElseToken(s *types.Statement) bool {

0 commit comments

Comments
 (0)