Skip to content

Commit

Permalink
remove `The most annoying message in the work so it never goes unotic…
Browse files Browse the repository at this point in the history
…ed!`
  • Loading branch information
billettc committed Jan 12, 2021
1 parent ac27435 commit 5030ff7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 51 deletions.
4 changes: 2 additions & 2 deletions ACCOUNTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ STRUCTURE:
(account_meta_ptr as *const u8, mem::size_of::<AccountMeta>()), PARTIALLY
(hash_ptr as *const u8, mem::size_of::<Hash>()), FOUND
(data_ptr, data_len), FOUND



accounts/ files:


00000000 5B AD 9A D9 05 00 00 00
A5 00 00 00 00 00 00 00 [............... -> DATA_LEN (165)
A5 00 00 00 00 00 00 00 [............... -> DATA_LEN (165)
00000010 FA 5A 35 34 39 06 38 15 1B 33 6A 74 2F 64 8E 48 .Z549.8..3jt/d.H
00000020 38 5D 01 54 CF 90 F1 CA 55 DA 8D E9 75 B1 5C 28 8].T....U...u.\( -> pubkey de l'account
HrGhscadmYEhMu6tLqjFhTz3RkJm1kgzNzggh6NTopiK
Expand Down
5 changes: 1 addition & 4 deletions codec/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import (
)

func BlockFromProto(slot *pbcodec.Slot) (*bstream.Block, error) {
blockTime, err := slot.Time()
if err != nil {
return nil, err
}
blockTime := slot.Block.Time()

content, err := proto.Marshal(slot)
if err != nil {
Expand Down
Binary file removed dfusesol
Binary file not shown.
66 changes: 35 additions & 31 deletions pb/dfuse/solana/codec/v1/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,56 +31,60 @@ import (
// TODO: We should probably memoize all fields that requires computation
// like ID() and likes.

func (b *Slot) ID() string {
return b.Id
func (s *Slot) ID() string {
return s.Id
}

func (b *Slot) Num() uint64 {
return b.Number
func (s *Slot) Num() uint64 {
return s.Number
}

func (b *Slot) Time() (time.Time, error) {
fmt.Println("The most annoying message in the work so it never goes unoticed! This is broken, we are using 'time.Now()' as the block time!")
return time.Now(), nil
// timestamp, err := ptypes.Timestamp(b.Header.Timestamp)
// if err != nil {
// return time.Time{}, fmt.Errorf("unable to turn google proto Timestamp into time.Time: %s", err)
// }

// return timestamp, nil
}

func (b *Slot) MustTime() time.Time {
timestamp, err := b.Time()
if err != nil {
panic(err)
}

return timestamp
}

func (b *Block) PreviousID() string {
//func (b *Slot) Time() (time.Time, error) {
// fmt.Println("The most annoying message in the work so it never goes unoticed! This is broken, we are using 'time.Now()' as the block time!")
// return time.Now(), nil
// // timestamp, err := ptypes.Timestamp(b.Header.Timestamp)
// // if err != nil {
// // return time.Time{}, fmt.Errorf("unable to turn google proto Timestamp into time.Time: %s", err)
// // }
//
// // return timestamp, nil
//}
//
//func (b *Slot) MustTime() time.Time {
// timestamp, err := b.Time()
// if err != nil {
// panic(err)
// }
//
// return timestamp
//}

func (m *Block) PreviousID() string {
fmt.Println("The most annoying message in the work so it never goes unoticed! This is broken, the previous ID is always the empty string!")
return ""
}

func (m *Block) Time() time.Time {
return time.Unix(int64(m.ClockUnixTimestamp), 0)
}

// FIXME: This logic at some point is hard-coded and will need to be re-visited in regard
// of the fork logic.
func (b *Slot) LIBNum() uint64 {
if b.Number == bstream.GetProtocolFirstStreamableBlock {
func (s *Slot) LIBNum() uint64 {
if s.Number == bstream.GetProtocolFirstStreamableBlock {
return bstream.GetProtocolGenesisBlock
}

//todo: remove that -10 stuff
if b.Number <= 10 {
if s.Number <= 10 {
return bstream.GetProtocolFirstStreamableBlock
}

return b.Number - 10
return s.Number - 10
}

func (b *Slot) AsRef() bstream.BlockRef {
return bstream.NewBlockRef(b.ID(), b.Number)
func (s *Slot) AsRef() bstream.BlockRef {
return bstream.NewBlockRef(s.ID(), s.Number)
}

func BlockToBuffer(block *Slot) ([]byte, error) {
Expand Down
3 changes: 2 additions & 1 deletion pb/dfuse/solana/serumhist/v1/serumhist.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions serumhist/flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@ import (

pbcodec "github.com/dfuse-io/dfuse-solana/pb/dfuse/solana/codec/v1"
"github.com/dfuse-io/dfuse-solana/serumhist/metrics"
"go.uber.org/zap"
)

func (i *Injector) flush(ctx context.Context, slot *pbcodec.Slot) error {
slotNum := slot.Number
closeToHeadBlockTime := false
onFlushIntervalBoundary := slotNum%i.flushSlotInterval == 0

t, err := slot.Time()
if err != nil {
zlog.Warn("unable to determine slot time for flush... not relying on it",
zap.String("slot_id", slot.Id),
)
} else {
closeToHeadBlockTime = time.Since(t) < 25*time.Second
}
t := slot.Block.Time()
closeToHeadBlockTime = time.Since(t) < 25*time.Second

if onFlushIntervalBoundary || closeToHeadBlockTime {
reason := "needed"
Expand Down
5 changes: 1 addition & 4 deletions serumhist/injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ func (i *Injector) Launch(ctx context.Context, startBlockNum uint64) error {
return fmt.Errorf("error while flushing: %w", err)
}

t, err := slot.Time()
if err != nil {
return fmt.Errorf("unable to resolve slot time for slot %q: %w", slot.Number, err)
}
t := slot.Block.Time()

err = i.FlushIfNeeded(slot.Number, t)
if err != nil {
Expand Down

0 comments on commit 5030ff7

Please sign in to comment.