Skip to content

Commit

Permalink
fix packets
Browse files Browse the repository at this point in the history
  • Loading branch information
mossid committed Jun 13, 2019
1 parent 114f6f3 commit 7445bfd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x/ibc/04-channel/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (man CounterpartyManager) object(connid, chanid string) CounterObject {

seqsend: commitment.NewInteger(man.protocol.Value([]byte(key+"/nextSequenceSend")), mapping.Dec),
seqrecv: commitment.NewInteger(man.protocol.Value([]byte(key+"/nextSequenceRecv")), mapping.Dec),
// packets: commitment.NewIndexer(man.protocol.Prefix([]byte(key + "/packets")), mapping.Dec),
packets: commitment.NewIndexer(man.protocol.Prefix([]byte(key+"/packets")), mapping.Dec),
}
}

Expand Down Expand Up @@ -182,7 +182,7 @@ type CounterObject struct {

seqsend commitment.Integer
seqrecv commitment.Integer
//packets commitment.Indexer
packets commitment.Indexer

connection connection.CounterObject
}
Expand Down
22 changes: 22 additions & 0 deletions x/ibc/23-commitment/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ func (m Mapping) Value(key []byte) Value {
}
}

func (m Mapping) Prefix(prefix []byte) Mapping {
return Mapping{
base: m.base.Prefix(prefix),
}
}

type Indexer struct {
Mapping
enc mapping.IntEncoding
}

func NewIndexer(m Mapping, enc mapping.IntEncoding) Indexer {
return Indexer{
Mapping: m,
enc: enc,
}
}

func (ix Indexer) Value(index uint64) Value {
return ix.Mapping.Value(mapping.EncodeInt(index, ix.enc))
}

type Value struct {
base Base
key []byte
Expand Down

0 comments on commit 7445bfd

Please sign in to comment.