-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from tonkeeper/historical-apy
Historical apy
- Loading branch information
Showing
8 changed files
with
192 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package litestorage | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/tonkeeper/opentonapi/pkg/core" | ||
"github.com/tonkeeper/tongo" | ||
"github.com/tonkeeper/tongo/tlb" | ||
) | ||
|
||
func (s *LiteStorage) GetLogs(ctx context.Context, account tongo.AccountID, destination *tlb.MsgAddress, limit int, beforeLT uint64) ([]core.Message, error) { | ||
var messages []core.Message | ||
if beforeLT == 0 { | ||
beforeLT = 1 << 63 | ||
} | ||
txLt := beforeLT | ||
for { | ||
txs, err := s.GetAccountTransactions(ctx, account, limit, txLt, 0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(txs) == 0 { | ||
return messages, nil | ||
} | ||
fmt.Println(len(txs), txs[0].Lt, txs[1].Lt) | ||
for _, tx := range txs { | ||
txLt = tx.Lt | ||
for _, m := range tx.OutMsgs { | ||
if m.CreatedLt >= beforeLT { | ||
continue | ||
} | ||
if m.Destination != nil { | ||
continue | ||
} | ||
if destination != nil { | ||
if destination.SumType == "AddrNone" && m.DestinationExtern != nil { | ||
continue | ||
} | ||
if destination.SumType == "AddrExtern" && (m.DestinationExtern == nil || m.DestinationExtern.ToFiftHex() != destination.AddrExtern.ExternalAddress.ToFiftHex()) { | ||
continue | ||
} | ||
} | ||
messages = append(messages, m) | ||
if len(messages) == limit { | ||
return messages, nil | ||
} | ||
} | ||
} | ||
if len(txs) < limit { | ||
return messages, nil | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package sentry | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
) | ||
|
||
type SentryInfoData map[string]interface{} | ||
|
||
var inited = false | ||
|
||
func init() { | ||
dsn := os.Getenv("SENTRY_DSN") | ||
if dsn == "" { | ||
return | ||
} | ||
err := sentry.Init(sentry.ClientOptions{ | ||
Dsn: dsn, | ||
TracesSampleRate: 1.0, | ||
}) | ||
if err != nil { | ||
fmt.Printf("failed to sentry init: %s", err) | ||
} | ||
inited = true | ||
sentry.Flush(2 * time.Second) | ||
} | ||
|
||
func Send(title string, data SentryInfoData, logLevel sentry.Level) { | ||
if !inited { | ||
return | ||
} | ||
|
||
go func(localHub *sentry.Hub) { | ||
localHub.ConfigureScope(func(scope *sentry.Scope) { | ||
scope.SetLevel(logLevel) | ||
scope.SetExtras(data) | ||
}) | ||
localHub.CaptureMessage(title) | ||
}(sentry.CurrentHub().Clone()) | ||
} |