Complete output queue for create packet
This commit is contained in:
parent
7d3c0cd3e7
commit
1fc222e449
|
@ -173,7 +173,7 @@ func (h Handler) createPacket(ctx basecoin.Context, store state.KVStore,
|
||||||
|
|
||||||
// start making the packet to send
|
// start making the packet to send
|
||||||
packet := Packet{
|
packet := Packet{
|
||||||
DestChain: t.DestChain,
|
DestChain: dest,
|
||||||
Tx: t.Tx,
|
Tx: t.Tx,
|
||||||
Permissions: make([]basecoin.Actor, len(t.Permissions)),
|
Permissions: make([]basecoin.Actor, len(t.Permissions)),
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,9 @@ func (h Handler) createPacket(ctx basecoin.Context, store state.KVStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
// now add it to the output queue....
|
// now add it to the output queue....
|
||||||
// TODO: where to store, also set the sequence....
|
q := OutputQueue(store, dest)
|
||||||
|
packet.Sequence = q.Tail()
|
||||||
|
q.Push(packet.Bytes())
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,12 @@ const (
|
||||||
// we otherwise use the chainid as prefix, so this must not be an
|
// we otherwise use the chainid as prefix, so this must not be an
|
||||||
// alpha-numeric byte
|
// alpha-numeric byte
|
||||||
prefixChains = "**"
|
prefixChains = "**"
|
||||||
|
|
||||||
|
prefixInput = "i"
|
||||||
|
prefixOutput = "o"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// this is used for the global handler info
|
||||||
var (
|
var (
|
||||||
handlerKey = []byte{0x2}
|
handlerKey = []byte{0x2}
|
||||||
)
|
)
|
||||||
|
@ -77,7 +81,7 @@ func (c ChainSet) Register(chainID string, ourHeight uint64, theirHeight int) er
|
||||||
// send off to another chain.
|
// send off to another chain.
|
||||||
type Packet struct {
|
type Packet struct {
|
||||||
DestChain string `json:"dest_chain"`
|
DestChain string `json:"dest_chain"`
|
||||||
Sequence int `json:"sequence"`
|
Sequence uint64 `json:"sequence"`
|
||||||
Permissions []basecoin.Actor `json:"permissions"`
|
Permissions []basecoin.Actor `json:"permissions"`
|
||||||
Tx basecoin.Tx `json:"tx"`
|
Tx basecoin.Tx `json:"tx"`
|
||||||
}
|
}
|
||||||
|
@ -86,3 +90,17 @@ type Packet struct {
|
||||||
func (p Packet) Bytes() []byte {
|
func (p Packet) Bytes() []byte {
|
||||||
return wire.BinaryBytes(p)
|
return wire.BinaryBytes(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InputQueue returns the queue of input packets from this chain
|
||||||
|
func InputQueue(store state.KVStore, chainID string) *state.Queue {
|
||||||
|
ch := stack.PrefixedStore(chainID, store)
|
||||||
|
space := stack.PrefixedStore(prefixInput, ch)
|
||||||
|
return state.NewQueue(space)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OutputQueue returns the queue of output packets destined for this chain
|
||||||
|
func OutputQueue(store state.KVStore, chainID string) *state.Queue {
|
||||||
|
ch := stack.PrefixedStore(chainID, store)
|
||||||
|
space := stack.PrefixedStore(prefixOutput, ch)
|
||||||
|
return state.NewQueue(space)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue