mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-16 04:24:56 +02:00
Merge branch 'table-deltas'
This commit is contained in:
commit
0b3b383977
4 changed files with 102 additions and 0 deletions
|
|
@ -67,3 +67,18 @@ func (a ActionChannel) Channel() Channel {
|
|||
|
||||
return ch
|
||||
}
|
||||
|
||||
// Table deltas
|
||||
type TableDeltaChannel struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func (td TableDeltaChannel) Channel() Channel {
|
||||
ch := Channel{"tabledeltas"}
|
||||
|
||||
if len(td.Name) > 0 {
|
||||
ch.Append("name", td.Name)
|
||||
}
|
||||
|
||||
return ch
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,3 +129,21 @@ func TestAction_Channel(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTableDelta_Channel(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
action TableDeltaChannel
|
||||
want Channel
|
||||
}{
|
||||
{"Empty", TableDeltaChannel{}, Channel{"tabledeltas"}},
|
||||
{"Contract", TableDeltaChannel{Name: "delta_name"}, Channel{"tabledeltas", "name", "delta_name"}},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.action.Channel(); !got.Is(tt.want) {
|
||||
t.Errorf("TableDeltaChannel.String() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,3 +85,16 @@ type RollbackMessage struct {
|
|||
OldBlockNum uint32 `json:"old_block" msgpack:"old_block"`
|
||||
NewBlockNum uint32 `json:"new_block" msgpack:"new_block"`
|
||||
}
|
||||
|
||||
type TableDeltaRow struct {
|
||||
Present bool `json:"present" msgpack:"present"`
|
||||
Data map[string]any `json:"data" msgpack:"data"`
|
||||
RawData []byte `json:"raw_data" msgpack:"raw_data"`
|
||||
}
|
||||
|
||||
type TableDelta struct {
|
||||
BlockNum uint32 `json:"blocknum" msgpack:"blocknum"`
|
||||
Timestamp time.Time `json:"blocktimestamp" msgpack:"blocktimestamp"`
|
||||
Name string `json:"name" msgpack:"name"`
|
||||
Rows []TableDeltaRow `json:"rows" msgpack:"rows"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue